:root {
  --background: #eef1f5;
  --shell: #f8f9fb;
  --card: #ffffff;
  --card-hover: #fbfcfe;
  --foreground: #0b1f44;
  --heading: #071a3a;
  --muted: #667085;
  --muted-foreground: #8a94a6;
  --border: #e3e8ef;
  --border-strong: #d4dce8;
  --brand-navy: #102a56;
  --brand-navy-soft: rgba(16, 42, 86, 0.08);
  --brand-crimson: #cf1735;
  --brand-crimson-hover: #b8122d;
  --brand-crimson-soft: rgba(207, 23, 53, 0.08);
  --success: #16a34a;
  --success-soft: rgba(22, 163, 74, 0.10);
  --warning: #d97706;
  --warning-soft: rgba(217, 119, 6, 0.10);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.10);
  --info: #2563eb;
  --shadow-card: 0 8px 24px rgba(16, 42, 86, 0.045);
  --shadow-shell: 0 20px 60px rgba(16, 42, 86, 0.10);
  --radius-card: 14px;
  --radius-control: 10px;
  --rail-width: 72px;
  --topbar-height: 70px;
  --grid-gap: 14px;
  --ease-spring: cubic-bezier(0.34, 1.45, 0.64, 1);
  --ease-snappy: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html { font-size: 14px; }

body {  font-family: Inter, system-ui, -apple-system, sans-serif;  background: var(--background);  color: var(--foreground);  line-height: 1.5;  min-height: 100vh;}

a { color: var(--brand-crimson); text-decoration: none; }
a:hover { color: var(--brand-crimson-hover); }

.tabular { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.92em; }

.app-page {
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
  padding: 20px;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.app-shell {
  width: min(1440px, calc(100vw - 40px));
  height: calc(100vh - 40px);
  min-height: calc(100vh - 40px);
  max-height: calc(100vh - 40px);
  background: var(--shell);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  box-shadow: var(--shadow-shell);
  display: grid;
  grid-template-columns: var(--rail-width) 1fr;
  overflow: hidden;
  align-items: stretch;
  animation: pageIn 180ms ease-out;
  position: relative;
}

@keyframes pageIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .app-shell, .modal-overlay, .modal,
  .micro-reveal, .flash-msg, .toast, .badge { animation: none !important; transition: none !important; }
}

.icon-rail {
  width: var(--rail-width);
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0;
  gap: 8px;
  position: sticky;
  top: 0;
  height: 100%;
  max-height: calc(100vh - 40px);
  min-height: 0;
  align-self: start;
  overflow: visible;
  border-radius: 17px 0 0 17px;
  z-index: 100;
}

.rail-logo {
  width: 40px;
  height: 40px;
  background: var(--brand-navy);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 10px;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.rail-nav { display: flex; flex-direction: column; gap: 6px; flex: 1; min-height: 0; width: 100%; align-items: center; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.rail-sep { width: 32px; height: 1px; background: var(--border); margin: 4px 0; }
.rail-bottom { display: flex; flex-direction: column; gap: 6px; align-items: center; flex-shrink: 0; }

.rail-link {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: var(--radius-control);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-navy);
  border: 1px solid transparent;
  transition: 120ms ease;
  position: relative;
}
.rail-link:hover { background: var(--brand-navy-soft); }
.rail-link.active {
  color: var(--brand-crimson);
  border-color: var(--brand-crimson);
  background: var(--brand-crimson-soft);
}
.rail-link svg { width: 17px; height: 17px; stroke-width: 1.75; }

.rail-link[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--heading);
  color: #fff;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  white-space: nowrap;
  z-index: 100;
  pointer-events: none;
}

.shell-main {
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  border-radius: 0 17px 17px 0;
}

.topbar {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.topbar-left { display: flex; align-items: center; gap: 24px; }
.wordmark { font-weight: 700; font-size: 16px; color: var(--heading); letter-spacing: -0.02em; }
.topbar-tabs { display: flex; gap: 20px; }
.topbar-tab {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  padding-bottom: 4px;
  border-bottom: 2px solid transparent;
}
.topbar-tab.active { color: var(--brand-crimson); border-bottom-color: var(--brand-crimson); }

.topbar-right { display: flex; align-items: center; gap: 10px; }
.updated-pill {
  font-size: 11px;
  color: var(--muted);
  background: var(--shell);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-navy);
  cursor: pointer;
  transition: 120ms ease;
}
.icon-btn:hover { border-color: var(--border-strong); background: var(--card-hover); }
.icon-btn svg { width: 18px; height: 18px; }

.main-content {
  padding: 14px 18px 18px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  overscroll-behavior: contain;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 20px;
  transition: 120ms ease;
}
.card:hover { border-color: var(--border-strong); }
.card-title { font-size: 14px; font-weight: 600; color: var(--heading); margin-bottom: 4px; }
.card-sub { font-size: 12px; color: var(--muted-foreground); }

.kpi-value { font-size: 32px; font-weight: 700; color: var(--heading); line-height: 1.1; }
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 500; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-control);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--foreground);
  cursor: pointer;
  transition: 140ms ease;
}
.btn:hover { background: var(--card-hover); }
.btn-primary { background: var(--brand-crimson); border-color: var(--brand-crimson); color: #fff; }
.btn-primary:hover { background: var(--brand-crimson-hover); border-color: var(--brand-crimson-hover); }

.badge {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: rgba(37,99,235,0.1); color: var(--info); }
.badge-muted { background: rgba(102,112,133,0.12); color: var(--muted); }
.badge-partial { background: rgba(217,119,6,0.12); color: #b45309; }

.progress-bar { height: 6px; background: var(--border); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--brand-crimson); border-radius: 999px; }
.progress-fill-navy { background: var(--brand-navy); }

.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.data-table td { padding: 12px; border-bottom: 1px solid var(--border); }
.data-table tr:hover td { background: var(--card-hover); }

.page-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 4px; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  font-size: 13px;
  background: var(--card);
  color: var(--foreground);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--brand-crimson);
  box-shadow: 0 0 0 3px var(--brand-crimson-soft);
}

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(7, 26, 58, 0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  animation: fadeIn 160ms ease;
}
.modal {
  background: var(--card);
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-shell);
  width: min(520px, calc(100vw - 32px));
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  animation: modalIn 180ms ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: scale(0.985); } to { opacity: 1; transform: scale(1); } }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-title { font-size: 16px; font-weight: 600; color: var(--heading); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab.active { color: var(--brand-crimson); border-bottom-color: var(--brand-crimson); }

.toast-container { position: fixed; top: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 16px;
  border-radius: var(--radius-control);
  background: var(--heading);
  color: #fff;
  font-size: 13px;
  box-shadow: var(--shadow-card);
}
.toast-error { background: var(--danger); }
.toast-success { background: var(--success); }

.flash-msg { padding: 10px 14px; border-radius: var(--radius-control); margin-bottom: 14px; font-size: 13px; }
.flash-success { background: var(--success-soft); color: var(--success); border: 1px solid rgba(22,163,74,0.2); }
.flash-error { background: var(--danger-soft); color: var(--danger); border: 1px solid rgba(220,38,38,0.2); }

.pagination { display: flex; gap: 6px; margin-top: 14px; justify-content: center; }
.pagination a, .pagination span {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  color: var(--muted);
}
.pagination a.active, .pagination a:hover { border-color: var(--brand-crimson); color: var(--brand-crimson); }

.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--brand-navy);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}

.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute; right: 0; top: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  box-shadow: var(--shadow-card);
  min-width: 160px;
  z-index: 50;
  display: none;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-item { display: block; padding: 8px 12px; font-size: 13px; color: var(--foreground); }
.dropdown-item:hover { background: var(--card-hover); }

.search-dialog {
  position: fixed; inset: 0; z-index: 1500;
  background: rgba(7,26,58,0.5);
  display: none; align-items: stretch; justify-content: center;
  padding-top: 15vh;
}
.search-dialog.open { display: flex; }
.search-box {
  width: min(560px, 90vw);
  background: var(--card);
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-shell);
  overflow: hidden;
}
.search-box input {
  width: 100%; padding: 16px 20px; border: none; font-size: 15px;
  border-bottom: 1px solid var(--border);
}
.search-results { max-height: 320px; overflow-y: auto; }
.search-result { display: block; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.search-result:hover { background: var(--card-hover); }

.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }

.mobile-menu-btn { display: none; }
.nav-backdrop { display: none; }
