:root {
  color-scheme: light;
  --ink: #122034;
  --muted: #5c6b82;
  --line: #dbe4ef;
  --panel: #ffffff;
  --canvas: #f4f7fb;
  --nav: #102542;
  --nav-2: #154c5c;
  --blue: #2563eb;
  --teal: #0f766e;
  --green: #12805c;
  --amber: #b45309;
  --red: #b42318;
  --soft-blue: #eff6ff;
  --soft-green: #ecfdf3;
  --soft-amber: #fffbeb;
  --shadow: 0 12px 28px rgba(18, 32, 52, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-size: 14px;
  letter-spacing: 0;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--blue); text-decoration: none; }

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    linear-gradient(130deg, rgba(16,37,66,0.94), rgba(15,118,110,0.86)),
    url('/static/amanah-pattern.svg');
  background-size: cover, 380px 380px;
}
.login-shell { width: min(94vw, 540px); }
.login-panel {
  background: #fff;
  border: 1px solid rgba(219, 228, 239, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}
.brand-lockup { display: flex; align-items: center; gap: 14px; }
.brand-mark, .boot-mark { width: 48px; height: 48px; }
.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}
.login-panel h1 { margin: 0; font-size: 24px; line-height: 1.15; }
.login-principle { color: var(--muted); line-height: 1.6; margin: 18px 0 22px; }
.login-error {
  border: 1px solid #fecaca;
  background: #fff1f2;
  color: var(--red);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
  font-weight: 700;
}
.stack { display: grid; gap: 14px; }
label { display: grid; gap: 7px; font-weight: 700; color: #26384f; }
input, select, textarea {
  width: 100%;
  border: 1px solid #cfd9e7;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
  min-height: 40px;
}
textarea { resize: vertical; min-height: 78px; }
input:focus, select:focus, textarea:focus {
  outline: 3px solid rgba(37, 99, 235, 0.15);
  border-color: var(--blue);
}
.primary-button, .secondary-button, .ghost-button, .danger-button {
  border-radius: 8px;
  border: 1px solid transparent;
  min-height: 40px;
  padding: 9px 14px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}
.primary-button { background: var(--blue); color: #fff; }
.secondary-button { background: #fff; color: var(--blue); border-color: var(--blue); }
.ghost-button { background: #fff; color: var(--ink); border-color: #aab7c8; }
.danger-button { background: var(--red); color: #fff; }
.primary-button:hover, .secondary-button:hover, .ghost-button:hover { transform: translateY(-1px); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 280px minmax(0, 1fr); }
.side-nav {
  background: linear-gradient(180deg, var(--nav), var(--nav-2));
  color: #fff;
  min-height: 100vh;
  position: sticky;
  top: 0;
  align-self: start;
  padding: 20px 14px;
}
.nav-brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 18px; }
.nav-brand img { width: 42px; height: 42px; }
.nav-brand strong { display: block; font-size: 16px; line-height: 1.15; }
.nav-brand span { display: block; color: #b9d8df; font-size: 12px; margin-top: 3px; }
.nav-list { display: grid; gap: 4px; }
.nav-item {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 10px 10px;
  color: #dceaf1;
  background: transparent;
  text-align: left;
  font-weight: 750;
  min-height: 38px;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: #fff; color: #102542; }
.main {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}
.topbar {
  min-height: 74px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 26px;
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar h1 { margin: 0; font-size: 22px; line-height: 1.2; }
.topbar p { margin: 4px 0 0; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.user-pill {
  border: 1px solid var(--line);
  background: #f8fafc;
  border-radius: 8px;
  padding: 8px 10px;
  font-weight: 800;
}
.content { padding: 24px 26px 42px; min-width: 0; }
.boot-screen { min-height: 100vh; display: grid; place-items: center; gap: 14px; color: var(--muted); }

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.auto { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.panel, .card, .kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(18, 32, 52, 0.04);
}
.panel { padding: 16px; }
.card { padding: 14px; }
.kpi { padding: 16px; min-height: 112px; display: grid; align-content: space-between; }
.kpi span, .small-label {
  display: block;
  color: #61708a;
  text-transform: uppercase;
  font-size: 11px;
  line-height: 1.25;
  font-weight: 900;
  letter-spacing: 0.06em;
}
.kpi strong { display: block; margin-top: 8px; font-size: 24px; line-height: 1.12; }
.kpi small { color: var(--muted); font-weight: 700; }
.section-title { display: flex; justify-content: space-between; gap: 12px; align-items: end; margin-bottom: 12px; }
.section-title h2 { margin: 0; font-size: 18px; }
.section-title p { margin: 4px 0 0; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: end; }
.form-grid .wide { grid-column: span 2; }
.form-grid .full { grid-column: 1 / -1; }
.inline-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.progress {
  height: 10px;
  background: #e8eef6;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid #d7e0ed;
}
.progress > span { display: block; height: 100%; width: var(--value, 0%); background: linear-gradient(90deg, var(--teal), var(--blue)); }
.progress.warn > span { background: linear-gradient(90deg, var(--amber), #f59e0b); }
.progress.danger > span { background: linear-gradient(90deg, var(--red), #ef4444); }
.metric-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-top: 8px; color: var(--muted); font-weight: 750; }
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 4px 9px;
  background: #edf2f7;
  color: #334155;
  font-size: 12px;
  font-weight: 900;
}
.badge.success { background: var(--soft-green); color: var(--green); }
.badge.warn { background: var(--soft-amber); color: var(--amber); }
.badge.danger { background: #fff1f2; color: var(--red); }
.badge.info { background: var(--soft-blue); color: var(--blue); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: #586a83; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; background: #f8fafc; }
td strong { display: block; }
tr:last-child td { border-bottom: 0; }
.empty { color: var(--muted); padding: 18px; border: 1px dashed #b8c4d4; border-radius: 8px; background: #fff; }
.notice { border: 1px solid #b7e4d5; background: #f0fdfa; color: #134e4a; border-radius: 8px; padding: 12px 14px; line-height: 1.55; font-weight: 700; }
.notice.warn { border-color: #fde68a; background: #fffbeb; color: #7c2d12; }
.notice.danger { border-color: #fecaca; background: #fff1f2; color: #7f1d1d; }

.module-view { display: grid; gap: 18px; }
.card h3, .panel h3 { margin: 0 0 10px; font-size: 15px; }
.card p { color: var(--muted); margin: 5px 0; line-height: 1.45; }
.amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
.split-line { display: flex; justify-content: space-between; gap: 12px; margin: 8px 0; }
.quick-spend {
  border-left: 4px solid var(--teal);
}
.category-card { min-height: 154px; display: grid; gap: 10px; }
.category-card h3 { margin: 0; }
.category-card .amount { font-weight: 900; }
.alert-list { display: grid; gap: 10px; }
.alert-item { border-left: 4px solid var(--blue); }
.alert-item.warning { border-left-color: var(--amber); }
.alert-item.danger { border-left-color: var(--red); }
.alert-item.success { border-left-color: var(--green); }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 1fr; }
  .side-nav { position: relative; min-height: auto; }
  .nav-list { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
  .topbar { position: relative; }
  .grid.four, .grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .content, .topbar { padding-left: 14px; padding-right: 14px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .grid.two, .grid.three, .grid.four { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide, .form-grid .full { grid-column: auto; }
  .nav-list { grid-template-columns: 1fr; }
  .kpi strong { font-size: 21px; }
}
