/* Maalsoor — acacia green on dry-season sand; season colours carry through the dashboard. */
:root, [data-bs-theme="light"] {
  --ms-bg: #f2f3ec; --ms-surface: #ffffff; --ms-surface-2: #e9ebe1; --ms-ink: #1c231e; --ms-muted: #5a655c; --ms-line: #d5dacd;
  --ms-accent: #24573c; --ms-accent-hover: #1c4630; --ms-accent-ink: #ffffff; --ms-accent-soft: #dcebe0; --ms-sand: #a8721a;
  --ms-green: #236a40; --ms-green-bg: #dff0e4; --ms-gold: #875400; --ms-gold-bg: #faecce; --ms-red: #ad231a; --ms-red-bg: #f9dfdb;
  --ms-blue: #1c5891; --ms-blue-bg: #dce8f5; --ms-slate: #545e57; --ms-slate-bg: #e6e9e2; --ms-sand-bg: #f3e6cc;
  --s-jilaal: #d39b35; --s-gu: #3f8d5d; --s-xagaa: #bd6f34; --s-dayr: #5c93bd;
  --ms-f-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --ms-f-body: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --ms-f-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --bs-body-bg: var(--ms-bg); --bs-body-color: var(--ms-ink); --bs-border-color: var(--ms-line);
  --bs-secondary-color: var(--ms-muted); --bs-body-font-family: var(--ms-f-body); --bs-body-font-size: .9375rem;
  --bs-link-color: var(--ms-accent); --bs-link-hover-color: var(--ms-accent-hover); --bs-link-color-rgb: 36, 87, 60;
  --bs-primary: var(--ms-accent); --bs-primary-rgb: 36, 87, 60; --bs-focus-ring-color: rgba(36, 87, 60, .3);
  --bs-tertiary-bg: var(--ms-surface-2);
}
[data-bs-theme="dark"] {
  --ms-bg: #101410; --ms-surface: #171c18; --ms-surface-2: #202721; --ms-ink: #e5eae2; --ms-muted: #9aa69c; --ms-line: #2d362f;
  --ms-accent: #6fbf8e; --ms-accent-hover: #86cfa2; --ms-accent-ink: #0b1a11; --ms-accent-soft: #1b3325; --ms-sand: #e0a94e;
  --ms-green: #86d4a1; --ms-green-bg: #1b3224; --ms-gold: #f0bb55; --ms-gold-bg: #392b10; --ms-red: #ff8b7f; --ms-red-bg: #3d1a17;
  --ms-blue: #8fbff0; --ms-blue-bg: #17293b; --ms-slate: #a6b0a8; --ms-slate-bg: #252c26; --ms-sand-bg: #33280f;
  --s-jilaal: #b4832c; --s-gu: #377a50; --s-xagaa: #a3602b; --s-dayr: #4e7fa4;
  --bs-link-color-rgb: 111, 191, 142; --bs-primary-rgb: 111, 191, 142; --bs-focus-ring-color: rgba(111, 191, 142, .35);
  color-scheme: dark;
}
html, body { height: 100%; }
body { background: var(--ms-bg); color: var(--ms-ink); font-family: var(--ms-f-body); -webkit-tap-highlight-color: transparent; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 2000; background: var(--ms-accent); color: var(--ms-accent-ink); padding: 8px 12px; border-radius: 8px; }
.skip-link:focus { left: 8px; }
h1, h2, h3, .h1, .h2, .h3 { color: inherit; font-family: var(--ms-f-display); letter-spacing: -.015em; text-wrap: balance; }
.num, .table td.num, .table th.num { font-family: var(--ms-f-mono); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.text-muted { color: var(--ms-muted) !important; }

/* ---- Buttons & forms ------------------------------------------------------- */
.btn { --bs-btn-border-radius: 8px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-weight: 500; }
.btn-sm { min-height: 32px; }
.btn.btn-primary, .btn-primary { background-image: none; --bs-btn-bg: var(--ms-accent); --bs-btn-border-color: var(--ms-accent); --bs-btn-color: var(--ms-accent-ink);
  --bs-btn-hover-bg: var(--ms-accent-hover); --bs-btn-hover-border-color: var(--ms-accent-hover); --bs-btn-hover-color: var(--ms-accent-ink);
  --bs-btn-active-bg: var(--ms-accent-hover); --bs-btn-active-border-color: var(--ms-accent-hover); --bs-btn-active-color: var(--ms-accent-ink);
  --bs-btn-disabled-bg: var(--ms-accent); --bs-btn-disabled-border-color: var(--ms-accent); --bs-btn-disabled-color: var(--ms-accent-ink); }
.btn.btn-light, .btn-light { background-image: none; --bs-btn-bg: var(--ms-surface); --bs-btn-border-color: var(--ms-line); --bs-btn-color: var(--ms-ink);
  --bs-btn-hover-bg: var(--ms-surface-2); --bs-btn-hover-border-color: var(--ms-line); --bs-btn-hover-color: var(--ms-ink);
  --bs-btn-active-bg: var(--ms-surface-2); --bs-btn-active-border-color: var(--ms-line); --bs-btn-active-color: var(--ms-ink); }
.btn-icon { width: 40px; padding: 0; color: var(--ms-ink); border: 1px solid transparent; }
.btn-icon:hover { background: var(--ms-surface-2); }
.lang-btn { font-family: var(--ms-f-mono); font-size: 13px; font-weight: 600; text-decoration: none; }
.form-control, .form-select { min-height: 44px; border-radius: 8px; background-color: var(--ms-surface); border-color: var(--ms-line); color: var(--ms-ink); }
.form-control:focus, .form-select:focus { border-color: var(--ms-accent); box-shadow: 0 0 0 .2rem var(--bs-focus-ring-color); }
.form-label { font-weight: 600; font-size: .875rem; margin-bottom: .3rem; }
.form-text { color: var(--ms-muted); }
.req { color: var(--ms-red); }
.form-check-input:checked { background-color: var(--ms-accent); border-color: var(--ms-accent); }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--ms-line); background: var(--ms-surface-2); color: var(--ms-ink); border-radius: 999px; padding: 3px 10px; font-size: .8rem; min-height: 30px; cursor: pointer; }
.chip:hover { border-color: var(--ms-accent); }
.alert { border-radius: 10px; }

/* ---- Shell ------------------------------------------------------------------- */
.app-shell { display: flex; min-height: 100%; }
.sidebar { width: 252px; flex: 0 0 252px; background: var(--ms-surface); border-right: 1px solid var(--ms-line); display: flex; flex-direction: column; }
@media (min-width: 992px) {
  .sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; visibility: visible !important; transform: none !important; }
}
@media (max-width: 991.98px) { .sidebar { --bs-offcanvas-width: 280px; background: var(--ms-surface); } }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 16px 10px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ms-ink); }
.brand b { display: block; font-family: var(--ms-f-display); font-size: 1.35rem; line-height: 1; color: var(--ms-accent); letter-spacing: -.02em; }
.brand small { display: block; color: var(--ms-muted); font-size: .75rem; margin-top: 2px; }
.sidebar-nav ul { list-style: none; margin: 0; padding: 0; }
.sidebar-nav { padding: 8px 10px; flex: 1; }
.sidebar-nav .nav-link { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 8px; color: var(--ms-ink); text-decoration: none; border: 0; background: none; text-align: left; font-size: .9rem; }
.sidebar-nav .nav-link:hover { background: var(--ms-surface-2); }
.sidebar-nav .nav-link .bi { font-size: 1.05rem; color: var(--ms-muted); }
.sidebar-nav .nav-link.active { background: var(--ms-accent-soft); color: var(--ms-accent); font-weight: 600; }
.sidebar-nav .nav-link.active .bi { color: var(--ms-accent); }
.sidebar-nav .caret { margin-left: auto; font-size: .75rem !important; transition: transform .15s; }
.sidebar-nav .nav-toggle[aria-expanded="true"] .caret { transform: rotate(180deg); }
.sidebar-nav .sub { padding-left: 30px !important; }
.sidebar-nav .sub .nav-link { padding: 7px 10px; font-size: .875rem; }
.sidebar-foot { padding: 12px 16px 18px; display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--ms-line); }
.season-chip { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--ms-muted); }
.season-chip .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--season, var(--s-dayr)); }
.btn-install { background: var(--ms-accent-soft); color: var(--ms-accent); border: 1px solid transparent; font-weight: 600; }
.btn-install:hover { background: var(--ms-accent); color: var(--ms-accent-ink); }
body.season-jilaal { --season: var(--s-jilaal); } body.season-gu { --season: var(--s-gu); }
body.season-xagaa { --season: var(--s-xagaa); } body.season-dayr { --season: var(--s-dayr); }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top, 0px)) 20px 8px; background: color-mix(in srgb, var(--ms-bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--ms-line); }
.topbar-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
@media (min-width: 992px) { .topbar-title { visibility: hidden; } }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.btn-user { display: flex; align-items: center; gap: 8px; border: 0; background: none; color: var(--ms-ink); padding: 4px 6px; }
.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; font-size: .75rem; font-weight: 600;
  background: hsl(var(--hue) 45% 85%); color: hsl(var(--hue) 50% 22%); }
[data-bs-theme="dark"] .avatar { background: hsl(var(--hue) 30% 28%); color: hsl(var(--hue) 60% 88%); }
.net-status { font-size: .8rem; color: var(--ms-gold); background: var(--ms-gold-bg); padding: 3px 10px; border-radius: 999px; }
.dropdown-menu { --bs-dropdown-bg: var(--ms-surface); --bs-dropdown-border-color: var(--ms-line); --bs-dropdown-link-color: var(--ms-ink); --bs-dropdown-link-hover-bg: var(--ms-surface-2); border-radius: 10px; }
.dropdown-item { display: flex; gap: 8px; align-items: center; min-height: 40px; }
.content { padding: 24px 28px 48px; max-width: 1280px; width: 100%; display: flex; flex-direction: column; gap: 20px; }
.foot { padding: 0 28px 24px; color: var(--ms-muted); font-size: .75rem; }
@media (max-width: 991.98px) {
  .content { padding: 16px 16px 96px; gap: 16px; }
  .foot { padding: 0 16px 90px; }
  .topbar { padding-left: 8px; padding-right: 12px; }
}

/* Bottom tab bar on phones */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--ms-surface); border-top: 1px solid var(--ms-line); padding-bottom: env(safe-area-inset-bottom, 0px); }
.tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 58px; color: var(--ms-muted); text-decoration: none; font-size: .7rem; border: 0; background: none; }
.tabbar .bi { font-size: 1.25rem; }
.tabbar a.active { color: var(--ms-accent); font-weight: 600; }

/* ---- Page parts -------------------------------------------------------------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.page-head h1 { font-size: 1.85rem; font-weight: 700; margin: 0; }
.page-sub { margin: 4px 0 0; color: var(--ms-muted); max-width: 65ch; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.crumbs { font-size: .8rem; color: var(--ms-muted); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 4px; }
.crumbs a { color: var(--ms-muted); text-decoration: none; }
.crumbs a:hover { color: var(--ms-accent); }
.crumbs .bi { font-size: .65rem; }
@media (max-width: 575.98px) { .page-head h1 { font-size: 1.5rem; } .page-actions { width: 100%; } .page-actions .btn { flex: 1 1 auto; } }

.panel { background: var(--ms-surface); border: 1px solid var(--ms-line); border-radius: 12px; min-width: 0; }
.panel-body { padding: 18px; }
.panel-head { padding: 14px 18px; border-bottom: 1px solid var(--ms-line); display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.panel-head h2, .section-title { font-size: 1.05rem; font-weight: 700; margin: 0; }
.panel-head a { font-size: .8rem; text-decoration: none; white-space: nowrap; }
.panel-foot { padding: 12px 18px; border-top: 1px solid var(--ms-line); background: var(--ms-surface-2); border-radius: 0 0 12px 12px; }
.panel-danger { border-color: var(--ms-red); }
.section-title { margin-bottom: 10px; }

.stat-strip { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); background: var(--ms-surface); border: 1px solid var(--ms-line); border-radius: 12px; overflow: hidden; }
.stat { display: flex; gap: 12px; padding: 14px 16px; border-left: 1px solid var(--ms-line); text-decoration: none; color: var(--ms-ink); min-width: 0; }
.stat:first-child { border-left: 0; }
a.stat:hover { background: var(--ms-surface-2); }
.stat-icon { width: 38px; height: 38px; flex: 0 0 38px; border-radius: 10px; display: grid; place-items: center; font-size: 1.1rem; }
.stat-body { display: flex; flex-direction: column; min-width: 0; }
.stat-value { font-family: var(--ms-f-display); font-size: 1.75rem; font-weight: 700; line-height: 1.05; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat-label { font-weight: 600; font-size: .85rem; }
.stat-sub { color: var(--ms-muted); font-size: .75rem; }
.tone-green .stat-icon { background: var(--ms-green-bg); color: var(--ms-green); }
.tone-gold .stat-icon { background: var(--ms-gold-bg); color: var(--ms-gold); }
.tone-red .stat-icon { background: var(--ms-red-bg); color: var(--ms-red); }
.tone-blue .stat-icon { background: var(--ms-blue-bg); color: var(--ms-blue); }
.tone-sand .stat-icon { background: var(--ms-sand-bg); color: var(--ms-sand); }
.tone-slate .stat-icon { background: var(--ms-slate-bg); color: var(--ms-slate); }
@media (max-width: 991.98px) {
  .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { border-left: 0; border-top: 1px solid var(--ms-line); }
  .stat:nth-child(even) { border-left: 1px solid var(--ms-line); }
  .stat:nth-child(-n+2) { border-top: 0; }
  .stat-value { font-size: 1.45rem; }
}

/* Season ribbon */
.season-card { display: grid; grid-template-columns: minmax(0, 240px) minmax(0, 1fr); gap: 20px; align-items: center; }
.season-card h2 { font-size: 1.6rem; margin: 2px 0; }
.eyebrow { font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ms-muted); font-weight: 600; }
.ribbon { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 3px; }
.ribbon span { height: 34px; border-radius: 5px; opacity: .35; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 3px; font: 500 10px var(--ms-f-mono); color: #fff; position: relative; }
.ribbon span.on { opacity: 1; }
.ribbon span.now::after { content: ""; position: absolute; top: -8px; left: 50%; transform: translateX(-50%); border: 5px solid transparent; border-top-color: var(--ms-ink); }
.ribbon .jilaal { background: var(--s-jilaal); } .ribbon .gu { background: var(--s-gu); } .ribbon .xagaa { background: var(--s-xagaa); } .ribbon .dayr { background: var(--s-dayr); }
.ribbon-labels { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3px; margin-top: 6px; font-size: .78rem; color: var(--ms-muted); }
.ribbon-labels b { color: var(--ms-ink); }
@media (max-width: 767.98px) { .season-card { grid-template-columns: minmax(0, 1fr); gap: 12px; } }

.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.figures > div { padding: 12px 18px; border-left: 1px solid var(--ms-line); border-top: 1px solid var(--ms-line); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.figures > div:nth-child(4n+1) { border-left: 0; } .figures > div:nth-child(-n+4) { border-top: 0; }
.figures span { font-size: .78rem; color: var(--ms-muted); }
.figures b { font-family: var(--ms-f-mono); font-weight: 500; font-size: 1.1rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
@media (max-width: 767.98px) {
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .figures > div:nth-child(n) { border-left: 1px solid var(--ms-line); border-top: 1px solid var(--ms-line); }
  .figures > div:nth-child(2n+1) { border-left: 0; } .figures > div:nth-child(-n+2) { border-top: 0; }
}

.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: center; padding: 10px 18px; border-top: 1px solid var(--ms-line); }
.mini-list li:first-child { border-top: 0; }
.mini-list a.t { color: var(--ms-ink); text-decoration: none; font-weight: 500; overflow-wrap: anywhere; }
.mini-list a.t:hover { color: var(--ms-accent); }
.mini-list .d { grid-column: 1; font-size: .78rem; color: var(--ms-muted); }
.mini-empty { padding: 14px 18px; color: var(--ms-muted); font-size: .875rem; }

/* Pills: colour plus a dot plus text, so status reads without colour */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-green { background: var(--ms-green-bg); color: var(--ms-green); } .pill-gold { background: var(--ms-gold-bg); color: var(--ms-gold); }
.pill-red { background: var(--ms-red-bg); color: var(--ms-red); } .pill-blue { background: var(--ms-blue-bg); color: var(--ms-blue); }
.pill-slate { background: var(--ms-slate-bg); color: var(--ms-slate); } .pill-sand { background: var(--ms-sand-bg); color: var(--ms-sand); }
.tag-ex { font-size: .62rem; letter-spacing: .06em; text-transform: uppercase; font-weight: 600; color: var(--ms-sand); border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; vertical-align: 1px; }

/* Lists */
.list-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.list-toolbar .search { position: relative; flex: 1 1 220px; max-width: 360px; }
.list-toolbar .search .bi { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ms-muted); }
.list-toolbar .search input { padding-left: 34px; }
.list-toolbar .form-select { width: auto; flex: 0 1 180px; }
.table-wrap { background: var(--ms-surface); border: 1px solid var(--ms-line); border-radius: 12px; overflow-x: auto; }
.table { --bs-table-bg: transparent; --bs-table-color: var(--ms-ink); --bs-table-border-color: var(--ms-line); --bs-table-hover-bg: var(--ms-surface-2); --bs-table-hover-color: var(--ms-ink); margin: 0; min-width: 680px; }
.table th { font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ms-muted); font-weight: 600; background: var(--ms-surface-2); white-space: nowrap; padding: 10px 12px; }
.table td { padding: 11px 12px; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table a.row-link { color: var(--ms-ink); font-weight: 600; text-decoration: none; }
.table a.row-link:hover { color: var(--ms-accent); text-decoration: underline; }
.table tr[data-href] { cursor: pointer; }
.table td.notes { color: var(--ms-muted); max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plus { color: var(--ms-green); } .minus { color: var(--ms-red); }
.bar { display: inline-flex; align-items: center; gap: 8px; justify-content: flex-end; }
.bar i { display: block; width: 70px; height: 6px; border-radius: 3px; background: var(--ms-surface-2); overflow: hidden; }
.bar i b { display: block; height: 100%; background: var(--ms-accent); }
.bar i b.gold { background: var(--ms-gold); } .bar i b.red { background: var(--ms-red); }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: var(--ms-muted); font-size: .8rem; }
.foot-note { font-size: .78rem; color: var(--ms-muted); }
.calc-card { background: var(--ms-accent-soft); color: var(--ms-ink); border-radius: 12px; padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; }
.calc-card dl { margin: 0; display: grid; grid-template-columns: auto auto; gap: 6px 16px; }
.calc-card dt { font-weight: 500; color: var(--ms-muted); }
.calc-card dd { margin: 0; text-align: right; font-family: var(--ms-f-mono); font-variant-numeric: tabular-nums; }

.empty-state { text-align: center; padding: 48px 16px; color: var(--ms-muted); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.empty-state > .bi { font-size: 2.2rem; color: var(--ms-accent); }
.empty-state h2 { font-size: 1.2rem; color: var(--ms-ink); margin: 6px 0 0; }
.empty-state p { max-width: 46ch; margin: 0 0 8px; }

/* Sign-in page */
.auth-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; background:
  linear-gradient(180deg, color-mix(in srgb, var(--season, var(--s-dayr)) 22%, var(--ms-bg)) 0, var(--ms-bg) 340px); }
.auth-card { width: min(420px, 100%); }
.auth-card .brand { justify-content: center; margin-bottom: 18px; }
.auth-card .brand b { font-size: 2rem; }

/* Monthly report (prints cleanly from the browser) */
@media print {
  .sidebar, .topbar, .tabbar, .foot, .no-print, .alert { display: none !important; }
  .content { padding: 0; max-width: none; }
  body { background: #fff; color: #000; }
  .panel, .stat-strip, .table-wrap { border-color: #bbb; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
