:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --sidebar-bg: #0e2431;
  --sidebar-bg-2: #0b1d28;
  --sidebar-text: #b8c9d4;
  --sidebar-active: #ffffff;
  --primary: #0f9d6a;
  --primary-dark: #0b7d54;
  --primary-soft: #e3f6ee;
  --accent: #f2b32e;
  --danger: #d64545;
  --danger-soft: #fdecec;
  --warning: #c98a1b;
  --warning-soft: #fdf3e0;
  --info: #2b7de0;
  --info-soft: #e8f1fd;
  --muted: #64748b;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-soft: #475569;
  --shadow: 0 1px 3px rgba(16, 42, 67, 0.08), 0 1px 2px rgba(16, 42, 67, 0.04);
  --shadow-lg: 0 10px 25px -5px rgba(16, 42, 67, 0.12), 0 8px 10px -6px rgba(16, 42, 67, 0.06);
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

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

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--sidebar-bg), var(--sidebar-bg-2));
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  flex-shrink: 0;
}

.brand-name { color: #fff; font-weight: 700; font-size: 16px; line-height: 1.2; }
.brand-sub { font-size: 11px; opacity: 0.7; letter-spacing: 0.4px; }

.nav { padding: 14px 10px 24px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: #5d7d8d; opacity: 0.55; padding: 14px 10px 6px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: 8px;
  color: var(--sidebar-text);
  margin-bottom: 2px;
  font-size: 13.5px;
}
.nav a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav a.active { background: var(--primary); color: #fff; font-weight: 600; }
.nav a .ic { width: 18px; text-align: center; flex-shrink: 0; opacity: 0.9; }
.nav .has-sub > a::after {
  content: "";
  margin-left: auto;
  border: 5px solid transparent;
  border-top-color: currentColor;
  border-bottom: none;
  opacity: 0.6;
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
  opacity: 0.7;
}

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 62px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-title { font-size: 17px; font-weight: 700; }

.topbar-search {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  min-width: 260px;
  color: var(--muted);
}
.topbar-search input {
  border: none;
  outline: none;
  background: transparent;
  font-size: 13px;
  width: 100%;
  font-family: var(--font);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  white-space: nowrap;
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}

.content { padding: 24px; max-width: 1440px; width: 100%; margin: 0 auto; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-head h1 { font-size: 22px; font-weight: 800; }
.page-head p { color: var(--muted); margin-top: 3px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  background: var(--surface);
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { border-color: var(--border); color: var(--text-soft); background: var(--surface); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--text-soft); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 7px; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-head h3 { font-size: 15px; font-weight: 700; }
.card-head p { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.card-body { padding: 20px; }
.card-body.flush { padding: 0; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ---------- Stat cards ---------- */
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.stat .stat-label { font-size: 12.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; padding-right: 46px; }
.stat .stat-value { font-size: 28px; font-weight: 800; margin-top: 6px; }
.stat .stat-foot { font-size: 12px; color: var(--muted); margin-top: 6px; }
.stat .stat-ic {
  position: absolute;
  right: 16px;
  top: 16px;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.stat.green .stat-ic { background: var(--primary-soft); }
.stat.blue .stat-ic { background: var(--info-soft); }
.stat.amber .stat-ic { background: var(--warning-soft); }
.stat.red .stat-ic { background: var(--danger-soft); }
.stat.green .stat-value { color: var(--primary-dark); }
.stat.blue .stat-value { color: var(--info); }
.stat.amber .stat-value { color: var(--warning); }
.stat.red .stat-value { color: var(--danger); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left;
  padding: 11px 16px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }
td .cell-sub { font-size: 12px; color: var(--muted); }
td.num, th.num { text-align: right; }
td.actions { text-align: right; white-space: nowrap; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.success { background: var(--primary-soft); color: var(--primary-dark); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.muted { background: #eef1f5; color: var(--muted); }
.badge.plain::before { display: none; }
.badge.step::before { display: none; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field { min-width: 0; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-soft); margin-bottom: 6px; }
.field label .req { color: var(--danger); }
.field input, .field select, .field textarea {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  font-family: var(--font);
  background: var(--surface);
  color: var(--text);
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 157, 106, 0.12);
}
.field input[type="checkbox"], .field input[type="radio"] { width: auto; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.check-label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; color: var(--text-soft); }

/* ---------- Steps / workflow ---------- */
.flow {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.flow .step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}
.flow .step .step-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #eef1f5;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}
.flow .step.done { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); }
.flow .step.done .step-num { background: var(--primary); color: #fff; }
.flow .step.current { border-color: var(--accent); background: var(--warning-soft); color: var(--warning); }
.flow .step.current .step-num { background: var(--accent); color: #fff; }
.flow .step.rejected { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.flow .step.rejected .step-num { background: var(--danger); color: #fff; }
.flow .arrow { color: var(--border); font-weight: 700; }

/* ---------- Misc ---------- */
.pill { display: inline-block; padding: 3px 9px; border-radius: 6px; font-size: 12px; font-weight: 600; background: #eef1f5; color: var(--muted); }
.pill.green { background: var(--primary-soft); color: var(--primary-dark); }

.alert {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid transparent;
}
.alert.info { background: var(--info-soft); color: #1e5fae; border-color: #cfe2fb; }
.alert.warn { background: var(--warning-soft); color: var(--warning); border-color: #f3ddb0; }
.alert.success { background: var(--primary-soft); color: var(--primary-dark); border-color: #c6ebdb; }

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

.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-16 { margin-bottom: 16px; }
.text-muted { color: var(--muted); }
.text-small { font-size: 12.5px; }
.text-danger { color: var(--danger); }
.text-primary { color: var(--primary); }
.font-bold { font-weight: 700; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.flex-col { flex-direction: column; align-items: stretch; }
.flex-wrap { flex-wrap: wrap; }
.right { text-align: right; }
.grow { flex: 1; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.tab {
  display: block;
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  text-decoration: none;
}
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- Permission matrix ---------- */
.permission-table td { font-size: 13px; }
.permission-table .perm-check { text-align: center; }
.permission-table .perm-check input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.role-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
}
.role-tag .role-dot { width: 8px; height: 8px; border-radius: 50%; }

/* ---------- Modals ---------- */
.modal { display: none; }
.modal:target { display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px 32px; position: fixed; inset: 0; z-index: 100; }
/* A failed submit reopens the modal it came from, so the typed work and the
   validation message land in the same place. Set by Blade from old('_modal'). */
.modal.open { display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px 32px; position: fixed; inset: 0; z-index: 100; }
.modal.open .modal-dialog,
.modal.open .modal-card { animation: modalIn 0.18s ease; }
.modal-overlay { position: fixed; inset: 0; background: rgba(11, 29, 40, 0.55); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
.modal-dialog,
.modal-card {
  position: relative; z-index: 1;
  background: var(--surface);
  border-radius: 14px;
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-dialog.wide,
.modal-card.wide { max-width: 960px; }
.modal-dialog.narrow,
.modal-card.narrow { max-width: 460px; }
.modal:target .modal-dialog,
.modal:target .modal-card { animation: modalIn 0.18s ease; }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 2;
}
.modal-head h3 { font-size: 16px; font-weight: 700; }
.modal-head p { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.modal-close {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; line-height: 1;
  color: var(--muted);
  background: var(--bg);
  flex-shrink: 0;
  cursor: pointer;
}
.modal-close:hover { background: var(--danger-soft); color: var(--danger); }
.modal-body { padding: 20px 22px; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  background: var(--surface);
}

/* ---------- Login ---------- */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0e2431 0%, #124735 55%, #0f9d6a 130%);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.login-card .login-head {
  padding: 28px 32px 8px;
  text-align: center;
}
.login-brand {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
  border-radius: 14px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 800;
}
.login-card h1 { font-size: 21px; font-weight: 800; }
.login-card .login-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.login-card .login-form { padding: 22px 32px 30px; }
.login-note {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

/* ---------- Dashboard widgets ---------- */
.chart-bar { display: flex; align-items: flex-end; gap: 14px; height: 180px; padding-top: 10px; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.chart-col .bar {
  width: 100%;
  max-width: 42px;
  border-radius: 7px 7px 0 0;
  background: linear-gradient(180deg, var(--primary), var(--primary-dark));
  min-height: 6px;
}
.chart-col .bar.alt { background: linear-gradient(180deg, #7ac7a8, var(--primary)); }
.chart-col .bar.amber { background: linear-gradient(180deg, var(--accent), #c98a1b); }
.chart-col span { font-size: 11px; color: var(--muted); font-weight: 600; }

.kpi-list { display: flex; flex-direction: column; }
.kpi-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.kpi-row:last-child { border-bottom: none; }
.kpi-row .kpi-ic {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}
.kpi-row .kpi-name { font-weight: 600; font-size: 13px; }
.kpi-row .kpi-val { margin-left: auto; font-weight: 800; font-size: 16px; }
.kpi-row .kpi-val.small { font-size: 13px; color: var(--muted); }

/* ---------- Workflow queue ---------- */
.queue-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.queue-item:last-child { border-bottom: none; }
.queue-item .qi-ic {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}
.queue-item .qi-title { font-weight: 600; font-size: 13.5px; }
.queue-item .qi-sub { font-size: 12.5px; color: var(--muted); }
.queue-item .qi-right { margin-left: auto; text-align: right; flex-shrink: 0; }

/* ---------- Activity / timeline ---------- */
.timeline { position: relative; padding-left: 26px; }
.timeline::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--border);
}
.timeline .tl-item { position: relative; padding: 0 0 20px 12px; }
.timeline .tl-item:last-child { padding-bottom: 0; }
.timeline .tl-item::before {
  content: "";
  position: absolute;
  left: -26px;
  top: 5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--primary-soft);
}
.timeline .tl-item.amber::before { background: var(--accent); box-shadow: 0 0 0 2px var(--warning-soft); }
.timeline .tl-item.red::before { background: var(--danger); box-shadow: 0 0 0 2px var(--danger-soft); }
.timeline .tl-title { font-weight: 600; font-size: 13.5px; }
.timeline .tl-sub { font-size: 12.5px; color: var(--muted); }
.timeline .tl-time { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* ---------- Mobile ---------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: transform 0.2s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .topbar-search { min-width: 0; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .grid-4, .grid-3 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .page-head h1 { font-size: 19px; }
}

/* ---------- Collapsible nav groups ---------- */
.nav-group { margin-bottom: 2px; }
.nav-group > summary {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: 8px;
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary::marker { content: ""; }
.nav-group > summary:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav-group > summary .ic { width: 18px; flex-shrink: 0; opacity: 0.9; }
.nav-group > summary .caret {
  margin-left: auto;
  width: 0;
  height: 0;
  border: 4px solid transparent;
  border-top-color: currentColor;
  border-bottom: none;
  opacity: 0.6;
  transition: transform 0.15s ease;
}
.nav-group[open] > summary { color: #fff; }
.nav-group[open] > summary .caret { transform: rotate(180deg); }
.nav-group .nav-sub { padding: 2px 0 6px 29px; display: flex; flex-direction: column; gap: 1px; }
.nav-group .nav-sub a {
  display: block;
  padding: 7px 11px;
  border-radius: 7px;
  color: var(--sidebar-text);
  font-size: 13px;
  opacity: 0.85;
}
.nav-group .nav-sub a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; opacity: 1; }
.nav-group .nav-sub a.active { background: var(--primary); color: #fff; font-weight: 600; opacity: 1; }
.nav-group > summary .grp-count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  background: var(--accent);
  color: #16232b;
  border-radius: 99px;
  padding: 1px 7px;
}
.nav-group > summary .grp-count + .caret { margin-left: 8px; }

/* ---------- Persona cards ---------- */
.persona-head { display: flex; align-items: flex-start; gap: 13px; }
.persona-head .avatar-md {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: linear-gradient(150deg, var(--primary), var(--primary-dark));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 800;
  flex-shrink: 0;
}
.persona-head .avatar-md.blue { background: linear-gradient(150deg, #5fa4ee, var(--info)); }
.persona-head .avatar-md.amber { background: linear-gradient(150deg, var(--accent), #b8791a); }
.persona-head .avatar-md.slate { background: linear-gradient(150deg, #64748b, #334155); }
.persona-head .p-name { font-size: 15px; font-weight: 700; }
.persona-head .p-title { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.p-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 800;
  color: var(--muted);
  margin-bottom: 8px;
}
.p-list { list-style: none; display: flex; flex-direction: column; gap: 7px; }
.p-list li {
  font-size: 12.5px;
  color: var(--text-soft);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.45;
}
.p-list li::before { content: "\2713"; color: var(--primary); font-weight: 800; flex-shrink: 0; }
.p-list.cannot li::before { content: "\00d7"; color: var(--danger); font-size: 14px; line-height: 1.2; }

/* ---------- Mobile nav toggle (pure CSS, via :target) ---------- */
.topbar-menu { display: none; }
.nav-close { display: none; }

@media (max-width: 900px) {
  .topbar-menu {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-soft);
    flex-shrink: 0;
  }
  .topbar-menu:hover { border-color: var(--primary); color: var(--primary); }
  .sidebar:target { transform: translateX(0); }
  .sidebar:target .nav-close {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 14px;
    right: 12px;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 20px;
    line-height: 1;
  }
  .sidebar:target .nav-close:hover { background: rgba(214, 69, 69, 0.35); }
}

/* ---------- Topbar notification bell ---------- */
.topbar-bell {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.topbar-bell:hover { border-color: var(--primary); color: var(--primary); }
.topbar-bell .dot {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  border-radius: 99px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--surface);
}

/* ---------- Sidebar sign-out ---------- */
.sidebar-account { padding: 10px; border-top: 1px solid rgba(255, 255, 255, 0.08); margin-top: auto; }
.sidebar-account a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: 8px;
  color: var(--sidebar-text);
  font-size: 13.5px;
}
.sidebar-account a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.sidebar-account a.signout:hover { background: rgba(214, 69, 69, 0.18); color: #ffb4b4; }
.sidebar .sidebar-account + .sidebar-footer { margin-top: 0; }

/* ---------- Breadcrumbs ---------- */
.crumbs { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-bottom: 12px; }
.crumbs a { color: var(--muted); font-weight: 600; }
.crumbs a:hover { color: var(--primary); }
.crumbs .sep { opacity: 0.5; }
.crumbs .here { color: var(--text); font-weight: 700; }

/* ---------- Detail header ---------- */
.detail-head {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.detail-head .avatar-lg {
  width: 62px;
  height: 62px;
  border-radius: 16px;
  background: linear-gradient(150deg, var(--primary), var(--primary-dark));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 800;
  flex-shrink: 0;
}
.detail-head .avatar-lg.blue { background: linear-gradient(150deg, #5fa4ee, var(--info)); }
.detail-head .avatar-lg.amber { background: linear-gradient(150deg, var(--accent), #b8791a); }
.detail-head .avatar-lg.slate { background: linear-gradient(150deg, #64748b, #334155); }
.detail-head .dh-main { flex: 1; min-width: 220px; }
.detail-head h1 { font-size: 21px; font-weight: 800; }
.detail-head .dh-sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.detail-head .dh-tags { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.detail-head .dh-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- Meta grid (label / value pairs) ---------- */
.meta-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px 24px; }
.meta-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.meta-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.meta-item .meta-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); font-weight: 700; }
.meta-item .meta-value { font-size: 14px; font-weight: 600; margin-top: 4px; word-break: break-word; }
.meta-item .meta-value.big { font-size: 19px; font-weight: 800; }
.meta-item .meta-value.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

/* ---------- Vertical trail (approval / chain of custody) ---------- */
.trail { position: relative; padding-left: 30px; }
.trail::before { content: ""; position: absolute; left: 11px; top: 10px; bottom: 10px; width: 2px; background: var(--border); }
.trail .tr-item { position: relative; padding: 0 0 22px 4px; }
.trail .tr-item:last-child { padding-bottom: 0; }
.trail .tr-item::before {
  content: "";
  position: absolute;
  left: -30px;
  top: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #eef1f5;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 2px var(--border);
}
.trail .tr-item::after {
  position: absolute;
  left: -30px;
  top: 2px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  content: attr(data-step);
}
.trail .tr-item.done::before { background: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.trail .tr-item.done::after { content: "\2713"; color: #fff; }
.trail .tr-item.current::before { background: var(--accent); box-shadow: 0 0 0 3px var(--warning-soft); }
.trail .tr-item.current::after { color: #fff; }
.trail .tr-item.rejected::before { background: var(--danger); box-shadow: 0 0 0 2px var(--danger-soft); }
.trail .tr-item.rejected::after { content: "\00d7"; color: #fff; font-size: 15px; }
.trail .tr-title { font-weight: 700; font-size: 13.5px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.trail .tr-who { font-size: 12.5px; color: var(--text-soft); margin-top: 2px; }
.trail .tr-time { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.trail .tr-note {
  margin-top: 8px;
  padding: 9px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--text-soft);
}

/* ---------- Progress bars ---------- */
.bar-track { height: 8px; border-radius: 99px; background: #eef1f5; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; background: var(--primary); }
.bar-fill.amber { background: var(--accent); }
.bar-fill.red { background: var(--danger); }
.bar-fill.blue { background: var(--info); }
.bar-row { display: flex; flex-direction: column; gap: 7px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.bar-row:last-child { border-bottom: none; }
.bar-row .bar-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; }
.bar-row .bar-top strong { font-weight: 700; }

/* ---------- Fund / balance cards ---------- */
.fund {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  background: linear-gradient(140deg, #ffffff, #f8fbfa);
}
.fund.social { background: linear-gradient(140deg, #ffffff, #f7faff); }
.fund .fund-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); font-weight: 700; }
.fund .fund-value { font-size: 24px; font-weight: 800; margin-top: 6px; }
.fund .fund-foot { font-size: 12px; color: var(--muted); margin-top: 5px; }

/* ---------- Table tools (search + filters) ---------- */
.table-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: #fbfcfe;
}
.table-tools .tt-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  min-width: 220px;
  flex: 1;
  color: var(--muted);
}
.table-tools .tt-search input { border: none; outline: none; background: transparent; font-size: 13px; width: 100%; font-family: var(--font); }
.table-tools select {
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: var(--font);
  background: var(--surface);
  color: var(--text-soft);
  outline: none;
}

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 20px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.pagination .pages { display: flex; gap: 5px; }
.pagination .pages a {
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--text-soft);
}
.pagination .pages a:hover { border-color: var(--primary); color: var(--primary); }
.pagination .pages a.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- Chips ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-soft);
}
.chip.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); }
.chip.off { color: var(--muted); }
.chip .x { color: var(--muted); font-weight: 700; }
.chip-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 44px 20px; }
.empty .empty-ic { font-size: 30px; opacity: 0.55; }
.empty h4 { font-size: 15px; font-weight: 700; margin-top: 10px; }
.empty p { font-size: 13px; color: var(--muted); margin-top: 5px; }

/* ---------- Permission group rows ---------- */
tr.group-row td {
  background: #f3f6fa;
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-soft);
  padding: 9px 16px;
}
.perm-name { font-weight: 600; }
.perm-key { font-size: 11.5px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---------- Two-column detail layout ---------- */
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.split.even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 18px; }

/* ---------- Sticky action bar ---------- */
.action-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 20px;
  margin-top: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.action-bar .ab-note { margin-right: auto; font-size: 12.5px; color: var(--muted); }

/* ---------- Auth extras ---------- */
.login-card.wide { max-width: 470px; }
.auth-steps { display: flex; align-items: center; gap: 6px; justify-content: center; margin-bottom: 18px; }
.auth-steps .dot { width: 26px; height: 5px; border-radius: 99px; background: var(--border); }
.auth-steps .dot.on { background: var(--primary); }
.auth-back { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 14px; }
.auth-back:hover { color: var(--primary); }
.otp-inputs { display: flex; gap: 10px; justify-content: space-between; }
.otp-inputs input {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  padding: 12px 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: var(--font);
  color: var(--text);
  outline: none;
  background: var(--surface);
}
.otp-inputs input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15, 157, 106, 0.12); }
.strength { display: flex; gap: 5px; margin-top: 8px; }
.strength span { height: 4px; flex: 1; border-radius: 99px; background: var(--border); }
.strength span.on { background: var(--primary); }
.strength span.mid { background: var(--accent); }
.rule-list { list-style: none; margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.rule-list li { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.rule-list li.ok { color: var(--primary-dark); }
.rule-list li::before { content: "\25cb"; font-size: 11px; }
.rule-list li.ok::before { content: "\2713"; font-weight: 800; }

/* ---------- Access denied ---------- */
.denied-wrap { max-width: 620px; margin: 6vh auto; text-align: center; }
.denied-ic {
  width: 78px;
  height: 78px;
  margin: 0 auto 18px;
  border-radius: 22px;
  background: var(--danger-soft);
  color: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
}
.denied-wrap h1 { font-size: 24px; font-weight: 800; }
.denied-wrap p { color: var(--muted); margin-top: 8px; }

/* ---------- Notifications ---------- */
.notif {
  display: flex;
  gap: 14px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.notif:last-child { border-bottom: none; }
.notif.unread { background: #f6fbf9; }
.notif .n-ic {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.notif .n-ic.amber { background: var(--warning-soft); color: var(--warning); }
.notif .n-ic.red { background: var(--danger-soft); color: var(--danger); }
.notif .n-ic.blue { background: var(--info-soft); color: var(--info); }
.notif .n-title { font-weight: 600; font-size: 13.5px; }
.notif .n-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.notif .n-time { font-size: 11.5px; color: var(--muted); margin-left: auto; white-space: nowrap; flex-shrink: 0; }

/* ---------- Payslip ---------- */
.payslip { max-width: 780px; margin: 0 auto; }
.payslip-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; flex-wrap: wrap; padding-bottom: 18px; border-bottom: 2px solid var(--text); }
.payslip table td { padding: 9px 0; }
.payslip .total-row td { font-weight: 800; border-top: 2px solid var(--text); border-bottom: none; font-size: 15px; }

/* ---------- New-component responsiveness ---------- */
@media (max-width: 1100px) {
  .split { grid-template-columns: 1fr; }
  .meta-grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .meta-grid, .meta-grid.cols-2, .meta-grid.cols-4 { grid-template-columns: 1fr; }
  .split.even { grid-template-columns: 1fr; }
  .otp-inputs { gap: 6px; }
  .otp-inputs input { font-size: 18px; padding: 10px 2px; }
  .detail-head { padding: 16px; }
}

/* ---------- Print ---------- */
@media print {
  .sidebar, .topbar, .page-actions, .action-bar, .crumbs, .no-print { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; border-color: #ccc; }
}

/* ---------------------------------------------------------------------------
   Searchable select (public/js/combo.js)

   The native <select> stays in the DOM and stays the form control; it is simply
   moved off-screen rather than removed, so the page keeps working when the
   script does not load.
   --------------------------------------------------------------------------- */
.combo { position: relative; }
.combo-native { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.combo-input { width: 100%; }
/*
   FIXED, not absolute. The modal dialog is a scroll container
   (max-height: 90vh; overflow-y: auto), and an absolutely-positioned child of it
   gets clipped at its edge — the list appeared, and was cut off by the modal.
   Fixed positioning takes the list out of every ancestor's overflow; combo.js
   sets top/left/width from the input's bounding rect and keeps them in step on
   scroll and resize.
 */
.combo-list {
  position: fixed; z-index: 100000;
  margin: 0; padding: 4px; list-style: none; max-height: 260px; overflow-y: auto;
  background: var(--surface, #fff); border: 1px solid var(--border, #d9e2e8);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(11, 29, 40, 0.18);
}
.combo-item { padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 14px; line-height: 1.35; }
.combo-item:hover, .combo-item.is-active { background: var(--surface-alt, #eef4f7); }
.combo-item.is-chosen { font-weight: 600; }
.combo-empty { padding: 8px 10px; font-size: 13px; color: var(--muted, #6b7c86); }

@media (max-width: 640px) { .combo-list { max-height: 200px; } }

/* ---------------------------------------------------------------------------
   Bulk revalidation — the select-many bar and its checkbox column.
   The bar is hidden until something is ticked, so the queue reads exactly as it
   did before for anyone only ever accepting one row at a time.
--------------------------------------------------------------------------- */
.bulk-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 14px; margin-bottom: 12px;
  background: var(--primary-soft); border: 1px solid #c6ebdb; border-radius: 8px;
  font-size: 13px; font-weight: 600; color: var(--primary-dark);
}
.bulk-bar input[type="text"] {
  flex: 1 1 260px; min-width: 0;
  padding: 7px 10px; border: 1px solid #c6ebdb; border-radius: 6px;
  font-size: 13px; font-weight: 400; background: #fff;
}
.bulk-bar[hidden] { display: none; }

.col-check { width: 34px; text-align: center; }
.col-check input[type="checkbox"] { width: auto; margin: 0; cursor: pointer; }

/* A multi-select needs room to be usable as a cohort picker. */
.field select[multiple] { height: auto; padding: 6px; }
