/* ============================================================
   UMS Staff Console — Design System
   Palette: Deep Blue + Gold. Self-contained (no framework).
   ============================================================ */

:root {
  /* Brand — set per-tenant (see the inline theme block in the templates).
     Shades derive from --brand/--gold so one override re-themes everything. */
  --brand:        #0E2A5E;
  --brand-700:    color-mix(in srgb, var(--brand) 88%, white);
  --brand-600:    color-mix(in srgb, var(--brand) 76%, white);
  --brand-800:    color-mix(in srgb, var(--brand) 80%, black);
  --brand-050:    color-mix(in srgb, var(--brand) 8%, white);
  /* Gold accent */
  --gold:         #C8A23A;
  --gold-400:     color-mix(in srgb, var(--gold) 76%, white);
  --gold-600:     color-mix(in srgb, var(--gold) 76%, black);
  /* Neutrals */
  --bg:           #EEF1F7;
  --surface:      #FFFFFF;
  --surface-2:    #F7F9FC;
  --ink:          #1A2233;
  --muted:        #6A7488;
  --border:       #E2E8F2;
  /* Status */
  --success:      #1E7E34;
  --success-bg:   #E6F4EA;
  --warn:         #B7791F;
  --warn-bg:      #FBF3E2;
  --danger:       #C0392B;
  --danger-bg:    #FBE9E7;
  --info:         var(--brand-600);
  --info-bg:      color-mix(in srgb, var(--brand) 10%, white);

  --radius:       12px;
  --radius-sm:    8px;
  --shadow:       0 1px 2px rgba(16,33,73,.06), 0 6px 20px rgba(16,33,73,.06);
  --shadow-lg:    0 10px 40px rgba(16,33,73,.16);
  --sidebar-w:    258px;
}

/* ---- Dark theme (accessibility): flip surfaces/text, keep brand+gold ---- */
:root[data-theme="dark"] {
  --bg:        #0E1522;
  --surface:   #16202F;
  --surface-2: #1B2736;
  --ink:       #E6EBF3;
  --muted:     #94A2B6;
  --border:    #29384C;
  --brand-050: #1A2A45;   /* subtle row hover on dark */
  --shadow:    0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35);
  --shadow-lg: 0 12px 44px rgba(0,0,0,.5);
}
/* Elements that used the near-black brand colour for TEXT need lightening. */
:root[data-theme="dark"] h1,
:root[data-theme="dark"] h2,
:root[data-theme="dark"] h3,
:root[data-theme="dark"] h4,
:root[data-theme="dark"] .stat .value,
:root[data-theme="dark"] .card__head h3,
:root[data-theme="dark"] .topbar h1 { color: #EAF0F8; }
:root[data-theme="dark"] .badge-muted { background:#26364a; color:#aab6c8; }
:root[data-theme="dark"] a { color: #8FB4F2; }

/* Theme toggle button in the topbar */
.theme-toggle {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--ink);
  width: 38px; height: 38px; border-radius: 9px; cursor: pointer; font-size: 1rem;
  display: inline-grid; place-items: center; transition: background .12s, transform .12s;
}
.theme-toggle:hover { transform: translateY(-1px); }

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14.5px;
  line-height: 1.5;
}

a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5rem; color: var(--brand-800); font-weight: 700; }

/* ---------- App shell: sidebar + main ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--brand-800) 0%, var(--brand) 100%);
  color: #cdd7ea;
  position: fixed; inset: 0 auto 0 0;
  display: flex; flex-direction: column;
  z-index: 30;
}
.sidebar__brand {
  display: flex; align-items: center; gap: .6rem;
  padding: 1.15rem 1.15rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar__seal {
  width: 38px; height: 38px; border-radius: 9px; flex: 0 0 auto;
  background: var(--gold); color: var(--brand-800);
  display: grid; place-items: center; font-weight: 800; font-size: .85rem;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.35);
}
.sidebar__logo {
  width: 40px; height: 40px; border-radius: 10px; flex: 0 0 auto;
  background: #fff; object-fit: contain; padding: 3px;
  box-shadow: 0 0 0 2px rgba(255,255,255,.25);
}
.hero-logo {
  width: 84px; height: 84px; border-radius: 18px; background: #fff;
  object-fit: contain; padding: 6px; margin-bottom: 1.4rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); position: relative; z-index: 1;
}
.sidebar__brand b { color: #fff; font-size: .98rem; line-height: 1.15; display: block; }
.sidebar__brand span { font-size: .72rem; color: #9fb0d0; }

.nav { padding: .6rem .55rem 1.5rem; overflow-y: auto; }
.nav__group { margin-top: 1rem; padding: 0 .6rem; font-size: .68rem; letter-spacing: .09em;
  text-transform: uppercase; color: #7f92b6; }
.nav a {
  display: flex; align-items: center; gap: .65rem;
  padding: .56rem .75rem; margin: .12rem 0;
  border-radius: 9px; color: #c8d2e6; font-weight: 500;
  text-decoration: none; transition: background .12s, color .12s;
}
.nav a .ico { width: 18px; text-align: center; opacity: .85; }
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.nav a.active { background: rgba(255,255,255,.12); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 62px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 1rem;
  padding: 0 1.4rem; position: sticky; top: 0; z-index: 20;
}
.topbar h1 { margin: 0; font-size: 1.05rem; }
.topbar .spacer { flex: 1; }
.userchip { display: flex; align-items: center; gap: .6rem; }
.userchip .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--brand-050); color: var(--brand); font-weight: 700;
  display: grid; place-items: center; font-size: .82rem;
}
.userchip small { color: var(--muted); display: block; line-height: 1; }

.content { padding: 1.5rem 1.6rem 3rem; animation: fadeUp .45s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Time-of-day greeting banner — bigger, modern gradient, slides in once per login */
.greeting {
  display: flex; align-items: center; gap: 1.1rem;
  /* modern gradient: indigo → Team water-blue → cyan */
  background: linear-gradient(120deg, #202a56 0%, var(--brand) 52%, #17a8bd 118%);
  color: #fff; border-left: 5px solid var(--gold);
  padding: 1.25rem 1.5rem; border-radius: 16px; margin-bottom: 1.5rem;
  box-shadow: 0 14px 34px rgba(20,40,90,.28);
  position: relative; overflow: hidden;
}
.greeting::after {                       /* soft sheen */
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(120% 140% at 100% 0%, rgba(255,255,255,.18), transparent 55%);
  pointer-events: none;
}
.greeting .g-emoji { font-size: 2.5rem; line-height: 1; filter: drop-shadow(0 3px 6px rgba(0,0,0,.25)); }
.greeting .g-body { position: relative; z-index: 1; }
.greeting .g-hello { color: #fff; font-weight: 800; font-size: 1.35rem; letter-spacing: .2px; }
.greeting b { color: #fff; }
.greeting .g-sub { color: #dbe6fb; font-size: .86rem; margin-top: 1px; }
.greeting .g-quote { color: #eef4ff; font-size: .92rem; font-style: italic; margin-top: .55rem; opacity: .95; }
.greeting .g-quote .g-author { font-style: normal; opacity: .8; font-size: .82rem; }

/* Entrance: fly in from the left. Exit: fly off to the top-right corner. */
@keyframes g-in  { from { opacity: 0; transform: translateX(-46px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes g-out { to   { opacity: 0; transform: translate(48vw, -150%) rotate(3deg) scale(.9); } }
.greeting.g-enter { animation: g-in .65s cubic-bezier(.2,.8,.2,1) both; }
.greeting.g-leave { animation: g-out .85s cubic-bezier(.6,.05,.7,.1) forwards; }
@media (prefers-reduced-motion: reduce) {
  .content, .greeting { animation: none; transition: none; }
  .greeting.g-leave { display: none; }
}
.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 1.2rem; gap: 1rem; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin: .15rem 0 0; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card__head { padding: .95rem 1.15rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; }
.card__head h3 { margin: 0; font-size: .98rem; }
.card__body { padding: 1.15rem; }

/* ---------- Stat tiles ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; margin-bottom: 1.4rem; }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--gold); }
.stat .label { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
.stat .value { font-size: 1.9rem; font-weight: 800; color: var(--brand-800); margin-top: .2rem; }
.stat .sub { font-size: .8rem; color: var(--muted); margin-top: .15rem; }
.stat .ico { position: absolute; top: 1rem; right: 1.1rem; font-size: 1.4rem; opacity: .25; }
.stat.accent::after { background: var(--brand); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .5rem .95rem; border-radius: var(--radius-sm);
  border: 1px solid transparent; font-weight: 600; font-size: .88rem;
  cursor: pointer; text-decoration: none; transition: filter .12s, background .12s;
}
.btn:hover { text-decoration: none; filter: brightness(1.05); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-gold { background: var(--gold); color: var(--brand-800); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--ink); }
.btn-outline:hover { background: var(--surface-2); }
.btn-sm { padding: .32rem .6rem; font-size: .8rem; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th, table.tbl td { padding: .7rem .85rem; text-align: left; border-bottom: 1px solid var(--border); }
table.tbl thead th { background: var(--surface-2); color: var(--muted); font-size: .74rem;
  text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
table.tbl tbody tr:hover { background: var(--brand-050); }
table.tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: .18rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 700; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-muted { background: #EEF1F6; color: var(--muted); }

/* ---------- Forms ---------- */
.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; margin-bottom: .3rem; font-size: .86rem; }
.input, input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], select, textarea {
  width: 100%; padding: .6rem .7rem; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: #fff; font: inherit; color: var(--ink);
}
.input:focus, input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand-600); box-shadow: 0 0 0 3px var(--brand-050);
}

/* ---------- Alerts ---------- */
.alert { padding: .75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; border: 1px solid transparent; }
.alert-success { background: var(--success-bg); color: var(--success); border-color: #bfe2c8; }
.alert-error, .alert-danger { background: var(--danger-bg); color: var(--danger); border-color: #f3c9c2; }
.alert-info { background: var(--info-bg); color: var(--info); border-color: #c8d8f2; }
.alert-warning { background: var(--warn-bg); color: var(--warn); border-color: #ecdcae; }

.muted { color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; }
.login-hero {
  background: linear-gradient(150deg, var(--brand-800), var(--brand) 60%, var(--brand-700));
  color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: center;
  position: relative; overflow: hidden;
}
.login-hero::before { content: ""; position: absolute; width: 460px; height: 460px; border-radius: 50%;
  background: radial-gradient(circle, rgba(200,162,58,.28), transparent 70%); top: -120px; right: -120px; }
.login-hero .seal { width: 64px; height: 64px; border-radius: 14px; background: var(--gold);
  color: var(--brand-800); display: grid; place-items: center; font-weight: 800; font-size: 1.3rem;
  box-shadow: inset 0 0 0 3px rgba(255,255,255,.4); margin-bottom: 1.5rem; }
.login-hero h1 { color: #fff; font-size: 2rem; line-height: 1.15; }
.login-hero p { color: #c6d2e8; max-width: 30rem; }
.login-hero .tagline { color: var(--gold-400); font-style: italic; margin-top: 2rem; }
.login-form-panel { display: flex; align-items: center; justify-content: center; padding: 2rem; background: var(--surface); }
.login-form { width: 100%; max-width: 360px; }
.login-form h2 { font-size: 1.5rem; }

@media (max-width: 900px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 780px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-flex !important; }
}
.menu-toggle { display: none; background: none; border: 0; font-size: 1.4rem; cursor: pointer; color: var(--brand); }

/* ============================================================
   Dashboard kit — shared by the admin & module overview pages
   ============================================================ */

/* Section heading with a soft rule under it */
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  margin: 1.9rem 0 .95rem; flex-wrap: wrap; }
.section-head h2 { font-size: 1.06rem; margin: 0; }
.section-head .hint { color: var(--muted); font-size: .82rem; }

/* ---- Module hero band (top of each module overview) ---- */
.module-hero {
  display: flex; align-items: center; gap: 1.05rem;
  background: linear-gradient(120deg, var(--brand-800), var(--brand-700) 65%, var(--brand-600));
  color: #fff; border-radius: var(--radius); padding: 1.25rem 1.5rem;
  margin-bottom: 1.4rem; box-shadow: var(--shadow); border-left: 4px solid var(--gold);
  position: relative; overflow: hidden; animation: fadeUp .4s ease both;
}
.module-hero::before { content: ""; position: absolute; width: 260px; height: 260px; border-radius: 50%;
  background: radial-gradient(circle, rgba(200,162,58,.22), transparent 70%); top: -110px; right: -60px; }
.module-hero .m-ico { font-size: 2rem; line-height: 1; position: relative; z-index: 1; }
.module-hero h2 { color: #fff; margin: 0; font-size: 1.3rem; }
.module-hero p { color: #cfd9ec; margin: .2rem 0 0; font-size: .85rem; max-width: 48rem; }
.module-hero .m-actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; position: relative; z-index: 1; }

/* ---- Module launcher grid (admin dashboard) ---- */
.launch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(216px, 1fr)); gap: 1rem; }
.launch {
  display: flex; flex-direction: column; gap: .55rem; text-decoration: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.15rem; box-shadow: var(--shadow); color: var(--ink);
  position: relative; overflow: hidden; transition: transform .14s, box-shadow .14s, border-color .14s;
}
.launch:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--gold); text-decoration: none; }
.launch .l-top { display: flex; align-items: center; justify-content: space-between; }
.launch .l-ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  font-size: 1.3rem; background: var(--brand-050); color: var(--brand); }
.launch .l-count { font-weight: 800; font-size: 1.15rem; color: var(--brand-800); font-variant-numeric: tabular-nums; }
.launch .l-name { font-weight: 700; color: var(--brand-800); }
.launch .l-desc { color: var(--muted); font-size: .8rem; line-height: 1.35; }
.launch::after { content: ""; position: absolute; inset: auto 0 0 0; height: 3px;
  background: linear-gradient(90deg, var(--brand), var(--gold)); transform: scaleX(0);
  transform-origin: left; transition: transform .18s; }
.launch:hover::after { transform: scaleX(1); }
:root[data-theme="dark"] .launch .l-count, :root[data-theme="dark"] .launch .l-name { color: #EAF0F8; }

/* ---- Horizontal bar chart ---- */
.bars { display: flex; flex-direction: column; gap: .72rem; }
.bar-row { display: grid; grid-template-columns: 128px 1fr 58px; align-items: center; gap: .65rem; font-size: .84rem; }
.bar-row .bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; height: 12px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; transform-origin: left; animation: growx .6s ease both;
  background: linear-gradient(90deg, var(--brand-600), var(--brand)); }
.bar-fill.gold  { background: linear-gradient(90deg, var(--gold-400), var(--gold-600)); }
.bar-fill.green { background: linear-gradient(90deg, #2fa34d, var(--success)); }
.bar-fill.red   { background: linear-gradient(90deg, #e06456, var(--danger)); }
.bar-row .bar-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
@keyframes growx { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ---- Progress meter (e.g. fees collected vs billed) ---- */
.prog { margin-bottom: 1.05rem; }
.prog:last-child { margin-bottom: 0; }
.prog .prog-head { display: flex; justify-content: space-between; font-size: .84rem; margin-bottom: .35rem; }
.prog .prog-head b { color: var(--brand-800); }
.prog-track { height: 14px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.prog-fill { height: 100%; border-radius: 999px; transform-origin: left; animation: growx .6s ease both;
  background: linear-gradient(90deg, #2fa34d, var(--success)); }
.prog-fill.gold { background: linear-gradient(90deg, var(--gold-400), var(--gold-600)); }
:root[data-theme="dark"] .prog .prog-head b { color: #EAF0F8; }

/* ---- Donut (conic-gradient) ---- */
.donut-wrap { display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap; }
.donut { width: 138px; height: 138px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto; }
.donut .hole { width: 96px; height: 96px; border-radius: 50%; background: var(--surface);
  display: grid; place-items: center; text-align: center; box-shadow: inset 0 0 0 1px var(--border); }
.donut .hole .big { font-size: 1.5rem; font-weight: 800; color: var(--brand-800); line-height: 1; }
.donut .hole .cap { font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
:root[data-theme="dark"] .donut .hole .big { color: #EAF0F8; }
.legend { display: flex; flex-direction: column; gap: .5rem; font-size: .85rem; }
.legend .li { display: flex; align-items: center; gap: .5rem; }
.legend .sw { width: 12px; height: 12px; border-radius: 3px; flex: 0 0 auto; }

/* ---- Activity feed ---- */
.feed { display: flex; flex-direction: column; }
.feed .item { display: flex; gap: .7rem; padding: .62rem 0; border-bottom: 1px solid var(--border); }
.feed .item:last-child { border-bottom: 0; }
.feed .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--gold); margin-top: .4rem; flex: 0 0 auto; }
.feed .f-main { font-size: .86rem; }
.feed .f-time { color: var(--muted); font-size: .76rem; }

/* Small helpers used across module pages */
.stat.mini .value { font-size: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1.2rem; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 1.2rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.card__body.tight { padding: .8rem 1.15rem; }
.empty { text-align: center; color: var(--muted); padding: 1.4rem 1rem; }
@media (max-width: 980px) { .grid-3, .grid-2-1 { grid-template-columns: 1fr; } }
