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

:root {
  --sidebar-w: 232px;
  --sidebar-bg: #0f172a;
  --sidebar-border: rgba(255,255,255,.06);
  --sidebar-text: #94a3b8;
  --sidebar-text-hover: #e2e8f0;
  --sidebar-active-bg: rgba(99,102,241,.18);
  --sidebar-active-text: #a5b4fc;
  --sidebar-active-border: #6366f1;
  --sidebar-logo-text: #f1f5f9;
  --accent: #6366f1;
  --accent-dark: #4f46e5;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

body { font-family: var(--font); font-size: 14px; background: #f1f5f9; color: #1a1a2e; display: flex; min-height: 100vh; }

.hidden { display: none !important; }

/* ── Login ─────────────────────────────────────────────────── */
#login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; width: 100%; }
.login-box { background: #fff; padding: 40px; border-radius: 12px; box-shadow: 0 4px 24px rgba(0,0,0,.10); width: 340px; }
.login-box h1 { text-align: center; margin-bottom: 4px; font-size: 22px; color: var(--accent); }
.login-sub { text-align: center; color: #94a3b8; font-size: 13px; margin-bottom: 28px; }
.login-box input { width: 100%; padding: 10px 14px; margin-bottom: 14px; border: 1px solid #dde1e7; border-radius: 8px; font-size: 14px; outline: none; transition: border .2s; }
.login-box input:focus { border-color: var(--accent); }
.login-box button { width: 100%; padding: 11px; background: var(--accent); color: #fff; border: none; border-radius: 8px; font-size: 15px; cursor: pointer; transition: background .2s; }
.login-box button:hover { background: var(--accent-dark); }

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

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--sidebar-border);
}
.sidebar-logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.sidebar-logo-text {
  color: var(--sidebar-logo-text);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
}
.sidebar-logo-sub {
  color: var(--sidebar-text);
  font-size: 11px;
  font-weight: 400;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--sidebar-text);
  padding: 10px 8px 4px;
  opacity: .6;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 500;
  transition: background .15s, color .15s;
  border-left: 2px solid transparent;
  cursor: pointer;
}
.nav-link:hover {
  background: rgba(255,255,255,.06);
  color: var(--sidebar-text-hover);
}
.nav-link.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  border-left-color: var(--sidebar-active-border);
}
.nav-link svg { flex-shrink: 0; opacity: .8; }
.nav-link.active svg { opacity: 1; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--sidebar-border);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--sidebar-text);
}
.sidebar-user span { flex: 1; color: var(--sidebar-text-hover); font-weight: 500; }
.sidebar-logout {
  padding: 4px 10px;
  border: 1px solid var(--sidebar-border);
  border-radius: 6px;
  background: none;
  color: var(--sidebar-text);
  font-size: 11px;
  cursor: pointer;
  transition: all .15s;
}
.sidebar-logout:hover { background: rgba(255,255,255,.08); color: var(--sidebar-text-hover); }

/* ── Main layout ───────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.content { padding: 24px; flex: 1; max-width: 1200px; width: 100%; }

/* ── Content ───────────────────────────────────────────────── */
.tab-content { padding: 0; }
.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.toolbar h2 { font-size: 18px; font-weight: 600; color: #0f172a; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn-primary { padding: 8px 18px; background: var(--accent); color: #fff; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; transition: background .2s; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-icon { padding: 5px 10px; border: 1px solid #e5e7eb; border-radius: 6px; background: none; cursor: pointer; font-size: 13px; color: #6b7280; transition: all .2s; margin-left: 4px; }
.btn-icon:hover { background: #f3f4f6; }
.btn-danger { border-color: #fca5a5; color: #ef4444; }
.btn-danger:hover { background: #fef2f2; }
.btn-secondary { padding: 8px 18px; border: 1px solid #d1d5db; border-radius: 8px; background: none; cursor: pointer; font-size: 14px; color: #374151; transition: background .2s; }
.btn-secondary:hover { background: #f9fafb; }

/* ── Table ─────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 1px 6px rgba(0,0,0,.06); }
th { padding: 12px 16px; text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: #6b7280; background: #f9fafb; border-bottom: 1px solid #e5e7eb; }
td { padding: 12px 16px; border-bottom: 1px solid #f3f4f6; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }

/* ── Toggle ────────────────────────────────────────────────── */
.toggle { position: relative; width: 36px; height: 20px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: #d1d5db; border-radius: 20px; cursor: pointer; transition: .2s; }
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle-slider::before { content: ''; position: absolute; width: 14px; height: 14px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); }

/* ── Modal ─────────────────────────────────────────────────── */
#modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 200; }
.modal { background: #fff; border-radius: 12px; width: 560px; max-width: 95vw; max-height: 90vh; overflow-y: auto; box-shadow: 0 8px 40px rgba(0,0,0,.18); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid #e5e7eb; }
.modal-header h3 { font-size: 16px; }
#modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: #9ca3af; line-height: 1; }
#modal-close:hover { color: #374151; }
#modal-body { padding: 24px; }

/* ── Form ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 9px 12px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 14px; outline: none; transition: border .2s; font-family: inherit; }
.form-group textarea { height: 140px; resize: vertical; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--accent); }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ── Handbook column filters ───────────────────────────────── */
.hb-col-filter {
  display: block; width: 100%; margin-top: 5px; padding: 3px 6px;
  font-size: 11px; font-weight: normal; letter-spacing: 0; text-transform: none;
  color: #374151; background: #fff; border: 1px solid #d1d5db; border-radius: 4px;
  outline: none; transition: border .2s;
}
.hb-col-filter:focus { border-color: var(--accent); }
#handbook-table th { vertical-align: top; }

/* ── Misc ──────────────────────────────────────────────────── */
.error { color: #ef4444; font-size: 13px; margin-top: 8px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 12px; }
.badge-active { background: #dcfce7; color: #16a34a; }
.badge-inactive { background: #f3f4f6; color: #9ca3af; }
.stage-label { font-size: 12px; color: #6b7280; max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
