/* =============================================================================
   BDPH — application styles
   Palette: deep green sidebar, BDPH green for action, ochre for "you are here".
   ========================================================================== */
:root {
  --ink: #123F35;
  --ink-2: #1a5244;
  --ink-text: #b7cfc6;
  --blue: #177B62;
  --blue-600: #12634f;
  --blue-50: #e6f3ee;
  --gold: #BC8B33;
  --gold-50: #f8efdc;
  --green: #2e8b4e;
  --green-50: #e7f5ee;
  --red: #c2413b;
  --red-50: #fbecea;
  --violet: #6b4fc8;
  --violet-50: #f1edfc;
  --slate: #5b6476;
  --slate-50: #f0f2f5;

  --bg: #F6F5EF;
  --surface: #ffffff;
  --surface-2: #faf9f4;
  --line: #e4e2d8;
  --text: #1d2a26;
  --muted: #63726c;

  --radius-lg: 12px;
  --radius: 8px;
  --radius-sm: 6px;
  --sidebar-w: 264px;

  --bs-body-font-family: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--text);
  --bs-primary: var(--blue);
  --bs-primary-rgb: 23, 123, 98;
  --bs-link-color: var(--blue);
  --bs-link-color-rgb: 23, 123, 98;
  --bs-link-hover-color: var(--blue-600);
  --bs-border-color: var(--line);
  --bs-secondary-color: var(--muted);
}

[data-bs-theme="dark"] {
  --ink: #0b1f1a;
  --ink-2: #133a30;
  --bg: #0e1714;
  --surface: #15221e;
  --surface-2: #1a2a25;
  --line: #283b35;
  --text: #e3ece8;
  --muted: #93a59e;
  --blue: #4fb894;
  --blue-600: #6cc8a7;
  --blue-50: #16362d;
  --gold-50: #3a2f17;
  --green-50: #14342a;
  --red-50: #3d1d1d;
  --violet-50: #2a2250;
  --slate-50: #222d44;
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--text);
  --bs-border-color: var(--line);
  --bs-primary-rgb: 79, 184, 148;
  --bs-tertiary-bg: var(--surface-2);
}

html { font-size: 15px; }
body { background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { text-decoration: none; }
.text-muted { color: var(--muted) !important; }
::selection { background: var(--gold); color: #1b1300; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---- Shell ---------------------------------------------------------------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w); background: var(--ink); color: var(--ink-text);
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; z-index: 1040;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 18px 20px; color: #fff; border-bottom: 1px solid rgba(255,255,255,.06); }
.brand:hover { color: #fff; }
.brand-logo { width: 40px; height: 40px; border-radius: 10px; background: #fff; object-fit: contain; padding: 3px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 10px; background: var(--gold); color: var(--ink);
  display: grid; place-items: center; font-weight: 800; font-size: .82rem; letter-spacing: .02em;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text strong { font-size: 1.05rem; font-weight: 800; }
.brand-text small { color: var(--ink-text); font-size: .76rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.side-nav { flex: 1; overflow-y: auto; padding: 12px 10px 20px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent; }
.side-nav ul { list-style: none; margin: 0; padding: 0; }
.side-nav .nav-link {
  display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 12px; border-radius: var(--radius);
  color: var(--ink-text); font-weight: 500; font-size: .93rem; background: none; border: 0; text-align: left; position: relative;
}
.side-nav .nav-link > .bi:first-child { font-size: 1.05rem; width: 20px; text-align: center; opacity: .85; }
.side-nav .nav-link:hover { color: #fff; background: rgba(255,255,255,.05); }
.side-nav .nav-link.active { color: #fff; background: var(--ink-2); }
.side-nav .nav-link.active::before {
  content: ''; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--gold);
}
.side-nav .caret { margin-left: auto; font-size: .75rem; transition: transform .2s; }
.side-nav .nav-toggle[aria-expanded="true"] .caret { transform: rotate(180deg); }
.side-nav .nav-group.open > .nav-toggle { color: #fff; }
.side-nav .sub { padding: 2px 0 6px 31px; }
.side-nav .sub .nav-link { padding: 7px 12px; font-size: .88rem; font-weight: 500; }
.side-nav .sub .nav-link.active { color: var(--gold); background: transparent; }
.side-nav .sub .nav-link.active::before { left: -13px; top: 10px; bottom: 10px; }

.side-foot { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.06); }
.side-user { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.side-user strong { color: #fff; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user small { font-size: .76rem; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: 14px; height: 64px; padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.top-search { flex: 1; max-width: 480px; position: relative; display: flex; align-items: center; }
.top-search .bi { position: absolute; left: 13px; color: var(--muted); }
.top-search input {
  width: 100%; height: 40px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  padding: 0 44px 0 38px; color: var(--text); font-size: .92rem;
}
.top-search input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-50); }
.top-search kbd { position: absolute; right: 12px; background: var(--slate-50); color: var(--muted); border: 1px solid var(--line); font-size: .72rem; padding: 1px 6px; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.term-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-size: .84rem; font-weight: 600;
  background: var(--gold-50); color: #8a5a00; margin-right: 6px; white-space: nowrap;
}
[data-bs-theme="dark"] .term-chip { color: var(--gold); }
.icon-btn {
  width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 10px; border: 0; background: none; color: var(--muted); font-size: 1.15rem;
}
.icon-btn:hover { background: var(--surface); color: var(--text); }
.dot-count {
  position: absolute; top: 3px; right: 3px; min-width: 17px; height: 17px; border-radius: 9px; background: var(--red); color: #fff;
  font-size: .66rem; font-weight: 700; display: grid; place-items: center; padding: 0 4px;
}
.user-btn { display: flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--muted); padding: 4px; border-radius: 999px; }
.user-btn:hover { background: var(--surface); }

.content { padding: 28px; flex: 1; width: 100%; max-width: 1600px; }
.foot { padding: 16px 28px; color: var(--muted); font-size: .82rem; border-top: 1px solid var(--line); }

.sidebar-backdrop { display: none; }
@media (max-width: 991.98px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .25s ease; }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(9,15,30,.45); z-index: 1030; }
  .topbar { padding: 0 16px; }
  .content { padding: 20px 16px; }
  .term-chip { display: none; }
  .top-search kbd { display: none; }
}

/* ---- Page header ---------------------------------------------------------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-head h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -.015em; margin: 0; }
.page-sub { color: var(--muted); margin: 4px 0 0; max-width: 70ch; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.crumbs { font-size: .83rem; color: var(--muted); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--blue); }
.crumbs .bi { font-size: .65rem; }

/* ---- Panels --------------------------------------------------------------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); margin-bottom: 22px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-head h2, .panel-head h3 { font-size: 1.02rem; font-weight: 700; margin: 0; }
.panel-head .hint { color: var(--muted); font-size: .85rem; font-weight: 400; }
.panel-body { padding: 20px; }
.panel-foot { padding: 12px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.panel.flush .table { margin: 0; }

/* ---- Stat strip ----------------------------------------------------------- */
.stat-strip {
  display: grid; grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr)); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-lg); margin-bottom: 22px; overflow: hidden;
}
.stat { display: flex; gap: 14px; align-items: flex-start; padding: 18px 20px; color: var(--text); border-left: 1px solid var(--line); }
.stat:first-child { border-left: 0; }
a.stat:hover { background: var(--surface-2); color: var(--text); }
.stat-icon { width: 40px; height: 40px; flex: 0 0 40px; 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-size: 1.55rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: .86rem; font-weight: 500; }
.stat-sub { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.tone-blue .stat-icon { background: var(--blue-50); color: var(--blue); }
.tone-gold .stat-icon { background: var(--gold-50); color: #b07a12; }
.tone-green .stat-icon { background: var(--green-50); color: var(--green); }
.tone-red .stat-icon { background: var(--red-50); color: var(--red); }
.tone-violet .stat-icon { background: var(--violet-50); color: var(--violet); }
.tone-slate .stat-icon { background: var(--slate-50); color: var(--slate); }
@media (max-width: 1199.98px) { .stat-strip { grid-template-columns: repeat(min(var(--cols, 4), 3), minmax(0, 1fr)); } .stat { border-top: 1px solid var(--line); } }
@media (max-width: 767.98px) { .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 420px) { .stat-strip { grid-template-columns: 1fr; } .stat { border-left: 0; } }

/* ---- Tables --------------------------------------------------------------- */
.table { --bs-table-bg: transparent; --bs-table-color: var(--text); margin-bottom: 0; font-size: .92rem; }
.table > thead th {
  font-size: .8rem; font-weight: 700; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--line);
  padding: 10px 14px; white-space: nowrap;
}
.table > tbody td { padding: 11px 14px; vertical-align: middle; border-color: var(--line); }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: var(--surface-2); }
.table tfoot td, .table tfoot th { background: var(--surface-2); font-weight: 700; padding: 11px 14px; }
.table .num, .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.table-sm > tbody td { padding: 7px 12px; }
.cell-main { font-weight: 600; color: var(--text); }
.cell-sub { display: block; color: var(--muted); font-size: .82rem; }
.link-strong { font-weight: 600; color: var(--text); }
.link-strong:hover { color: var(--blue); }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions .btn { padding: 3px 9px; }
.pager-info { color: var(--muted); font-size: .86rem; }

/* ---- Filters -------------------------------------------------------------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.filters .f { display: flex; flex-direction: column; gap: 4px; min-width: 150px; flex: 1 1 160px; max-width: 260px; }
.filters .f.grow { max-width: none; flex: 2 1 220px; }
.filters label { font-size: .8rem; font-weight: 600; color: var(--muted); }
.filters .f-actions { display: flex; gap: 8px; margin-left: auto; }

/* ---- Forms ---------------------------------------------------------------- */
.form-control, .form-select { border-radius: var(--radius-sm); border-color: var(--line); background-color: var(--surface); font-size: .93rem; }
.form-control:focus, .form-select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-50); }
.form-label { font-weight: 600; font-size: .86rem; margin-bottom: 5px; }
.form-label .req { color: var(--red); margin-left: 2px; }
.form-text { color: var(--muted); }
.form-section { padding: 20px; border-bottom: 1px solid var(--line); }
.form-section:last-child { border-bottom: 0; }
.form-section h3 { font-size: .98rem; font-weight: 700; margin: 0 0 4px; }
.form-section > p { color: var(--muted); font-size: .86rem; margin: 0 0 16px; }
.btn { border-radius: var(--radius-sm); font-weight: 600; font-size: .9rem; display: inline-flex; align-items: center; gap: 6px; justify-content: center; }
.btn-primary { --bs-btn-bg: var(--blue); --bs-btn-border-color: var(--blue); --bs-btn-hover-bg: var(--blue-600); --bs-btn-hover-border-color: var(--blue-600); --bs-btn-active-bg: var(--blue-600); }
.btn-outline-primary { --bs-btn-color: var(--blue); --bs-btn-border-color: var(--blue); --bs-btn-hover-bg: var(--blue); --bs-btn-hover-border-color: var(--blue); }
.btn-light { --bs-btn-bg: var(--surface); --bs-btn-border-color: var(--line); --bs-btn-color: var(--text); --bs-btn-hover-bg: var(--surface-2); --bs-btn-hover-border-color: var(--line); }
.btn-gold { background: var(--gold); border-color: var(--gold); color: #2a1c00; }
.btn-gold:hover { background: #a87b2a; border-color: #a87b2a; color: #2a1c00; }
.ts-wrapper.form-select { padding: 0; }
.ts-control { border-radius: var(--radius-sm) !important; border-color: var(--line) !important; min-height: 38px; background: var(--surface) !important; color: var(--text); }
.ts-dropdown { border-color: var(--line); background: var(--surface); color: var(--text); }
.ts-dropdown .active { background: var(--blue-50); color: var(--text); }
.ts-control input { color: var(--text) !important; }

/* ---- Pills, grades, avatars ---------------------------------------------- */
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.pill-green { background: var(--green-50); color: var(--green); }
.pill-red { background: var(--red-50); color: var(--red); }
.pill-gold { background: var(--gold-50); color: #9a6a0c; }
.pill-blue { background: var(--blue-50); color: var(--blue); }
.pill-violet { background: var(--violet-50); color: var(--violet); }
.pill-slate { background: var(--slate-50); color: var(--slate); }
[data-bs-theme="dark"] .pill-gold { color: var(--gold); }
[data-bs-theme="dark"] .pill-slate { color: var(--muted); }
.grade { display: inline-grid; place-items: center; min-width: 30px; height: 26px; padding: 0 6px; border-radius: 6px; font-weight: 800; font-size: .85rem; }
.grade-a { background: var(--green-50); color: var(--green); }
.grade-b { background: var(--blue-50); color: var(--blue); }
.grade-c { background: var(--gold-50); color: #9a6a0c; }
.grade-d { background: #fdebdc; color: #b4551c; }
.grade-f { background: var(--red-50); color: var(--red); }
[data-bs-theme="dark"] .grade-d { background: #3d2717; color: #f0a46f; }
.avatar {
  --hue: 220; width: 38px; height: 38px; flex: 0 0 38px; border-radius: 50%; display: inline-grid; place-items: center; object-fit: cover;
  background: hsl(var(--hue) 55% 92%); color: hsl(var(--hue) 45% 32%); font-weight: 700; font-size: .82rem;
}
[data-bs-theme="dark"] .avatar:not(img) { background: hsl(var(--hue) 30% 26%); color: hsl(var(--hue) 70% 85%); }
.avatar.sm { width: 32px; height: 32px; flex-basis: 32px; font-size: .74rem; }
.avatar.lg { width: 88px; height: 88px; flex-basis: 88px; font-size: 1.6rem; }
.person { display: flex; align-items: center; gap: 11px; min-width: 0; }
.person > div { min-width: 0; }

/* ---- Empty states --------------------------------------------------------- */
.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state > .bi { font-size: 2.4rem; color: var(--line); display: block; margin-bottom: 10px; }
[data-bs-theme="dark"] .empty-state > .bi { color: #3a4a6c; }
.empty-state h2 { font-size: 1.1rem; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.empty-state p { max-width: 46ch; margin: 0 auto 16px; }

/* ---- Tabs ----------------------------------------------------------------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0 12px; overflow-x: auto; }
.tabs a, .tabs button {
  padding: 13px 14px; color: var(--muted); font-weight: 600; font-size: .9rem; border: 0; background: none; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a:hover, .tabs button:hover { color: var(--text); }
.tabs a.active, .tabs button.active { color: var(--blue); border-bottom-color: var(--blue); }
.tabs .count { background: var(--slate-50); color: var(--muted); border-radius: 999px; padding: 1px 7px; font-size: .74rem; margin-left: 4px; }

/* ---- Profile header ------------------------------------------------------- */
.profile-card { display: grid; grid-template-columns: auto 1fr auto; gap: 22px; align-items: center; padding: 22px; }
.profile-card h2 { font-size: 1.4rem; font-weight: 800; margin: 0; }
.profile-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--muted); font-size: .9rem; margin-top: 6px; }
.profile-meta span { display: inline-flex; align-items: center; gap: 6px; }
.profile-figures { display: flex; gap: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.profile-figures div { padding: 10px 18px; text-align: center; border-left: 1px solid var(--line); }
.profile-figures div:first-child { border-left: 0; }
.profile-figures strong { display: block; font-size: 1.25rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.profile-figures small { color: var(--muted); font-size: .78rem; }
@media (max-width: 767.98px) { .profile-card { grid-template-columns: 1fr; text-align: left; } }
.dl { display: grid; grid-template-columns: minmax(130px, 38%) 1fr; gap: 0; margin: 0; }
.dl dt { color: var(--muted); font-weight: 500; font-size: .87rem; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.dl dd { margin: 0; padding: 9px 0; border-bottom: 1px dashed var(--line); font-weight: 500; }

/* ---- Term block (transcript-like on screen) ------------------------------ */
.term-block { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; overflow: hidden; }
.term-block-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; padding: 11px 16px; background: var(--blue-50); font-weight: 700; }
.term-block-head .figs { display: flex; gap: 16px; font-size: .88rem; }

/* ---- Charts --------------------------------------------------------------- */
.chart-box { position: relative; height: 300px; }
.chart-box.sm { height: 220px; }
.legend-list { list-style: none; padding: 0; margin: 0; font-size: .88rem; }
.legend-list li { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.legend-list li:last-child { border-bottom: 0; }
.legend-list .sw { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 10px; }
.legend-list .v { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---- Lists ---------------------------------------------------------------- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line); align-items: center; }
.feed li:last-child { border-bottom: 0; }
.feed .feed-main { flex: 1; min-width: 0; }
.feed .feed-title { font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed .feed-meta { color: var(--muted); font-size: .82rem; }
.date-tile { width: 46px; flex: 0 0 46px; text-align: center; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; line-height: 1.1; }
.date-tile b { display: block; font-size: 1.05rem; padding: 4px 0 2px; }
.date-tile small { display: block; background: var(--gold-50); color: #9a6a0c; font-size: .68rem; font-weight: 700; padding: 2px 0; }
.progress { height: 8px; border-radius: 6px; background: var(--slate-50); }
.progress-bar { background: var(--blue); }

/* ---- Marks / attendance grids -------------------------------------------- */
.grid-input { width: 82px; text-align: right; font-variant-numeric: tabular-nums; }
.grid-input.is-invalid { border-color: var(--red); background: var(--red-50); }
.att-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.att-toggle input { display: none; }
.att-toggle label { padding: 5px 11px; font-size: .82rem; font-weight: 700; cursor: pointer; color: var(--muted); border-left: 1px solid var(--line); }
.att-toggle label:first-of-type { border-left: 0; }
.att-toggle input:checked + label.p { background: var(--green-50); color: var(--green); }
.att-toggle input:checked + label.a { background: var(--red-50); color: var(--red); }
.att-toggle input:checked + label.l { background: var(--gold-50); color: #9a6a0c; }
.att-toggle input:checked + label.e { background: var(--violet-50); color: var(--violet); }
.sticky-actions { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding: 12px 20px; display: flex; gap: 10px; align-items: center; justify-content: flex-end; border-radius: 0 0 var(--radius-lg) var(--radius-lg); z-index: 5; }

/* ---- Timetable grid ------------------------------------------------------- */
.tt { display: grid; grid-template-columns: 70px repeat(var(--days, 6), minmax(140px, 1fr)); min-width: 900px; }
.tt-head { padding: 10px; font-weight: 700; font-size: .85rem; color: var(--muted); border-bottom: 1px solid var(--line); background: var(--surface-2); text-align: center; }
.tt-time { font-size: .76rem; color: var(--muted); text-align: right; padding: 4px 8px 0 0; border-right: 1px solid var(--line); }
.tt-col { position: relative; border-left: 1px solid var(--line); }
.tt-slot { border-bottom: 1px dashed var(--line); }
.tt-item {
  position: absolute; left: 4px; right: 4px; border-radius: 7px; padding: 6px 8px; font-size: .78rem; overflow: hidden;
  background: hsl(var(--hue, 220) 70% 95%); border-left: 3px solid hsl(var(--hue, 220) 60% 45%); color: hsl(var(--hue, 220) 45% 22%);
}
[data-bs-theme="dark"] .tt-item { background: hsl(var(--hue, 220) 30% 22%); color: hsl(var(--hue, 220) 70% 88%); }
.tt-item strong { display: block; font-size: .82rem; }
.tt-item .tt-del { position: absolute; top: 3px; right: 4px; opacity: 0; }
.tt-item:hover .tt-del { opacity: 1; }

/* ---- Notices -------------------------------------------------------------- */
.notice-card { padding: 18px 20px; border-bottom: 1px solid var(--line); }
.notice-card:last-child { border-bottom: 0; }
.notice-card h3 { font-size: 1.02rem; font-weight: 700; margin: 0 0 4px; }
.notice-card .body { color: var(--text); margin-top: 8px; white-space: pre-line; max-width: 80ch; }
.notice-card.urgent { border-left: 3px solid var(--red); }
.notice-card.important { border-left: 3px solid var(--gold); }

/* ---- Auth pages ----------------------------------------------------------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--surface); }
.auth-side {
  background: var(--ink); color: #dfe6f5; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden;
}
.auth-side::after {
  content: ''; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; border-radius: 50%;
  border: 56px solid rgba(226,169,59,.12);
}
.auth-side h1 { font-family: 'Source Serif 4', Georgia, serif; font-size: 2.6rem; line-height: 1.12; color: #fff; font-weight: 700; max-width: 16ch; }
.auth-side p { color: var(--ink-text); max-width: 44ch; font-size: 1.02rem; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-form form { width: 100%; max-width: 380px; }
.auth-form h2 { font-weight: 800; font-size: 1.5rem; margin-bottom: 4px; }
@media (max-width: 899.98px) { .auth { grid-template-columns: 1fr; } .auth-side { padding: 28px 24px; } .auth-side h1 { font-size: 1.8rem; } .auth-side::after { display: none; } }

/* ---- Misc ----------------------------------------------------------------- */
.flash { border-radius: var(--radius); border: 0; }
.alert-success { background: var(--green-50); color: var(--green); }
.alert-danger { background: var(--red-50); color: var(--red); }
.alert-warning { background: var(--gold-50); color: #855a06; }
.alert-info { background: var(--blue-50); color: var(--blue); }
[data-bs-theme="dark"] .alert-warning { color: var(--gold); }
.modal-content { border-radius: var(--radius-lg); border: 1px solid var(--line); background: var(--surface); }
.modal-header, .modal-footer { border-color: var(--line); }
.modal-title { font-weight: 700; font-size: 1.1rem; }
.dropdown-menu { border-color: var(--line); border-radius: var(--radius); background: var(--surface); }
.pagination { --bs-pagination-color: var(--text); --bs-pagination-bg: var(--surface); --bs-pagination-border-color: var(--line); --bs-pagination-active-bg: var(--blue); --bs-pagination-active-border-color: var(--blue); --bs-pagination-hover-bg: var(--surface-2); --bs-pagination-disabled-bg: var(--surface); }
.section-title { font-size: 1.05rem; font-weight: 700; margin: 0 0 12px; }
.kv-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: .92rem; }
.kv-row:last-child { border-bottom: 0; }
.kv-row span:first-child { color: var(--muted); }
.big-figure { font-size: 2rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.perm-group { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.perm-group h4 { font-size: .92rem; font-weight: 700; margin: 0 0 8px; display: flex; justify-content: space-between; }
.search-group h3 { font-size: .9rem; font-weight: 700; color: var(--muted); padding: 14px 20px 6px; margin: 0; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: .82rem; background: var(--surface); color: var(--text); }
@media print { .sidebar, .topbar, .foot, .page-actions, .filters, .no-print { display: none !important; } .content { padding: 0; } .panel { border: 0; } }

/* ---- SVG charts ----------------------------------------------------------- */
.chart-wrap { position: relative; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { stroke: var(--muted); stroke-width: 1; opacity: .5; }
.chart .tick { fill: var(--muted); font-size: 11px; font-family: 'Figtree', sans-serif; }
.chart path:hover, .chart circle:hover { opacity: .85; }
.chart .pt { fill: var(--surface); stroke-width: 2; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .84rem; color: var(--muted); margin-bottom: 8px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.donut-wrap { display: grid; grid-template-columns: 170px 1fr; gap: 20px; align-items: center; }
.donut { width: 170px; height: 170px; }
.donut-track { stroke: var(--slate-50); }
.donut-value { font-size: 26px; font-weight: 800; fill: var(--text); font-family: 'Figtree', sans-serif; }
.donut-label { font-size: 11px; fill: var(--muted); font-family: 'Figtree', sans-serif; }
@media (max-width: 575.98px) { .donut-wrap { grid-template-columns: 1fr; justify-items: center; } .donut-wrap .legend-list { width: 100%; } }
.hbars { list-style: none; margin: 0; padding: 0; }
.hbars li { padding: 7px 0; }
.hb-top { display: flex; justify-content: space-between; gap: 10px; font-size: .9rem; margin-bottom: 5px; }
.hb-top strong { font-variant-numeric: tabular-nums; }
.hb-track { height: 8px; border-radius: 6px; background: var(--slate-50); overflow: hidden; }
.hb-fill { height: 100%; border-radius: 6px; background: var(--blue); }
h1, h2, h3, h4, h5, h6 { color: var(--text); }
.dropdown-item.btn { justify-content: flex-start; font-weight: 400; border-radius: 0; width: 100%; padding: .4rem 1rem; }
.attention .feed li { padding: 11px 20px; }
.att-n { min-width: 42px; height: 30px; border-radius: 8px; display: inline-grid; place-items: center; font-weight: 800; font-size: .88rem; font-variant-numeric: tabular-nums; padding: 0 8px; }
.attention .feed-main:hover { color: var(--blue) !important; }
.cal td { padding: 6px; }
.cal .pill { font-size: .7rem; padding: 2px 6px; border-radius: 5px; text-align: left; }
.btn-light { background: var(--surface); color: var(--text); border-color: var(--line); background-image: none; }
.btn-light:hover { background: var(--surface-2); color: var(--text); border-color: var(--line); }
.btn-primary, .btn-outline-primary { background-image: none; }
@media (max-width: 575.98px) {
  .chart-wrap { overflow-x: auto; }
  .chart-wrap > .chart { min-width: 560px; }
  .page-head h1 { font-size: 1.35rem; }
  .profile-figures { width: 100%; }
  .profile-figures div { flex: 1; padding: 8px; }
}
.panel-body { container-type: inline-size; }
@container (max-width: 440px) {
  .donut-wrap { grid-template-columns: 1fr; justify-items: center; }
  .donut-wrap .legend-list { width: 100%; }
}

/* ---- Installable app: splash and install bar ------------------------------ */
#app-splash { display: none; }
#app-splash.show { position: fixed; inset: 0; z-index: 3000; background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; transition: opacity .4s ease; }
#app-splash.hide { opacity: 0; }
#app-splash img { width: 132px; height: 132px; object-fit: contain; animation: splash-in .6s ease both; }
#app-splash .splash-mark { width: 120px; height: 120px; border-radius: 28px; background: var(--gold); color: var(--ink); display: grid; place-items: center; font-weight: 800; font-size: 1.8rem; animation: splash-in .6s ease both; }
#app-splash strong { font-size: 1.35rem; font-weight: 800; color: #123F35; letter-spacing: .01em; }
#app-splash small { color: #687185; font-size: .9rem; }
@keyframes splash-in { from { transform: scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { #app-splash img, #app-splash .splash-mark { animation: none; } }
#install-bar { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 2000; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px;
  background: var(--ink); color: #fff; box-shadow: 0 10px 30px rgba(9,15,30,.3); max-width: 520px; margin: 0 auto; }
#install-bar[hidden] { display: none; }
#install-bar .ib-text { flex: 1; min-width: 0; line-height: 1.3; }
#install-bar .ib-text strong { display: block; }
#install-bar .ib-text span { font-size: .84rem; color: var(--ink-text); }
#install-bar .ib-close { background: none; border: 0; color: var(--ink-text); font-size: 1.5rem; line-height: 1; padding: 0 4px; }
@media (display-mode: standalone) { .topbar { padding-top: env(safe-area-inset-top); height: calc(64px + env(safe-area-inset-top)); } }

/* =============================================================================
   BDPH additions
   ========================================================================== */
.top-title { font-weight: 700; font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lang-btn { width: auto; padding: 0 10px; gap: 6px; display: inline-flex; align-items: center; font-weight: 700; font-size: .78rem; }
.dropdown-item.active, .dropdown-item:active { background: var(--blue); }
.d-sm-inline-grid { display: none; }
@media (min-width: 576px) { .d-sm-inline-grid { display: inline-grid !important; } }

/* Project cards */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.project-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; display: flex; flex-direction: column; color: var(--text); transition: border-color .15s, transform .15s; }
.project-card:hover { border-color: var(--blue); color: var(--text); }
.project-card .pc-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.project-card h3 { font-size: 1.02rem; font-weight: 700; margin: 0; line-height: 1.3; }
.project-card .pc-meta { color: var(--muted); font-size: .84rem; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.project-card .pc-foot { margin-top: auto; padding-top: 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.project-cover { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; background: var(--surface-2); }
.cover-blank { display: grid; place-items: center; background: linear-gradient(135deg, hsl(var(--hue) 38% 88%), hsl(calc(var(--hue) + 40) 40% 80%)); color: hsl(var(--hue) 35% 32%); font-size: 2.2rem; }
[data-bs-theme="dark"] .cover-blank { background: linear-gradient(135deg, hsl(var(--hue) 25% 22%), hsl(calc(var(--hue) + 40) 25% 16%)); color: hsl(var(--hue) 40% 70%); }
.project-hero { border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--line); margin-bottom: 16px; }
.project-hero .project-cover { aspect-ratio: 21 / 8; }

.progress { height: 8px; background: var(--slate-50); border-radius: 99px; }
.progress .progress-bar { background: var(--blue); border-radius: 99px; }
.progress.lg { height: 12px; }
.phase-list { list-style: none; margin: 0; padding: 0; }
.phase-list li { display: grid; grid-template-columns: 34px 1fr 64px; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.phase-list li:last-child { border-bottom: 0; }
.phase-no { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--slate-50); color: var(--muted); font-weight: 800; font-size: .85rem; }
.phase-list li.done .phase-no { background: var(--green); color: #fff; }
.phase-list li.doing .phase-no { background: var(--gold); color: #fff; }
.phase-list .pct { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Timeline (status history, progress updates, complaint thread) */
.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 18px 16px; }
.timeline li::before { content: ''; position: absolute; left: -25px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 3px solid var(--blue); }
.timeline li.muted::before { border-color: var(--line); }
.timeline .tl-time { color: var(--muted); font-size: .8rem; }
.timeline .tl-title { font-weight: 700; }
.timeline img { max-width: 100%; border-radius: var(--radius); margin-top: 8px; }

/* Selection and ranked ballot */
.choice-card { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.choice-card.on { border-color: var(--blue); background: var(--blue-50); }
.choice-card .cc-main { flex: 1; min-width: 0; }
.choice-card h3 { font-size: 1rem; font-weight: 700; margin: 0 0 2px; }
.choice-list { display: grid; gap: 10px; }
.counter-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 99px; background: var(--blue-50); color: var(--blue); font-weight: 700; }
.ballot-row { display: grid; grid-template-columns: 112px 1fr; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.ballot-row:last-child { border-bottom: 0; }
.prio-tag { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; border-radius: var(--radius); padding: 8px; font-weight: 800; line-height: 1.1; background: var(--slate-50); }
.prio-tag small { font-weight: 600; font-size: .72rem; color: var(--muted); }
.prio-1 { background: #177B62; color: #fff; } .prio-1 small { color: #d2eee4; }
.prio-2 { background: #BC8B33; color: #fff; } .prio-2 small { color: #f6e7c9; }
.prio-3 { background: #E9C985; color: #3a2a06; }
.prio-4 { background: var(--slate-50); }
.receipt-box { text-align: center; padding: 28px 16px; }
.receipt-box .code { font-size: 2rem; font-weight: 800; letter-spacing: .12em; font-variant-numeric: tabular-nums; }
.rank-no { width: 36px; height: 36px; border-radius: 10px; display: inline-grid; place-items: center; font-weight: 800; background: var(--slate-50); }
.rank-no.r1 { background: #177B62; color: #fff; } .rank-no.r2 { background: #BC8B33; color: #fff; } .rank-no.r3 { background: #E9C985; color: #3a2a06; }

.welcome { background: linear-gradient(120deg, var(--ink), var(--ink-2)); color: #fff; border-radius: var(--radius-lg); padding: 22px 22px; margin-bottom: 18px; position: relative; overflow: hidden; }
.welcome h1 { font-size: 1.45rem; font-weight: 800; margin: 0 0 4px; }
.welcome p { color: var(--ink-text); margin: 0; }
.welcome .btn-gold { margin-top: 14px; }
.cta-card { display: flex; gap: 14px; align-items: center; padding: 16px; border-radius: var(--radius-lg); border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.cta-card:hover { border-color: var(--blue); color: var(--text); }
.cta-card .cta-icon { width: 46px; height: 46px; flex: 0 0 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.35rem; background: var(--blue-50); color: var(--blue); }
.cta-card.gold .cta-icon { background: var(--gold-50); color: #9a6f1f; }
.yswd { border-left: 4px solid var(--gold); padding: 12px 16px; background: var(--surface); border-radius: 0 var(--radius) var(--radius) 0; margin-bottom: 12px; }
.yswd .yswd-label { font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.notif { display: flex; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); color: var(--text); }
.notif:hover { background: var(--surface-2); color: var(--text); }
.notif.unread { background: var(--blue-50); }
.notif .n-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--blue); margin-top: 7px; flex: 0 0 9px; }
.notif:not(.unread) .n-dot { background: transparent; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.photo-grid img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--line); }
.loc-cascade { display: grid; gap: 10px; }

/* Resident bottom tab bar (phones) */
.tabbar { display: none; }
@media (max-width: 991.98px) {
  body.is-resident .content { padding-bottom: 92px; }
  body.is-resident .foot { display: none; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
    background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: .7rem; font-weight: 600; padding: 4px 0; }
  .tabbar a .bi { font-size: 1.25rem; }
  .tabbar a.on { color: var(--blue); }
  body.is-resident #install-bar { bottom: calc(70px + env(safe-area-inset-bottom)); }
}
@media (max-width: 575.98px) {
  .content { padding: 16px; }
  .ballot-row { grid-template-columns: 1fr; gap: 6px; }
  .prio-tag { flex-direction: row; gap: 8px; justify-content: flex-start; }
}

ul.tabs { list-style: none; margin-left: 0; }
ul.tabs li { display: contents; }
.welcome h1 { color: #fff; }
@media (max-width: 767.98px) {
  body.is-resident .stat-strip { grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); }
  body.is-resident .stat { padding: 12px 10px; border-left: 1px solid var(--line); border-top: 0; }
  body.is-resident .stat:first-child { border-left: 0; }
  body.is-resident .stat-icon { display: none; }
  body.is-resident .stat-value { font-size: 1.3rem; }
  body.is-resident .stat-label { font-size: .78rem; }
}
