:root {
  --navy: #0b1727;
  --navy-2: #10233b;
  --panel: #16283f;
  --line: #24405e;
  --sky: #38bdf8;
  --sky-2: #0ea5e9;
  --amber: #f59e0b;
  --green: #22c55e;
  --red: #ef4444;
  --slate: #94a3b8;
  --text: #e8eef7;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(56, 189, 248, 0.12), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(245, 158, 11, 0.08), transparent 60%),
    var(--navy);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #0d1a2b; }
::-webkit-scrollbar-thumb { background: #24405e; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #35597f; }

.font-mono-num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

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

.sidebar {
  width: 250px;
  flex: 0 0 250px;
  background: linear-gradient(180deg, var(--navy-2), #0a1626);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}
.brand-badge {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--sky), #1d4ed8);
  display: grid; place-items: center; font-size: 19px;
  box-shadow: 0 6px 18px rgba(14,165,233,.35);
}
.brand-title { font-weight: 700; font-size: 15px; letter-spacing: .2px; line-height: 1.1; }
.brand-sub { font-size: 10.5px; color: var(--slate); letter-spacing: .6px; text-transform: uppercase; }

.nav { padding: 12px 10px; overflow-y: auto; flex: 1; }
.nav-group-label { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: #5c7796; padding: 12px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: 9px; margin: 2px 0;
  color: #b9c8db; cursor: pointer; font-size: 13.5px; font-weight: 500;
  border: 1px solid transparent; transition: all .14s ease;
}
.nav-item i { width: 18px; text-align: center; font-size: 14px; }
.nav-item:hover { background: rgba(56,189,248,.08); color: #fff; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(56,189,248,.18), rgba(56,189,248,.04));
  color: #fff; border-color: rgba(56,189,248,.35);
}
.nav-item.active i { color: var(--sky); }

.sidebar-foot { padding: 12px; border-top: 1px solid var(--line); }

.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 22px; border-bottom: 1px solid var(--line);
  background: rgba(11,23,39,.75); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 30;
}
.page-title { font-size: 17px; font-weight: 700; }
.page-sub { font-size: 12px; color: var(--slate); }
.content { padding: 20px 22px 60px; }

/* ---------- Cards ---------- */
.card {
  background: linear-gradient(180deg, rgba(22,40,63,.9), rgba(15,28,45,.9));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
}
.card-title { font-size: 13px; font-weight: 700; letter-spacing: .3px; display:flex; align-items:center; gap:8px; }
.card-title i { color: var(--sky); }

.stat-card {
  position: relative; overflow: hidden;
  background: linear-gradient(160deg, rgba(24,44,70,.95), rgba(13,25,41,.95));
  border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px;
}
.stat-card::after {
  content: ''; position: absolute; right: -20px; top: -20px;
  width: 80px; height: 80px; border-radius: 50%;
  background: radial-gradient(circle, rgba(56,189,248,.20), transparent 70%);
}
.stat-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--slate); font-weight: 600; }
.stat-value { font-size: 27px; font-weight: 800; line-height: 1.05; margin-top: 4px; }
.stat-unit { font-size: 12px; color: var(--slate); font-weight: 600; margin-left: 3px; }
.stat-sub { font-size: 11px; color: var(--slate); margin-top: 3px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  padding: 8px 14px; border-radius: 9px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--line); background: #16283f; color: var(--text);
  cursor: pointer; transition: all .14s ease; white-space: nowrap;
}
.btn:hover { background: #1d3452; border-color: #35597f; }
.btn-primary { background: linear-gradient(135deg, var(--sky-2), #2563eb); border-color: transparent; color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-danger { background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.4); color: #fca5a5; }
.btn-danger:hover { background: rgba(239,68,68,.22); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.icon-btn {
  width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 9px; border: 1px solid var(--line); background: #16283f;
  color: #c3d2e4; cursor: pointer; transition: all .14s;
}
.icon-btn:hover { background: #1d3452; color: #fff; }

/* ---------- Forms ---------- */
.field-label { display: block; font-size: 11.5px; font-weight: 600; color: #a9bcd2; margin-bottom: 4px; }
.input, .select, .textarea {
  width: 100%; padding: 8px 11px; border-radius: 9px; font-size: 13px;
  background: #0e1e33; border: 1px solid var(--line); color: var(--text);
  transition: border-color .14s, box-shadow .14s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--sky); box-shadow: 0 0 0 3px rgba(56,189,248,.14);
}
.input::placeholder, .textarea::placeholder { color: #5c7796; }
.textarea { resize: vertical; min-height: 70px; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; padding-right: 30px; }

/* ---------- Table ---------- */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table.logbook { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
table.logbook thead th {
  position: sticky; top: 0; z-index: 5;
  background: #12233a; color: #9fb4cc; text-align: left; font-weight: 600;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px;
  padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.logbook tbody td { padding: 8px 10px; border-bottom: 1px solid rgba(36,64,94,.55); white-space: nowrap; }
table.logbook tbody tr:hover { background: rgba(56,189,248,.06); }
table.logbook tbody tr:last-child td { border-bottom: 0; }
table.logbook td.num, table.logbook th.num { text-align: right; font-variant-numeric: tabular-nums; }
.reg-chip {
  display: inline-block; padding: 2px 7px; border-radius: 6px; font-weight: 700; font-size: 11.5px;
  background: rgba(56,189,248,.14); color: #7dd3fc; border: 1px solid rgba(56,189,248,.3); letter-spacing: .5px;
}

/* ---------- Badges ---------- */
.badge { display:inline-flex; align-items:center; gap:5px; padding: 3px 9px; border-radius: 999px; font-size: 10.5px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; }
.badge-current { background: rgba(34,197,94,.16); color: #4ade80; border: 1px solid rgba(34,197,94,.4); }
.badge-soon { background: rgba(245,158,11,.16); color: #fbbf24; border: 1px solid rgba(245,158,11,.4); }
.badge-expired { background: rgba(239,68,68,.16); color: #f87171; border: 1px solid rgba(239,68,68,.4); }
.badge-none { background: rgba(148,163,184,.14); color: #a9bcd2; border: 1px solid rgba(148,163,184,.35); }
.badge-role { background: rgba(56,189,248,.12); color: #7dd3fc; border: 1px solid rgba(56,189,248,.28); text-transform: none; letter-spacing: 0; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(4,10,18,.72); backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center; padding: 30px 16px; z-index: 100; overflow-y: auto;
}
.modal {
  width: 100%; max-width: 920px; background: #0f1f34; border: 1px solid var(--line);
  border-radius: 16px; box-shadow: 0 30px 70px rgba(0,0,0,.6); animation: pop .16s ease;
}
.modal.wide { max-width: 1080px; }
.modal.slim { max-width: 560px; }
@keyframes pop { from { transform: translateY(8px) scale(.99); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display:flex; align-items:center; justify-content:space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); position: sticky; top:0; background:#0f1f34; border-radius: 16px 16px 0 0; z-index: 2;}
.modal-body { padding: 18px; }
.modal-foot { display:flex; gap:10px; justify-content:flex-end; padding: 14px 18px; border-top: 1px solid var(--line); position: sticky; bottom:0; background:#0f1f34; border-radius: 0 0 16px 16px; }

/* ---------- Tabs ---------- */
.tabs { display:flex; gap:4px; border-bottom:1px solid var(--line); overflow-x:auto; }
.tab { padding: 8px 13px; font-size: 12.5px; font-weight: 600; color: var(--slate); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab:hover { color: #fff; }
.tab.active { color: var(--sky); border-bottom-color: var(--sky); }

/* ---------- Misc ---------- */
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--sky); font-weight: 700; margin: 4px 0 10px; display:flex; align-items:center; gap:8px;}
.helper { font-size: 11px; color: var(--slate); }
.divider { height:1px; background: var(--line); margin: 14px 0; }
.empty { text-align:center; padding: 46px 20px; color: var(--slate); }
.empty i { font-size: 34px; opacity:.5; display:block; margin-bottom: 12px; }
.toast-wrap { position: fixed; right: 18px; bottom: 18px; z-index: 200; display:flex; flex-direction:column; gap:9px; }
.toast { padding: 11px 15px; border-radius: 10px; font-size: 13px; font-weight: 600; box-shadow: 0 12px 30px rgba(0,0,0,.45); animation: pop .16s ease; max-width: 340px; }
.toast-ok { background: #14532d; border:1px solid #22c55e; color:#bbf7d0; }
.toast-err { background: #4c1d1d; border:1px solid #ef4444; color:#fecaca; }
.toast-info { background: #0c2f47; border:1px solid #38bdf8; color:#bae6fd; }

.spinner { width: 30px; height: 30px; border: 3px solid rgba(56,189,248,.25); border-top-color: var(--sky); border-radius: 50%; animation: spin .7s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.mobile-nav-toggle { display: none; }
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .22s ease; }
  .sidebar.open { transform: none; }
  .mobile-nav-toggle { display: grid; }
  .content { padding: 16px 14px 60px; }
}

/* Auth */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 430px; }
.hero-plane { font-size: 40px; }

/* Chart sizing */
.chart-box { position: relative; height: 260px; }
.chart-box.sm { height: 210px; }

/* Form grid */
.fgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.fgrid.fgrid3 { grid-template-columns: repeat(3, 1fr); }
.role-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px;
  border-radius: 9px; background: #0e1e33; border: 1px solid var(--line);
  font-size: 12.5px; cursor: pointer; user-select: none; transition: all .14s;
}
.role-chip:hover { border-color: #35597f; }
.role-chip input { accent-color: var(--sky); }
.role-chip:has(input:checked) { background: rgba(56,189,248,.14); border-color: rgba(56,189,248,.5); color: #fff; }

/* Dashboard responsive grids */
@media (max-width: 1100px) {
  .dash-grid, .dash-grid3 { grid-template-columns: 1fr !important; }
}
@media (max-width: 700px) {
  .fgrid, .fgrid.fgrid3 { grid-template-columns: 1fr; }
  .lb-filters { grid-template-columns: 1fr !important; }
  .stat-value { font-size: 22px; }
}

/* Print */
@media print {
  .sidebar, .topbar, .btn, .icon-btn, .toast-wrap { display: none !important; }
  body { background: #fff; color: #000; }
  .card { border: 1px solid #ccc; background: #fff; }
}
