/* astro-saas — tharusikuru palette, Sinhala-first typography.
   Pure CSS, no framework, no build step. */

:root {
  --burgundy:        #7c1b1f;
  --burgundy-soft:   #a44a4d;
  --burgundy-faint:  #d8b7b8;
  --cream:           #f4e5c0;
  --cream-light:     #fbf3dc;
  --cream-warm:      #f9eac8;
  --saffron:         #f2c730;
  --saffron-soft:    #fae39a;
  --terracotta:      #d97c1f;
  --terracotta-soft: #f0c399;
  --ink:             #4a1416;
  --ink-soft:        #7a4a4c;
  --ink-faint:       #b89a90;
  --line:            #e3cf9f;
  --panel:           #fffdf7;
  --bg:              #f4e2af;
  --shadow:          0 12px 32px -14px rgba(124, 27, 31, 0.22);
  --shadow-soft:     0 6px 18px -8px rgba(124, 27, 31, 0.16);
  --radius:          14px;
  --radius-sm:       8px;
  --font-body:       'Noto Serif Sinhala', 'Cormorant Garamond', Georgia, serif;
  --font-ui:         'Noto Sans Sinhala', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  /* Lock the document to viewport height so the browser scrollbar never
     appears. Any long content scrolls *inside* <main> below. The header,
     top-nav and language switcher stay anchored at the top of the
     viewport regardless of how long the page body is.
     `100dvh` (dynamic viewport) accounts for the mobile browser chrome
     showing/hiding; fall back to `100vh` for older browsers. */
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

h1, h2, h3, h4 {
  font-family: var(--font-body);
  font-weight: 500;
  color: var(--burgundy);
  margin: 0 0 0.5em;
}
h1 { font-size: 2rem; font-weight: 500; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; color: var(--burgundy-soft); }
h4 { font-size: 1rem; color: var(--ink-soft); }

a {
  color: var(--burgundy);
  text-decoration: none;
  border-bottom: 1px solid var(--terracotta-soft);
}
a:hover { color: var(--terracotta); border-bottom-color: transparent; }

/* ── header / shell ─────────────────────────────────────────────────── */

.shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.6rem;
  background: var(--cream-light);
  border-bottom: 1px solid var(--line);
  font-family: var(--font-ui);
  flex-shrink: 0;
  /* Anchor so the mobile .topnav.is-open dropdown (position:absolute)
     positions against the header bar, not the viewport. */
  position: relative;
}
.brand-row { display: flex; align-items: center; gap: 0.7rem; border: none; }
.brand-row strong { color: var(--burgundy); font-weight: 600; font-size: 1.05rem; }
.brand-row .brand-tld { color: var(--terracotta); font-weight: 600; }
.brand-row .tagline { color: var(--ink-soft); font-size: 0.85rem; margin-left: 0.5rem; }
.session-badge {
  background: var(--saffron);
  color: var(--ink);
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-family: var(--font-ui);
  margin-left: 0.8rem;
}

.topnav { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.topnav a {
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-sm);
  border: none;
  color: var(--ink-soft);
  font-family: var(--font-ui);
  font-size: 0.95rem;
}
.topnav a.active, .topnav a:hover {
  background: var(--cream-warm);
  color: var(--burgundy);
}
/* Primary "create free account" CTA in the guest nav. Needs higher specificity
   than `.topnav a` / `.topnav a:hover` (which would otherwise force dark ink
   text onto the burgundy button, making it illegible). */
.topnav a.nav-cta {
  background: var(--burgundy);
  color: #fff;
  font-weight: 600;
  padding: 0.4rem 0.95rem;
}
.topnav a.nav-cta:hover {
  background: var(--terracotta);
  color: #fff;
}

/* Nav dropdown — groups the client-workflow items (සේවාලාභීන් · සජීවී සැසිය ·
   පලාපල · ඉන්වොයිස්). Native <details> so it works on tap + click. */
.nav-dd { position: relative; }
.nav-dd > summary {
  list-style: none; cursor: pointer;
  padding: 0.4rem 0.85rem; border-radius: var(--radius-sm);
  color: var(--ink-soft); font-family: var(--font-ui); font-size: 0.95rem;
  display: inline-flex; align-items: center; gap: 0.3rem;
}
.nav-dd > summary::-webkit-details-marker { display: none; }
.nav-dd[open] > summary, .nav-dd.is-active > summary, .nav-dd > summary:hover {
  background: var(--cream-warm); color: var(--burgundy);
}
.nav-dd-caret { font-size: 0.6rem; opacity: 0.75; }
.nav-dd-menu {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 30;
  min-width: 12rem; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow); padding: 0.3rem;
  display: flex; flex-direction: column; gap: 2px;
}
.nav-dd-menu a {
  padding: 0.5rem 0.7rem; border-radius: 6px; white-space: nowrap; border: none;
  color: var(--ink-soft); font-family: var(--font-ui); font-size: 0.95rem;
}
.nav-dd-menu a.active, .nav-dd-menu a:hover { background: var(--cream-warm); color: var(--burgundy); }

/* ── main ─────────────────────────────────────────────────────────── */

main {
  /* The flex-1 region that consumes whatever vertical space remains
     under the locked chrome. Long page bodies scroll INSIDE this
     element; the browser window itself never gets a scrollbar.
     Uses a 3-column grid so every top-level child lives in the middle
     1180px-max column without us having to override per-component
     margins (which the old per-element approach was fighting). */
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: grid;
  grid-template-columns: minmax(1.6rem, 1fr) min(1180px, 100% - 3.2rem) minmax(1.6rem, 1fr);
  align-content: start;
  padding: 1.6rem 0 4rem;
  row-gap: 0;
}
main > * { grid-column: 2; }
main > .page-title:first-child { margin-top: 0; }

.page-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.2rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.6rem;
}
.page-title h1 { margin: 0; }
.muted { color: var(--ink-soft); font-size: 0.95rem; }

/* ── panels / cards ───────────────────────────────────────────────── */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem;
  box-shadow: var(--shadow-soft);
  margin-bottom: 1.2rem;
}
.panel + .panel { margin-top: 0; }
.panel h2 { margin-top: 0; }

/* Admin stat-card row — 4 across on desktop, 2 on phones (a media query can't
   override an inline grid-template, so this lives as a class). */
.admin-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.8rem; margin-bottom: 1rem; }
@media (max-width: 640px) { .admin-stats { grid-template-columns: 1fr 1fr; } }

.grid { display: grid; gap: 1rem; margin-bottom: 1.2rem; }
.grid:last-child { margin-bottom: 0; }
.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)); }
@media (max-width: 720px) {
  .grid.two, .grid.three, .grid.four { grid-template-columns: 1fr; }
}

.tile {
  background: var(--cream-light);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  font-family: var(--font-ui);
  display: block;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  transition: transform 0.15s, box-shadow 0.15s;
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.tile .label { font-size: 1rem; color: var(--burgundy); font-weight: 500; }
.tile .desc  { font-size: 0.85rem; color: var(--ink-soft); margin-top: 0.3rem; }

/* Tile with illustration — Replicate-generated palm-leaf-manuscript icons.
   The thumbnail sits centered above the label and gets a gentle desaturation
   so it reads as supporting art rather than competing with the burgundy text. */
.tile-figure {
  display: block;
  width: 84px;
  height: 84px;
  margin: 0.2rem auto 0.5rem;
  border-radius: 50%;
  background: var(--cream-warm);
  border: 1px solid rgba(124, 27, 31, 0.10);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, border-color 0.2s;
}
.tile-figure img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.85) contrast(1.02);
  transition: transform 0.3s, filter 0.3s;
}
.tile:hover .tile-figure {
  border-color: rgba(124, 27, 31, 0.35);
}
.tile:hover .tile-figure img {
  transform: scale(1.06);
  filter: saturate(1) contrast(1.04);
}
.tile.has-figure {
  text-align: center;
  padding-top: 1.2rem;
}
.tile.has-figure .label { font-size: 1.02rem; }
.tile.has-figure .desc  { font-size: 0.82rem; line-height: 1.5; }


/* ── form ─────────────────────────────────────────────────────────── */

form .row { display: grid; gap: 0.4rem; margin-bottom: 0.95rem; }
form label {
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink);
}
form input:not([type=checkbox]):not([type=radio]), form select, form textarea {
  font-family: var(--font-body);
  font-size: 1.02rem;
  padding: 0.65rem 0.8rem;
  min-height: 46px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: white;
  color: var(--ink);
  width: 100%;
}
/* Checkboxes/radios must NOT get the full-width box sizing above — keep them
   compact and themed so multi-select groups (e.g. report types) align tidily. */
form input[type=checkbox], form input[type=radio] {
  width: 1.2rem; height: 1.2rem;
  min-height: 0; flex: 0 0 auto;
  margin: 0; padding: 0;
  accent-color: var(--burgundy);
  cursor: pointer;
}
form textarea { resize: vertical; min-height: 80px; }
form input:focus, form select:focus, form textarea:focus {
  outline: none;
  border-color: var(--terracotta);
  box-shadow: 0 0 0 3px rgba(217, 124, 31, 0.35);
}
form .inline { display: flex; gap: 0.7rem; }
form .inline > * { flex: 1; }

/* ── time picker ──────────────────────────────────────────────────── */
.time-pick {
  display: grid;
  grid-template-columns: 1fr 1fr 1.3fr;
  gap: 0.5rem;
  align-items: stretch;
}
.time-pick select {
  width: 100%;
}

/* custom yyyy/mm/dd date picker (year · month · day selects), built by
   astro-form.js to replace native <input type=date> so the format is
   consistent and old birth-years are easy to pick. */
.date-pick {
  display: grid;
  grid-template-columns: 1fr 0.95fr 1.6fr 0.8fr; /* year · era · month(name) · day */
  gap: 0.5rem;
  align-items: stretch;
}
.date-pick select,
.date-pick input.dp-year { width: 100%; }

/* workdesk tool-group sub-headings */
.tool-group-h {
  font-family: var(--font-ui);
  font-size: 0.95rem;
  color: var(--ink-soft);
  margin: 1.1rem 0 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--line);
}
.tool-group-h:first-of-type { margin-top: 0.3rem; }

/* ── chart workbench (varga tabs, dense tables, panels) ─────────── */
.varga-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.5rem 0;
}
.varga-tab {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--burgundy-faint);
  border-radius: var(--radius-sm);
  background: white;
  color: var(--burgundy);
  text-decoration: none;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  min-width: 3.5rem;
  line-height: 1.2;
  transition: background 0.1s, color 0.1s;
}
.varga-tab .d-key   { font-weight: 600; font-size: 0.85rem; }
.varga-tab .d-name  { font-size: 0.72rem; color: var(--ink-soft); margin-top: 0.1rem; }
.varga-tab:hover    { background: var(--cream-warm); }
.varga-tab.active {
  background: var(--burgundy);
  color: white;
}
.varga-tab.active .d-name { color: rgba(255,255,255,0.85); }

table.list.compact th,
table.list.compact td {
  padding: 0.3rem 0.5rem;
  font-size: 0.88rem;
}
table.list.ashtaka td,
table.list.ashtaka th {
  text-align: center;
  font-variant-numeric: tabular-nums;
}
table.list.ashtaka td:first-child,
table.list.ashtaka th:first-child {
  text-align: left;
}

details.panel > summary {
  cursor: pointer;
  list-style: revert;
  margin-bottom: 0.5rem;
}
details.panel > summary h3 {
  margin: 0 0 0 0.3rem;
}
details.panel[open] > summary {
  margin-bottom: 1rem;
}

/* ── place picker (typeahead → /api/places) ──────────────────────── */
.place-pick { position: relative; }
.place-pick .place-q { width: 100%; }
.place-pick .place-meta {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.82rem;
  color: var(--ink-soft);
  min-height: 1.1em;
}
.place-list {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 0.2rem 0;
  list-style: none;
  max-height: 14rem;
  overflow-y: auto;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: 0 6px 18px rgba(0,0,0,0.10);
  z-index: 20;
}
.place-item {
  padding: 0.45rem 0.7rem;
  cursor: pointer;
  font-size: 0.95rem;
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  align-items: baseline;
}
.place-item:hover,
.place-item.is-active { background: var(--cream-warm); }
.place-item .place-country { font-size: 0.78rem; }
.place-item.is-loading,
.place-item.is-empty {
  color: var(--ink-soft);
  cursor: default;
  font-style: italic;
}

button, .btn {
  display: inline-block;
  font-family: var(--font-ui);
  font-size: 1rem;
  padding: 0.62rem 1.25rem;
  border: 1px solid var(--burgundy);
  background: var(--burgundy);
  color: white;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, box-shadow 0.15s;
}
/* Keep white text on hover — beats the global a:hover terracotta color, which
   would otherwise match the terracotta hover background and hide the label on
   anchor buttons (<a class="btn">). */
button:hover, .btn:hover { background: var(--terracotta); border-color: var(--terracotta); color: #fff; }
button:focus-visible, .btn:focus-visible,
a:focus-visible { outline: 3px solid var(--saffron); outline-offset: 2px; }
button.ghost, .btn.ghost {
  background: transparent;
  color: var(--burgundy);
  border-color: var(--burgundy-faint);
}
button.ghost:hover, .btn.ghost:hover {
  background: var(--cream-warm);
  color: var(--burgundy);
  border-color: var(--burgundy);
}
button.danger, .btn.danger {
  background: transparent; color: var(--burgundy); border-color: var(--burgundy-faint);
}
button.danger:hover, .btn.danger:hover {
  background: #c63840; color: white; border-color: #c63840;
}
.action-row { display: flex; gap: 0.6rem; margin-top: 1rem; flex-wrap: wrap; }

.alert {
  border: 1px solid var(--burgundy-faint);
  background: rgba(216,183,184,0.3);
  color: var(--burgundy);
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-family: var(--font-ui);
}
.alert.success { border-color: #b6c79d; background: rgba(182,199,157,0.25); color: #4f6b2f; }

/* ── table ────────────────────────────────────────────────────────── */

table.list {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-ui);
  font-size: 0.95rem;
}
table.list th, table.list td {
  text-align: left;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--line);
}
table.list th { color: var(--ink-soft); font-weight: 500; background: var(--cream-warm); }
table.list tr:hover td { background: rgba(244,229,192,0.4); }
table.list a { border-bottom: none; }

/* On narrow screens, dense workbench tables (shadbala, ashtakavarga,
   ephemeris, KP, dasha) would overflow the panel. Making the table its own
   block box gives it a horizontal scrollbar instead of breaking the layout. */
@media (max-width: 760px) {
  table.list {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  table.list th, table.list td { white-space: nowrap; }
}

/* ── chart diagram (north-indian style, simplified) ───────────────── */

.kundli-south {
  max-width: 380px;
  margin: 0 auto;
  color: var(--ink);
}
.kundli-south svg { width: 100%; height: auto; display: block; }

.kundli {
  width: 320px;
  max-width: 100%;
  aspect-ratio: 1 / 1;
  font-family: var(--font-ui);
  font-size: 0.88rem;
  background: var(--cream-light);
  position: relative;
  border: 1.5px solid var(--burgundy);
}
.kundli svg { width: 100%; height: 100%; }
/* Font sizes are in SVG user units (viewBox is 0 0 100 100, so ~3.2× the
   on-screen px at the default 320px width). Keep them small or the Sinhala
   labels overflow and overlap their cells. */
.kundli text {
  font-family: var(--font-ui);
  font-size: 3.4px;
  fill: var(--ink);
}
.kundli .houseNum { fill: var(--burgundy-soft); font-size: 2.6px; }
.kundli .signLbl  { fill: var(--terracotta); font-size: 3.2px; font-weight: 600; }
.kundli .planets-cell { fill: var(--ink); font-size: 3.5px; font-weight: 500; }

/* ── wizard / stepper ─────────────────────────────────────────────── */

.stepper {
  display: flex;
  gap: 0.4rem;
  margin: 0 0 1.5rem;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  flex-wrap: wrap;
}
.stepper .step {
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--cream-light);
  color: var(--ink-soft);
}
.stepper .step.done { background: var(--saffron-soft); color: var(--burgundy); }
.stepper .step.active { background: var(--burgundy); color: white; border-color: var(--burgundy); }

/* ── concern chips ──────────────────────────────────────────────── */

.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chips label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: background 0.15s;
}
.chips label:has(input:checked) {
  background: var(--saffron-soft);
  border-color: var(--terracotta);
  color: var(--burgundy);
}
.chips input { display: none; }

/* ── calendar grid ────────────────────────────────────────────────── */

.cal-month {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--line);
  font-family: var(--font-ui);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.cal-month .day-name {
  background: var(--cream-warm);
  text-align: center;
  padding: 0.4rem;
  font-weight: 500;
  color: var(--ink-soft);
}
.cal-month .day {
  background: var(--cream-light);
  min-height: 92px;
  padding: 0.35rem 0.5rem;
  font-size: 0.9rem;
  position: relative;
}
.cal-month .day.other { background: var(--cream); color: var(--ink-faint); }
.cal-month .day.today { background: var(--saffron-soft); }
.cal-month .day .num { font-weight: 600; color: var(--burgundy); }
.cal-month .day .appt {
  display: block;
  font-size: 0.78rem;
  background: var(--burgundy-faint);
  color: var(--burgundy);
  border-radius: 4px;
  padding: 1px 6px;
  margin-top: 3px;
  text-decoration: none;
  border: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cal-month .day .appt.deadline { background: rgba(217,124,31,0.3); }
.cal-month .day .appt.muhurta  { background: var(--saffron); }

.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.9rem;
  font-family: var(--font-ui);
}

/* ── reading & invoice ─────────────────────────────────────────── */

.kv { display: grid; grid-template-columns: 12rem 1fr; gap: 0.4rem 1rem; font-family: var(--font-ui); }
.kv dt { color: var(--ink-soft); }
.kv dd { margin: 0; color: var(--ink); }

.status-pill {
  display: inline-block;
  padding: 0.18rem 0.7rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-family: var(--font-ui);
  background: var(--cream-warm);
  color: var(--ink-soft);
}
.status-pill.draft   { background: var(--cream-warm); color: var(--ink-soft); }
.status-pill.issued  { background: var(--terracotta-soft); color: var(--burgundy); }
.status-pill.paid    { background: #c8e0a8; color: #4f6b2f; }

/* ── small helpers ─────────────────────────────────────────────── */

.split { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.split > .col { flex: 1; min-width: 280px; }
.tight { margin: 0; padding: 0; list-style: none; }
.tight li { padding: 0.3rem 0; border-bottom: 1px dashed var(--line); }
.tight li:last-child { border-bottom: none; }

/* ── CRM 360° view: tag strip + alerts ───────────────────────── */

.tag-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 1rem;
  font-family: var(--font-ui);
}
.tag {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.7rem;
  border-radius: 999px;
  font-size: 0.82rem;
  border: 1px solid var(--line);
  background: var(--cream-light);
  color: var(--ink-soft);
}
.tag-lagna    { background: var(--cream-warm);     color: var(--burgundy); border-color: var(--burgundy-faint); }
.tag-dasha    { background: var(--saffron-soft);   color: #8a6612; border-color: var(--saffron); }
.tag-warning  { background: #f6cfc2;               color: #8a2a1f; border-color: #d97c1f; }
.tag-stage    { background: var(--terracotta-soft); color: var(--burgundy); }
.tag-demo     { background: #e8e3d3;               color: var(--ink-soft); }

.alerts-panel { border-left: 3px solid var(--terracotta); }
.alerts-list { list-style: none; padding: 0; margin: 0; font-family: var(--font-ui); }
.alert-item {
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.4rem;
  background: var(--cream-light);
  border-left: 3px solid var(--line);
}
.alert-item .muted { font-size: 0.85rem; }
.alert-item.alert-info     { border-left-color: var(--saffron); }
.alert-item.alert-warn     { border-left-color: var(--terracotta); background: #fce8d6; }
.alert-item.alert-critical { border-left-color: #a8423e; background: #f6d5cf; color: #5e1a1d; }

.btn-small { padding: 0.25rem 0.7rem; font-size: 0.85rem; }

/* Customer list filter chips */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.6rem 0 1rem;
  font-family: var(--font-ui);
}
.filter-chips a {
  display: inline-block;
  padding: 0.25rem 0.8rem;
  border-radius: 999px;
  font-size: 0.85rem;
  border: 1px solid var(--line);
  background: var(--cream-light);
  color: var(--ink-soft);
  text-decoration: none;
}
.filter-chips a.active {
  background: var(--burgundy);
  color: var(--cream-light);
  border-color: var(--burgundy);
}
.filter-chips a:hover { border-color: var(--burgundy-soft); color: var(--burgundy); }

/* Alert badge on a list row */
.row-badge {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.row-badge.warn     { background: var(--terracotta); }
.row-badge.critical { background: #a8423e; }
.row-badge.info     { background: var(--saffron); }

/* Sortable column-header links */
table.list th a { color: var(--burgundy-soft); cursor: pointer; }
table.list th a:hover { color: var(--burgundy); }

/* Dashboard money-at-a-glance stat cards */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.7rem;
  margin-bottom: 1rem;
}
.stat-card {
  display: block;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  text-decoration: none;
  color: inherit;
}
a.stat-card:hover { border-color: var(--burgundy-soft); }
.stat-card.accent { background: var(--burgundy); border-color: var(--burgundy); }
.stat-card.accent .stat-label,
.stat-card.accent .stat-value { color: var(--cream-light); }
.stat-card.warn { border-color: var(--terracotta); }
.stat-label {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin-bottom: 0.25rem;
}
.stat-value {
  font-family: var(--font-ui);
  font-size: 1.45rem;
  font-weight: 600;
  color: var(--burgundy);
  line-height: 1.1;
}
.stat-sub { font-family: var(--font-ui); font-size: 0.78rem; margin-top: 0.2rem; }
@media (max-width: 720px) {
  .stat-cards { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
  .stat-card { padding: 0.6rem 0.7rem; }
  .stat-value { font-size: 1.2rem; }
}

/* List pagination */
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin: 0.9rem 0 0.4rem;
  font-family: var(--font-ui);
  font-size: 0.88rem;
}
.pager-btn, .pager-num {
  display: inline-block;
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--cream-light);
  color: var(--ink-soft);
  text-decoration: none;
}
.pager-num.active {
  background: var(--burgundy);
  color: var(--cream-light);
  border-color: var(--burgundy);
  font-weight: 600;
}
.pager-btn:hover:not(.disabled),
.pager-num:hover:not(.active) {
  border-color: var(--burgundy-soft);
  color: var(--burgundy);
}
.pager-btn.disabled { opacity: 0.45; cursor: default; }
.pager-gap { padding: 0 0.2rem; color: var(--ink-faint); }
.pager-info { margin-left: auto; }

/* ── header-aux (greeting + language switcher row) ───────────── */
.header-aux {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.4rem 1.5rem 0.5rem;
  background: var(--cream-light);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  font-family: var(--font-ui);
  flex-wrap: wrap;
}
.header-greet {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.92rem;
  color: var(--ink-soft);
}
.header-greet-msg strong { color: var(--burgundy); font-weight: 500; }
.header-greet-biz { font-size: 0.85rem; }
.ll-lang-switcher {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.7rem;
  background: white;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: 'Noto Sans Sinhala', 'Noto Sans Tamil', system-ui, sans-serif;
  font-size: 0.82rem;
}
.ll-lang-switcher .ll-lang-icon { font-size: 0.95rem; }
.ll-lang-switcher .ll-lang-btn {
  display: inline-block;
  padding: 0.12rem 0.65rem;
  border-radius: 999px;
  font-size: 0.82rem;
  text-decoration: none;
  color: var(--burgundy);
  border-bottom: 0;
  transition: all 0.15s;
}
.ll-lang-switcher .ll-lang-btn:hover { background: var(--cream-warm); }
.ll-lang-switcher .ll-lang-btn.is-active {
  background: var(--burgundy);
  color: var(--cream-light);
  font-weight: 500;
}

/* ── Print-mode escape from internal-scroll ───────────────────────
   PDF surfaces (Janma Patraya, Yearly Outlook) need the body to be a
   normal scrolling document so the page-break-after rules in their own
   styles work and so the printer/print preview can paginate. */
@media print {
  html, body, .shell { height: auto !important; overflow: visible !important; }
  main { overflow: visible !important; max-height: none !important; flex: none !important; padding: 0 !important; }
  .site-header, .header-aux, .taskbar, .topnav, .no-print { display: none !important; }
  /* Keep on-brand colours (verdict panels, chart cells) in the printout. */
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  /* Panels become clean bordered blocks that don't split across pages. */
  .panel { box-shadow: none !important; border: 1px solid #c9bfa8 !important; break-inside: avoid; page-break-inside: avoid; margin: 0 0 0.5rem !important; }
  details.panel { display: block !important; }
  details > summary { list-style: none; }
  details > summary h3 .learn-link { display: none !important; }
  .page-title { border: none !important; }
  .page-title .btn { display: none !important; }
  /* Size the rasi/navamsa diagrams sensibly for paper. */
  .kundli, .kundli-north, .kundli-south { max-width: 8cm !important; margin: 0 auto !important; }
  .kundli svg, .kundli-north svg, .kundli-south svg { width: 100% !important; height: auto !important; }
  .print-only { display: block !important; }
  @page { size: A4; margin: 1.2cm; }
}
.print-only { display: none; }

/* ── Custom scrollbar (subtle, on-brand) ─────────────────────────── */
main { scrollbar-width: thin; scrollbar-color: var(--burgundy-faint) transparent; }
main::-webkit-scrollbar { width: 9px; }
main::-webkit-scrollbar-track { background: transparent; }
main::-webkit-scrollbar-thumb {
  background: var(--burgundy-faint);
  border-radius: 5px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
main::-webkit-scrollbar-thumb:hover { background: var(--burgundy-soft); background-clip: padding-box; }

/* ── Status taskbar (sticky bottom of the shell) ─────────────── */
.taskbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 1rem;
  padding: 0.5rem 1.2rem;
  background: var(--burgundy);
  color: var(--cream-light);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  border-top: 1px solid rgba(0,0,0,0.2);
}
/* "Manual" launch button — right-aligned on the footer (the rest of the bar
   sits left); stacks normally inside the column layout on phones. */
.tb-manual { margin-left: auto; white-space: nowrap; }
.tb-left, .tb-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: nowrap;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tb-sep { opacity: 0.45; }
.tb-date, .tb-nak, .tb-sun { letter-spacing: 0.01em; }
.tb-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 0.2rem;
}
.tb-dot-ok { background: #8cce82; box-shadow: 0 0 0 2px rgba(140, 206, 130, 0.25); }
.tb-dot-down { background: #f08080; box-shadow: 0 0 0 2px rgba(240, 128, 128, 0.25); }

.tb-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.18rem 0.65rem;
  background: rgba(255,255,255,0.12);
  border-radius: 999px;
  color: var(--cream-light);
  text-decoration: none;
  border: 1px solid rgba(255,255,255,0.18);
  font-size: 0.8rem;
  transition: background 0.15s;
}
.tb-chip:hover { background: rgba(255,255,255,0.22); color: var(--cream-light); }
.tb-chip .tb-count {
  background: var(--saffron);
  color: var(--ink);
  border-radius: 999px;
  padding: 0 0.4rem;
  font-weight: 600;
  font-size: 0.78rem;
  min-width: 18px;
  text-align: center;
}
.tb-chip-warn .tb-count { background: var(--terracotta); color: var(--cream-light); }
.tb-chip-primary {
  background: var(--saffron);
  color: var(--burgundy);
  border-color: var(--saffron);
  font-weight: 500;
}
.tb-chip-primary:hover { background: var(--terracotta); color: var(--cream-light); border-color: var(--terracotta); }
.tb-chip-primary .tb-plus { font-weight: 600; font-size: 1rem; line-height: 1; }

/* ── Dashboard — compact tiles to fit on a single screen ───────
   The top two-column tiles (Start Session, New Customer) used to
   dominate the viewport. Shrink them so the quick-tools grid + the
   alerts panel fit within one screen-height.

   Layout: 2 columns × 2 rows grid. Figure spans both rows on the
   left; label sits top-right, desc below label. This keeps the
   compact horizontal form without the desc falling under the figure
   like a naive 2-column setup. */
.tile.has-figure {
  padding: 0.55rem 0.7rem;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 0.65rem;
  row-gap: 0.05rem;
  text-align: left;
  align-items: center;
}
.tile.has-figure .tile-figure {
  width: 44px; height: 44px;
  margin: 0;
  grid-column: 1;
  grid-row: 1 / span 2;
  align-self: center;
}
.tile.has-figure .label {
  grid-column: 2;
  grid-row: 1;
  align-self: end;
  font-size: 0.93rem !important;
  margin: 0;
  line-height: 1.2;
}
.tile.has-figure .desc {
  grid-column: 2;
  grid-row: 2;
  align-self: start;
  font-size: 0.74rem;
  line-height: 1.32;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* Top hero pair (Start Session, New Customer) — slightly larger than
   the quick-tools grid for visual emphasis. */
main > .grid.two:first-of-type .tile.has-figure {
  padding: 0.75rem 0.95rem;
  row-gap: 0.15rem;
}
main > .grid.two:first-of-type .tile.has-figure .tile-figure {
  width: 56px; height: 56px;
}
main > .grid.two:first-of-type .tile.has-figure .label {
  font-size: 1.05rem !important;
  font-weight: 500;
}
main > .grid.two:first-of-type .tile.has-figure .desc {
  font-size: 0.82rem;
}

/* Tighten main padding so chrome + content fit in viewport */
main { padding: 0.9rem 0 2rem; }
main > .grid:first-child { margin-top: 0.2rem; }

/* Quick-tools grid: tighter gap */
.panel .grid.four { gap: 0.5rem; margin-bottom: 0; }
.panel .grid.four .tile { padding: 0.45rem 0.6rem; }

/* Panel padding tighter on dashboard for vertical economy */
.panel { padding: 1rem 1.2rem; margin-bottom: 0.8rem; }
.panel h2 { font-size: 1.15rem; margin-bottom: 0.5rem; }

/* The .grid wrapper margins */
.grid { margin-bottom: 0.8rem; gap: 0.7rem; }

/* ─────────────────────────────────────────────────────────────────
   MOBILE RESPONSIVE LAYER
   Phone-first overrides applied below 720px viewport width.
   ─────────────────────────────────────────────────────────────── */

/* Hamburger button — desktop hides it. */
.nav-toggle {
  display: none;
  width: 38px; height: 38px;
  background: transparent;
  border: 1px solid var(--burgundy-faint);
  border-radius: var(--radius-sm);
  padding: 0 0.45rem;
  cursor: pointer;
  flex-direction: column;
  gap: 4px;
  justify-content: center;
  align-items: stretch;
  flex-shrink: 0;
}
.nav-toggle span {
  display: block;
  height: 2px;
  background: var(--burgundy);
  border-radius: 1px;
  transition: transform 0.18s, opacity 0.18s;
}
.nav-toggle.is-open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-toggle.is-open span:nth-child(2) { opacity: 0; }
.nav-toggle.is-open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 760px) {
  /* ── Chrome / nav ─────────────────────────────────────────── */
  .site-header {
    padding: 0.7rem 1rem;
    gap: 0.5rem;
    /* Let .topnav wrap to a full-width row below brand + button when
       toggled open — simpler & more reliable than absolute positioning. */
    flex-wrap: wrap;
  }
  .brand-row strong { font-size: 0.98rem; }
  .brand-row .tagline { display: none; }
  .session-badge { font-size: 0.7rem; padding: 0.12rem 0.5rem; }

  /* Hamburger visible by default; nav hidden until toggled. */
  .nav-toggle { display: flex; }
  .topnav {
    /* Hidden by default on mobile. .is-open swaps to flex below. */
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
    margin-top: 0.6rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--line);
  }
  .topnav.is-open { display: flex; }
  .topnav a {
    padding: 0.6rem 0.85rem;
    font-size: 0.97rem;
    border-radius: var(--radius-sm);
    border-bottom: 0;
    background: var(--cream-light);
  }
  .topnav a.active { background: var(--cream-warm); }
  /* Dropdown stacks inside the mobile column instead of floating. */
  .nav-dd { width: 100%; }
  .nav-dd > summary { padding: 0.6rem 0.85rem; background: var(--cream-light);
    border-radius: var(--radius-sm); justify-content: space-between; }
  .nav-dd-menu { position: static; box-shadow: none; border: none; min-width: 0;
    background: transparent; padding: 0.25rem 0 0.25rem 0.8rem; }
  .topnav form { width: 100%; margin: 0; }
  .topnav form button {
    width: 100%; text-align: left;
    padding: 0.6rem 0.85rem;
    background: var(--cream-light);
    color: var(--burgundy);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
  }

  /* Header-aux row: greeting on top, switcher below */
  .header-aux {
    padding: 0.4rem 1rem 0.5rem;
    gap: 0.4rem;
    flex-direction: column;
    align-items: stretch;
  }
  .header-greet { font-size: 0.85rem; flex-wrap: wrap; gap: 0.3rem; }
  .header-greet-biz { font-size: 0.78rem; }
  .ll-lang-switcher { align-self: flex-end; }

  /* ── Main + layout ─────────────────────────────────────────── */
  main {
    grid-template-columns: minmax(0.8rem, 1fr) min(1180px, 100% - 1.6rem) minmax(0.8rem, 1fr);
    padding: 0.7rem 0 5rem;  /* extra bottom for taskbar + thumb reach */
  }
  .page-title {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    padding-bottom: 0.5rem;
    margin-bottom: 0.8rem;
  }
  .page-title h1 { font-size: 1.4rem; }
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.2rem; }
  h3 { font-size: 1.05rem; }
  .panel { padding: 0.9rem 1rem; }

  /* Most grids collapse to one column. */
  .grid.two, .grid.three, .grid.four {
    grid-template-columns: 1fr;
  }
  /* But the dashboard quick-tools grid stays at 2 cols (small tiles ok). */
  .panel .grid.four { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
  .panel .grid.four .tile { padding: 0.45rem 0.5rem; }

  /* Customer-detail split (chart on right). Stack on mobile. */
  .split { flex-direction: column; }
  .split > .col { min-width: 0; width: 100%; }

  /* ── Tables — make them horizontally scrollable inside .panel ─ */
  .panel table.list,
  table.list {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  table.list thead, table.list tbody, table.list tr { display: table; width: 100%; }

  /* Forms */
  form .row { margin-bottom: 0.7rem; }
  form input, form select, form textarea { font-size: 0.95rem; padding: 0.55rem 0.65rem; }
  .action-row { gap: 0.4rem; }

  /* Filter chips — already wrap; tighten gap */
  .filter-chips { gap: 0.3rem; }
  .filter-chips a { padding: 0.2rem 0.6rem; font-size: 0.78rem; }

  /* Time + date pickers tighten their 3 selects on phones */
  .time-pick { grid-template-columns: 1fr 1fr 1fr; gap: 0.3rem; }
  .date-pick { grid-template-columns: 1fr 0.9fr 1.55fr 0.75fr; gap: 0.3rem; }

  /* Tile (dashboard hero pair) — back to single column */
  main > .grid.two:first-of-type { grid-template-columns: 1fr; }
  main > .grid.two:first-of-type .tile.has-figure { padding: 0.7rem 0.85rem; }

  /* ── Taskbar — 2 rows on small screens ─────────────────────── */
  .taskbar {
    flex-direction: column;
    align-items: stretch;
    padding: 0.4rem 0.7rem 0.5rem;
    gap: 0.3rem;
  }
  .tb-manual { position: static; transform: none; align-self: center; margin: .1rem 0; }
  .tb-left, .tb-right {
    justify-content: center;
    flex-wrap: wrap;
    white-space: normal;
  }
  .tb-chip-label { display: none; }
  .tb-chip { padding: 0.15rem 0.45rem; }
  .tb-chip-primary .tb-chip-label { display: inline; }

  /* ── Learn module nav strip ─────────────────────────────────── */
  .ll-mnav {
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
    padding: 0.4rem 0.5rem;
  }
  .ll-mnav-strip {
    grid-column: 1 / -1;
    order: -1;
    justify-content: center;
    flex-wrap: wrap;
  }
  .ll-mnav-dot { width: 11px; height: 11px; }
  .ll-mnav-title { display: none; }
  .ll-mnav-key { font-size: 0.7rem; }

  /* Long-form lesson sections */
  .ll-section { padding: 1rem 1rem 1.1rem; }
  .ll-section .ll-h { font-size: 1.15rem; }
  .ll-section .ll-num { width: 26px; height: 26px; font-size: 0.92rem; }
  .ll-section p { font-size: 0.97rem; line-height: 1.7; }

  /* Customer detail — relations + reading-history rows */
  .kv { grid-template-columns: 1fr; gap: 0.15rem 0; }
  .kv dt { color: var(--ink-soft); font-size: 0.82rem; }
  .kv dd { margin: 0 0 0.5rem; }

  /* Curriculum index module-grid — single column on tight phones */
  .module-grid { grid-template-columns: 1fr; gap: 0.6rem; }

  /* Long titles in module nav buttons — let them wrap */
  .ll-mnav-btn { padding: 0.3rem 0.5rem; }

  /* Learn hero — stack the progress ring under the blurb */
  .learn-hero { grid-template-columns: 1fr; gap: 0.7rem; padding: 1rem 1rem; }
  .learn-hero h1 { font-size: 1.4rem; }
  .progress-ring { width: 70px; height: 70px; align-self: flex-start; }
  .progress-ring svg { width: 70px; height: 70px; }
}

@media (max-width: 420px) {
  /* Ultra-tight: smaller paddings, hide the lang-switcher label */
  .site-header { padding: 0.55rem 0.7rem; }
  .header-aux { padding: 0.35rem 0.7rem 0.4rem; }
  .ll-lang-switcher .ll-lang-icon { display: none; }
  .panel { padding: 0.75rem 0.85rem; }
  /* Dashboard 2-col tools grid → 1-col on phones <420px */
  .panel .grid.four { grid-template-columns: 1fr; }
  .tb-left .tb-sun { display: none; }
  /* Greeting compacts */
  .header-greet-biz { display: none; }
}
