@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,600;1,300&family=Montserrat:wght@300;400;500;600&display=swap');

/* ── Variables ── */
:root {
  --black:       #080808;
  --surface:     #111111;
  --surface-2:   #1a1a1a;
  --surface-3:   #222222;
  --border:      rgba(255,255,255,0.07);
  --border-gold: rgba(201,168,76,0.25);
  --gold:        #c9a84c;
  --gold-light:  #e8c97a;
  --gold-dim:    #9a7a35;
  --text:        #f0ede8;
  --text-muted:  rgba(240,237,232,0.45);
  --text-soft:   rgba(240,237,232,0.7);
  --danger:      #e05252;
  --success:     #4caf7d;
  --warning:     #e0a84c;
  --info:        #4c8fe0;
  --radius:      8px;
  --radius-lg:   14px;
  --sidebar-w:   240px;
  --header-h:    60px;
  --font-sans:   'Montserrat', system-ui, sans-serif;
  --font-serif:  'Cormorant Garamond', Georgia, serif;
  --transition:  0.18s ease;
}

/* ── Reset ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body { background: var(--black); color: var(--text); font-family: var(--font-sans); min-height: 100vh; overflow-x: hidden; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, select, textarea { font-family: inherit; outline: none; }
ul { list-style: none; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-gold); border-radius: 4px; }

/* ── Layout principal ── */
#app { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-logo {
  padding: 1.4rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-logo .brand {
  font-family: var(--font-sans);
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: .35em;
  text-transform: uppercase;
  color: var(--gold);
}

.sidebar-logo .system {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 300;
  color: var(--text);
  letter-spacing: .06em;
}

.sidebar-nav { flex: 1; padding: 1rem 0; overflow-y: auto; }

.nav-section {
  padding: .3rem 1rem .1rem;
  font-size: .55rem;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: .8rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem 1.5rem;
  font-size: .8rem;
  font-weight: 400;
  color: var(--text-soft);
  transition: all var(--transition);
  border-left: 2px solid transparent;
  cursor: pointer;
}

.nav-item:hover { color: var(--text); background: rgba(255,255,255,.03); }
.nav-item.active { color: var(--gold); border-left-color: var(--gold); background: rgba(201,168,76,.06); }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .7; }
.nav-item.active svg { opacity: 1; }

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  font-size: .75rem;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--gold-dim);
  display: flex; align-items: center; justify-content: center;
  font-size: .65rem;
  font-weight: 600;
  color: var(--black);
  flex-shrink: 0;
}

.user-info .name { font-weight: 500; font-size: .78rem; color: var(--text); }
.user-info .role { font-size: .65rem; color: var(--text-muted); letter-spacing: .05em; }

.btn-logout {
  margin-top: .75rem;
  width: 100%;
  padding: .5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: .72rem;
  text-align: center;
  transition: all var(--transition);
}
.btn-logout:hover { border-color: var(--danger); color: var(--danger); }

/* ── Contenido principal ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Topbar ── */
.topbar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 90;
}

.topbar-title { font-size: 1rem; font-weight: 500; color: var(--text); }
.topbar-sub   { font-size: .72rem; color: var(--text-muted); margin-top: 1px; }
.topbar-actions { display: flex; align-items: center; gap: .75rem; }

/* ── Page ── */
.page { padding: 2rem; display: none; }
.page.active { display: block; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.card-title {
  font-size: .75rem;
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ── Stat cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.4rem 1.5rem;
  transition: border-color var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--gold);
  opacity: 0;
  transition: opacity var(--transition);
}

.stat-card:hover { border-color: var(--border-gold); }
.stat-card:hover::before { opacity: 1; }

.stat-label {
  font-size: .65rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: .75rem;
}

.stat-value {
  font-family: var(--font-serif);
  font-size: 2.4rem;
  font-weight: 600;
  color: var(--gold);
  line-height: 1;
  margin-bottom: .3rem;
}

.stat-desc { font-size: .72rem; color: var(--text-muted); }

/* ── Tabla ── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}

thead th {
  padding: .65rem 1rem;
  text-align: left;
  font-size: .62rem;
  font-weight: 500;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

tbody tr:hover { background: rgba(255,255,255,.02); }
tbody tr:last-child { border-bottom: none; }

tbody td {
  padding: .85rem 1rem;
  color: var(--text-soft);
  vertical-align: middle;
}

tbody td:first-child { color: var(--text); font-weight: 500; }

/* ── Badge / Pill ── */
.badge {
  display: inline-block;
  padding: .2rem .65rem;
  border-radius: 20px;
  font-size: .65rem;
  font-weight: 500;
  letter-spacing: .05em;
}

.badge-success  { background: rgba(76,175,125,.12); color: var(--success); }
.badge-danger   { background: rgba(224,82,82,.12);  color: var(--danger); }
.badge-warning  { background: rgba(224,168,76,.12); color: var(--warning); }
.badge-info     { background: rgba(76,143,224,.12); color: var(--info); }
.badge-muted    { background: rgba(255,255,255,.06); color: var(--text-muted); }

/* ── Botones ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem 1.1rem;
  border-radius: var(--radius);
  font-size: .78rem;
  font-weight: 500;
  transition: all var(--transition);
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--gold);
  color: var(--black);
  border-color: var(--gold);
}
.btn-primary:hover { background: var(--gold-light); border-color: var(--gold-light); }

.btn-ghost {
  border-color: var(--border);
  color: var(--text-soft);
}
.btn-ghost:hover { border-color: var(--border-gold); color: var(--gold); }

.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: rgba(224,82,82,.1); }

.btn svg { width: 14px; height: 14px; }

/* ── Formularios ── */
.form-group { margin-bottom: 1.1rem; }

.form-label {
  display: block;
  font-size: .7rem;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: .4rem;
}

.form-input, .form-select {
  width: 100%;
  padding: .65rem .9rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .84rem;
  transition: border-color var(--transition);
}

.form-input:focus, .form-select:focus {
  border-color: var(--gold-dim);
}

.form-input::placeholder { color: var(--text-muted); }
.form-select option { background: var(--surface-2); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
}

.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  padding: 2rem;
  transform: translateY(12px);
  transition: transform var(--transition);
}

.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.modal-title {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 300;
  color: var(--text);
}

.modal-close {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  transition: all var(--transition);
}

.modal-close:hover { border-color: var(--danger); color: var(--danger); }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: .75rem;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

/* ── Search ── */
.search-box {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .45rem .8rem;
  transition: border-color var(--transition);
}

.search-box:focus-within { border-color: var(--gold-dim); }
.search-box svg { width: 14px; height: 14px; color: var(--text-muted); flex-shrink: 0; }
.search-box input { background: none; border: none; color: var(--text); font-size: .82rem; width: 200px; }
.search-box input::placeholder { color: var(--text-muted); }

/* ── Toast ── */
.toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; display: flex; flex-direction: column; gap: .5rem; z-index: 999; }

.toast {
  padding: .75rem 1.1rem;
  border-radius: var(--radius);
  font-size: .8rem;
  font-weight: 500;
  border-left: 3px solid;
  background: var(--surface-2);
  animation: toastIn .2s ease;
  min-width: 220px;
}

.toast-success { border-color: var(--success); color: var(--success); }
.toast-error   { border-color: var(--danger);  color: var(--danger); }
.toast-info    { border-color: var(--gold);     color: var(--gold); }

@keyframes toastIn { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state svg { width: 40px; height: 40px; margin: 0 auto 1rem; opacity: .3; }
.empty-state p { font-size: .85rem; }

/* ── Loading ── */
.loading { display: flex; align-items: center; justify-content: center; padding: 2rem; }
.spinner {
  width: 24px; height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; }
  .main-content { margin-left: 0; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
