:root {
  --bg:        #f0f2f5;
  --surface:   #ffffff;
  --surface2:  #f5f6fa;
  --accent:    #e8533a;
  --accent-bg: #fdf1ef;
  --text:      #1a1d23;
  --muted:     #9098b1;
  --border:    #eaecf4;
  --sidebar-w: 220px;
  --radius:    12px;
  --shadow:    0 1px 3px rgba(0,0,0,.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
}

a { color: var(--accent); text-decoration: none; }

/* ── Layout ── */
.layout { display: flex; min-height: 100vh; }

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

/* Logo */
.sidebar .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 20px 18px;
}

.sidebar .logo .logo-icon {
  width: 42px; height: 42px;
  background: #2563eb;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar .logo .logo-icon svg { width: 24px; height: 24px; fill: #fff; }
.sidebar .logo .logo-text { font-size: 1.05rem; font-weight: 700; color: var(--text); }

/* Nav */
.sidebar nav { flex: 1; padding: 8px 12px; overflow-y: auto; }

.nav-item { margin-bottom: 2px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  color: var(--muted);
  font-size: .875rem;
  font-weight: 500;
  border-radius: 0 8px 8px 0;
  cursor: pointer;
  transition: all .15s;
  border: none;
  border-left: 3px solid transparent;
  background: none;
  width: 100%;
  text-align: left;
  margin-right: 12px;
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; fill: currentColor; }
.nav-link .nav-arrow { margin-left: auto; width: 14px; height: 14px; transition: transform .2s; }
.nav-link:hover  { color: var(--text); background: var(--surface2); }
.nav-link.active { color: var(--accent); background: var(--accent-bg); font-weight: 600; border-left: 3px solid var(--accent); }

/* Submenú */
.nav-sub { display: none; padding: 2px 0 4px 40px; }
.nav-sub.open { display: block; }
.nav-sub a {
  display: block;
  padding: 7px 10px;
  color: var(--muted);
  font-size: .845rem;
  border-radius: 6px;
  transition: all .15s;
}
.nav-sub a:hover, .nav-sub a.active { color: var(--accent); font-weight: 600; }
.nav-item.open .nav-arrow { transform: rotate(180deg); }

/* Footer sidebar */
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  text-align: center;
}
.sidebar-footer .brand { font-size: .78rem; font-weight: 700; color: var(--muted); }
.sidebar-footer .copy  { font-size: .72rem; color: var(--muted); margin-top: 2px; }

/* ════════════════════════════════════════
   TOPBAR
════════════════════════════════════════ */
.topbar-bar {
  position: fixed;
  top: 0; left: var(--sidebar-w); right: 0;
  height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  z-index: 40;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
}

.topbar-left { display: flex; align-items: center; gap: 16px; }

.hamburger {
  background: none; border: none; cursor: pointer;
  color: var(--accent); padding: 4px;
  display: flex; align-items: center;
}
.hamburger svg { width: 22px; height: 22px; fill: currentColor; }

.topbar-right { display: flex; align-items: center; gap: 12px; }

.user-avatar-wrap {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; padding: 6px 10px;
  border-radius: 8px; transition: background .15s;
  border: none;
  background: transparent;
}
.user-avatar-wrap:hover { background: var(--surface2); }

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fb923c, #e8533a);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: .78rem; font-weight: 700;
  flex-shrink: 0;
}
.user-avatar-name { font-size: .9rem; font-weight: 600; color: var(--text); }

/* User Dropdown Menu */
.user-menu-container { position: relative; }

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  min-width: 220px;
  z-index: 1000;
  display: none;
  overflow: hidden;
}

.user-dropdown.open { display: block; }

.user-dropdown-header {
  padding: 14px 16px;
  background: var(--surface2);
}

.user-dropdown-name {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.user-dropdown-email {
  font-size: .78rem;
  color: var(--muted);
}

.user-dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  font-size: .875rem;
  color: var(--text);
  cursor: pointer;
  transition: background .12s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  text-decoration: none;
}

.user-dropdown-item:hover {
  background: var(--surface2);
}

.user-dropdown-item svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.user-menu-arrow {
  transition: transform .2s;
}

.user-avatar-wrap:hover .user-menu-arrow {
  transform: translateY(1px);
}

/* ════════════════════════════════════════
   MAIN
════════════════════════════════════════ */
.main {
  margin-left: var(--sidebar-w);
  padding-top: 64px;
  flex: 1;
  min-height: 100vh;
  background: var(--bg);
}

.main-content { padding: 32px 36px; }

/* Page header dentro del main-content */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-title { font-size: 1.3rem; font-weight: 700; color: var(--text); margin-bottom: 24px; }

/* ════════════════════════════════════════
   CARDS
════════════════════════════════════════ */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.card-title {
  font-size: .72rem; font-weight: 700;
  color: var(--muted); text-transform: uppercase;
  letter-spacing: .6px; margin-bottom: 16px;
}

/* ════════════════════════════════════════
   STATS
════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
}
.stat-card .value { font-size: 2rem; font-weight: 700; color: var(--accent); }
.stat-card .label { font-size: .82rem; color: var(--muted); margin-top: 4px; }

/* ════════════════════════════════════════
   FORMS
════════════════════════════════════════ */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; }

input, select, textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 13px;
  font-size: .9rem;
  outline: none;
  transition: border .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(232,83,58,.1);
}
textarea { resize: vertical; min-height: 90px; }

/* ════════════════════════════════════════
   BUTTONS
════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 8px; border: none;
  cursor: pointer; font-size: .875rem; font-weight: 600;
  transition: opacity .15s, box-shadow .15s;
  white-space: nowrap;
}
.btn:hover { opacity: .88; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 2px 8px rgba(232,83,58,.25); }
.btn-danger  { background: #e74c3c; color: #fff; }
.btn-warn    { background: #f39c12; color: #fff; }
.btn-ghost   { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-blue    { background: #2563eb; color: #fff; }
.btn-sm      { padding: 5px 12px; font-size: .8rem; }

/* ════════════════════════════════════════
   TABLE
════════════════════════════════════════ */
.table-wrap { overflow-x: auto; overflow-y: visible; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; overflow: visible; }
th {
  text-align: left; padding: 10px 16px;
  color: var(--muted); font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
}
td { padding: 14px 16px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }

/* ════════════════════════════════════════
   BADGES
════════════════════════════════════════ */
.badge {
  display: inline-block; padding: 3px 10px;
  border-radius: 20px; font-size: .75rem; font-weight: 600;
}
.badge-green  { background: #e6f9f0; color: #1a9e5c; }
.badge-red    { background: #fdecea; color: #c0392b; }
.badge-yellow { background: #fef9e7; color: #d68910; }
.badge-orange { background: #fdf1ef; color: var(--accent); }
.badge-gray   { background: var(--surface2); color: var(--muted); }
.badge-blue   { background: #eff6ff; color: #2563eb; }

/* ════════════════════════════════════════
   LOGIN
════════════════════════════════════════ */
.login-wrap {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  background: var(--bg);
}
.login-box {
  background: var(--surface); border-radius: var(--radius);
  padding: 40px; width: 100%; max-width: 400px;
  box-shadow: 0 4px 24px rgba(0,0,0,.08);
}
.login-box .logo-wrap {
  display: flex; flex-direction: column;
  align-items: center; margin-bottom: 28px; gap: 8px;
}
.login-box .logo-icon {
  width: 56px; height: 56px; background: #2563eb;
  border-radius: 14px; display: flex;
  align-items: center; justify-content: center;
}
.login-box .logo-icon svg { width: 30px; height: 30px; fill: #fff; }
.login-box .logo-name { font-size: 1.3rem; font-weight: 700; color: var(--text); }
.login-box .subtitle  { font-size: .85rem; color: var(--muted); }

/* ════════════════════════════════════════
   ALERTS
════════════════════════════════════════ */
.alert { padding: 11px 15px; border-radius: 8px; font-size: .875rem; margin-bottom: 16px; }
.alert-error   { background: #fdecea; color: #c0392b; border: 1px solid #f5c6c2; }
.alert-success { background: #e6f9f0; color: #1a9e5c; border: 1px solid #b2e8cf; }

/* ════════════════════════════════════════
   QR
════════════════════════════════════════ */
.qr-box { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 20px; }
.qr-box img { border-radius: 8px; border: 4px solid var(--border); width: 220px; height: 220px; }

/* ════════════════════════════════════════
   MODAL
════════════════════════════════════════ */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.3); z-index: 100;
  align-items: flex-start; justify-content: center;
  overflow-y: auto;
  padding: 40px 16px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius);
  padding: 28px; width: 100%; max-width: 480px;
  position: relative; box-shadow: 0 8px 32px rgba(0,0,0,.12);
  margin: auto;
}
.modal-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 20px; }
.modal-close {
  position: absolute; top: 16px; right: 16px;
  background: var(--surface2); border: none; color: var(--muted);
  font-size: .9rem; cursor: pointer; border-radius: 50%;
  width: 28px; height: 28px; display: flex;
  align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--border); }

/* ════════════════════════════════════════
   MISC
════════════════════════════════════════ */
.flex            { display: flex; }
.gap-2           { gap: 8px; }
.gap-3           { gap: 12px; }
.justify-between { justify-content: space-between; }
.align-center    { align-items: center; }
.mb-4            { margin-bottom: 16px; }
.text-muted      { color: var(--muted); font-size: .85rem; }
.empty-state     { text-align: center; padding: 48px; color: var(--muted); }
code {
  background: var(--surface2); padding: 2px 6px;
  border-radius: 4px; font-size: .82rem; color: var(--accent);
}


/* ════════════════════════════════════════
   STATS CARDS
════════════════════════════════════════ */
.stat-card {
  background: var(--surface2);
  border-radius: 10px;
  padding: 20px;
  text-align: center;
}
