:root {
  --primary: #0f766e;
  --primary-dark: #115e59;
  --primary-soft: #e6f3f1;
  --accent: #b45309;
  --accent-soft: #fff4df;
  --danger: #b42318;
  --danger-soft: #feeceb;
  --info: #2563eb;
  --info-soft: #eaf0ff;
  --ink: #14211d;
  --muted: #61736c;
  --line: #d8e2dd;
  --line-strong: #bfcdc6;
  --bg: #f5f7f6;
  --bg2: #f8faf9;
  --card: #ffffff;
  --shadow: 0 1px 2px rgba(20, 33, 29, .05), 0 10px 24px rgba(20, 33, 29, .06);

  --green: var(--primary);
  --green-dark: var(--primary-dark);
  --green-light: var(--primary-soft);
  --gold: #c58b14;
  --red: var(--danger);
  --amber: var(--accent);
  --blue: var(--info);
}

* { box-sizing: border-box; margin: 0; }

html { min-width: 320px; }

body {
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background:
    linear-gradient(180deg, #eef4f2 0, var(--bg) 220px),
    var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}

a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font: inherit; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(37, 99, 235, .24);
  outline-offset: 2px;
}

/* ---- App shell: fixed sidebar + top app bar ------------------------------- */
:root { --sidebar-w: 244px; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  z-index: 60;
  display: flex;
  flex-direction: column;
  padding: 20px 14px 18px;
  color: #d7ebe2;
  background:
    radial-gradient(circle at 12% 4%, rgba(72, 214, 154, .20), transparent 34%),
    radial-gradient(circle at 90% 92%, rgba(46, 173, 128, .18), transparent 40%),
    linear-gradient(170deg, #0c4032 0%, #08301f 58%, #062818 100%);
  border-right: 1px solid rgba(255, 255, 255, .07);
  overflow-y: auto;
  scrollbar-width: thin;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 8px 0;
  margin-bottom: 26px;
  color: #fff;
}

.sidebar .brand:hover { text-decoration: none; }

.sidebar .brand-mark {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .14);
}

.sidebar .brand-mark svg { width: 19px; height: 19px; fill: none; stroke: #4fe3a2; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.sidebar .brand b { display: block; font-size: 16px; font-weight: 800; letter-spacing: -.3px; line-height: 1.1; }
.sidebar .brand small { display: block; font-size: 10.5px; color: #8fbdaa; margin-top: 3px; }

.sidebar nav { display: flex; flex-direction: column; gap: 3px; }

.sidebar nav a,
.sidebar nav .navgroup-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 13px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #c2ddd2;
  font-size: 13.5px;
  font-weight: 650;
  text-align: left;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}

.sidebar nav svg { width: 18px; height: 18px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.sidebar nav a:hover,
.sidebar nav .navgroup-btn:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }

.sidebar nav a.active {
  background: rgba(255, 255, 255, .13);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08);
}

.sidebar .navgroup-btn .chev { margin-left: auto; transition: transform .18s ease; }
.sidebar .navgroup.open .navgroup-btn .chev { transform: rotate(180deg); }

.sidebar .subnav { display: none; flex-direction: column; gap: 2px; margin: 2px 0 4px; }
.sidebar .navgroup.open .subnav { display: flex; }

.sidebar .subnav a {
  padding: 9px 13px 9px 16px;
  font-size: 12.75px;
  font-weight: 600;
  color: #a9cbbe;
}

.sidebar .subnav a svg { width: 16px; height: 16px; }

.sidebar-foot {
  margin-top: auto;
  padding: 16px 10px 2px;
  font-size: 13px;
  font-weight: 750;
  line-height: 1.35;
  color: #e6f5ee;
}

.sidebar-foot svg { width: 20px; height: 20px; display: block; margin-bottom: 9px; fill: none; stroke: #4fe3a2; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-foot span { color: #7fb49f; font-weight: 600; }

/* ---- Top app bar ---- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 72px;
  padding: 0 26px;
  margin-left: var(--sidebar-w);
  background: rgba(247, 250, 249, .92);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
}

.appbar .navtoggle {
  display: none;
  flex: 0 0 auto;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--primary-dark);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}

.gsearch {
  position: relative;
  flex: 1;
  min-width: 0;
  max-width: 660px;
}

.gsearch svg {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  width: 17px;
  height: 17px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.9;
  pointer-events: none;
}

.gsearch input {
  min-height: 44px;
  padding: 10px 14px 10px 42px;
  border-radius: 11px;
  border-color: var(--line);
  background: #fff;
  font-size: 13.5px;
  box-shadow: var(--shadow-sm);
}

.gsearch input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15, 118, 110, .1); }

.appbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; flex: 0 0 auto; }

.bell {
  position: relative;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s ease;
}

.bell:hover { background: #eef2f0; color: var(--ink); }
.bell svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.bell .dot {
  position: absolute;
  top: 8px;
  right: 9px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid #f7faf9;
}

.usermenu { position: relative; }

.userchip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 9px 5px 5px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}

.userchip:hover { background: #fff; border-color: var(--line); }

.avatar {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #16a394);
  color: #fff;
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: .3px;
}

.userchip .uname { font-size: 13.25px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.userchip .chev { width: 15px; height: 15px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.usermenu-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 210px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: #fff;
  box-shadow: var(--shadow-lg);
  display: none;
}

.usermenu.open .usermenu-pop { display: block; }

.usermenu-pop .who { padding: 9px 11px 11px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.usermenu-pop .who b { display: block; font-size: 13px; }
.usermenu-pop .who span { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; }

.usermenu-pop button {
  display: block;
  width: 100%;
  padding: 9px 11px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
  text-align: left;
  cursor: pointer;
}

.usermenu-pop button:hover { background: var(--danger-soft); color: var(--danger); }

/* Page content sits beside the fixed sidebar. The class is set by topbar(), so pages that
   never render the shell (the sign-in screen) are untouched. */
.has-sidebar .wrap {
  margin-left: var(--sidebar-w);
  width: auto;
  max-width: 1420px;
  padding: 22px 26px 46px;
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(6, 32, 24, .42);
  display: none;
}

.scrim.show { display: block; }

@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, .35);
  }

  .sidebar.open { transform: none; }
  .appbar { margin-left: 0; padding: 0 16px; min-height: 64px; }
  .appbar .navtoggle { display: inline-flex; }
  .has-sidebar .wrap { margin-left: 0; padding: 18px 16px 40px; }
  .userchip .uname, .userchip .chev { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}

.wrap {
  width: min(1220px, 100%);
  margin: 0 auto;
  padding: 24px 20px 44px;
}

h1 {
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: 0;
  margin-bottom: 5px;
}

.sub {
  color: var(--muted);
  margin-bottom: 18px;
  font-size: 13.5px;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.back-btn {
  width: auto;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-md);
  overflow-x: auto;
}

.card h2 {
  font-size: 15.5px;
  line-height: 1.25;
  margin-bottom: 12px;
  color: var(--primary-dark);
}

.card > div[style*="display:flex"] {
  min-width: 0;
}

.card [style*="flex:1"] {
  min-width: 0;
}

.muted { color: var(--muted); font-size: 12.75px; }
.right { text-align: right; }

.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: stretch;
}

.row > * {
  flex: 1;
  min-width: 150px;
}

label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.field { margin-bottom: 12px; }

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font-size: 13.5px;
}

input::placeholder,
textarea::placeholder { color: #91a09a; }

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
}

.btn {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  max-width: 100%;
  background: var(--primary);
  color: #fff;
  border: 1px solid var(--primary);
  padding: 8px 14px;
  border-radius: 7px;
  font-weight: 800;
  cursor: pointer;
  font-size: 13.5px;
  line-height: 1.2;
  text-align: center;
  white-space: normal;
}

.btn:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  text-decoration: none;
}

.btn.secondary {
  background: #fff;
  color: var(--primary-dark);
  border-color: var(--line-strong);
}

.btn.secondary:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
}

.btn.danger {
  background: #fff;
  color: var(--danger);
  border-color: #efb4af;
}

.btn.danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.btn.small {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 12px;
  border-radius: 6px;
}

.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
}

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  font-size: 13.25px;
}

th {
  text-align: left;
  color: var(--muted);
  background: #fbfdfc;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}

td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

tr:last-child td { border-bottom: 0; }

/* Keep year-wise vertical analyses easy to scan: clear separators between every column. */
th + th, td + td { border-left: 1px solid var(--line); }
tr:hover td { background: #fbfdfc; }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.25px;
  line-height: 1;
  font-weight: 800;
  white-space: nowrap;
}

.badge.green { background: var(--primary-soft); color: var(--primary-dark); }
.badge.gold { background: var(--accent-soft); color: var(--accent); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.gray { background: #eef2f0; color: var(--muted); }
.badge.blue { background: var(--info-soft); color: var(--info); }

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.search-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.search-row input { max-width: 320px; }

/* Inline add/edit forms — replace the old browser prompt() chains. */
.edit-form {
  background: var(--primary-soft);
  border: 1px solid var(--primary);
  border-radius: 8px;
  padding: 14px 16px;
}
.edit-form label { color: var(--primary-dark); }

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  /* The tab strip still scrolls when it overflows; it just stops drawing a scrollbar
     across the underline, which read as a stray vertical rule at the end of the row. */
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tabs button {
  flex: 0 0 auto;
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  padding: 10px 13px;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.tabs button.active {
  color: var(--primary-dark);
  border-bottom-color: var(--primary);
}

.tabs button:hover {
  color: var(--primary-dark);
  background: rgba(15, 118, 110, .06);
}

.steps {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}

.step {
  min-width: 0;
  background: rgba(255, 255, 255, .86);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  color: var(--muted);
  font-size: 12px;
  box-shadow: 0 1px 2px rgba(20, 33, 29, .04);
}

.step b {
  display: block;
  color: var(--ink);
  font-size: 12.5px;
  line-height: 1.25;
  margin-bottom: 3px;
}

.step.done {
  border-color: rgba(15, 118, 110, .42);
  background: var(--primary-soft);
}

.step.done b { color: var(--primary-dark); }

.dropzone {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px dashed var(--line-strong);
  border-radius: 8px;
  padding: 18px;
  text-align: center;
  color: var(--muted);
  background: #fbfdfc;
  cursor: pointer;
}

.dropzone:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.scroll-x {
  max-width: 100%;
  overflow-x: auto;
}

.sec {
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.sec-head {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg2);
  cursor: pointer;
}

.sec-head:hover { background: var(--primary-soft); }
.sec table { min-width: 920px; }
.sec input { min-width: 128px; }

.match-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  margin-bottom: 10px;
  background: #fff;
}

.match-card.top {
  border-color: rgba(15, 118, 110, .55);
  background: var(--primary-soft);
}

.match-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.match-rank {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
}

.score-bar {
  height: 8px;
  background: #e2ebe7;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 9px;
}

.score-bar div {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #2f9e44);
  border-radius: 999px;
}

.rule-grid {
  display: grid;
  grid-template-columns: minmax(190px, 1.6fr) minmax(120px, 1fr) minmax(110px, 1fr) minmax(110px, 1fr) 80px minmax(110px, .8fr) auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

/* Wide screens: the wrapper vanishes so the control is a direct grid item, positioned by
   the shared header row above. The caption only appears once that header is hidden. */
.rf { display: contents; }
.rf > span { display: none; }

.rule-actions { white-space: nowrap; }

/* The login page holds one card and a footer line, so it should sit centred in the
   viewport rather than starting 8vh down and pushing itself past the fold — on a 667px
   phone that produced a scrollbar for a page with nothing below to scroll to.
   dvh, not vh: mobile browser chrome makes vh taller than the visible area. */
body.login-page {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 0;
}

.login-box {
  width: min(520px, calc(100% - 32px));
  margin: 0 auto;
}

.login-brand {
  text-align: center;
  margin-bottom: 0;
}

.login-brand .big {
  color: var(--primary-dark);
  font-size: 31px;
  line-height: 1.05;
  font-weight: 900;
  letter-spacing: 0;
}

.login-brand .big span { color: var(--accent); }

.login-box .card {
  padding: 36px;
  border-radius: 20px;
  box-shadow: 0 20px 42px rgba(20, 33, 29, .08);
  overflow: visible;
}

.login-box .field {
  margin-bottom: 22px;
}

.login-box label {
  font-size: 14px;
  color: #4d6058;
}

.login-box input {
  min-height: 54px;
  font-size: 17px;
  border-radius: 12px;
  padding-left: 14px;
}

.login-mark {
  width: 58px;
  height: 58px;
  margin: 2px auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(180, 83, 9, .42);
  border-radius: 50%;
  color: var(--accent);
  background: #fffbf1;
  font-size: 19px;
  font-weight: 900;
}

.login-rule {
  width: 120px;
  height: 1px;
  margin: 20px auto 26px;
  border-top: 1px dashed rgba(180, 83, 9, .55);
}

.login-form {
  width: 100%;
  margin: 0 auto;
}


.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-right: 52px;
}

.eye-btn {
  position: absolute;
  top: 50%;
  right: 7px;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
}

.eye-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.eye-btn:hover { color: var(--primary-dark); }

.eye-btn:hover {
  background: var(--primary-soft);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 99;
  max-width: min(520px, calc(100vw - 44px));
  background: #17231f;
  color: #fff;
  padding: 12px 15px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, .24);
}

.toast.err { background: var(--danger); }

.spin {
  display: inline-block;
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  border: 2px solid currentColor;
  border-top-color: transparent !important;
  border-radius: 50%;
  animation: sp 1s linear infinite;
}

@keyframes sp { to { transform: rotate(360deg); } }

@media (max-width: 1050px) {
  .steps { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .rule-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* The header is its own grid, so once the columns rewrap it stops sitting above the
     fields it names. Hide it and let each field carry its own caption instead. */
  .rule-head { display: none; }

  .rf { display: block; }

  .rf > span {
    display: block;
    font-size: 10.5px;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 3px;
  }

  .rule-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 6px;
  }
}

/* One field per row on a phone: two columns of selects at this width leaves each too
   narrow to read the parameter name it is set to. */
@media (max-width: 560px) {
  .rule-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  body { font-size: 13.5px; }

  /* Doc/param counts and the created date are reference detail, not what a phone user is
     scanning for. Dropping them lets case no, applicant and status fit without the table
     scrolling sideways and clipping the status badge mid-word. */
  .col-opt { display: none; }

  /* Tables carry a 680px min-width so wide data scrolls rather than squashing. With the
     optional columns hidden the cases list has only three, so let it use the width it has
     — otherwise it still scrolls and clips the status badge for no reason. Section tables
     on the case page keep the min-width: 25 columns genuinely need to scroll. */
  .cases-table { min-width: 0; }

  .cases-table td,
  .cases-table th { padding: 9px 7px; }

  .wrap { padding: 18px 12px 32px; }
  h1 { font-size: 21px; }
  .card { padding: 13px; }
  .card > div[style*="display:flex"] {
    flex-wrap: wrap;
  }

  .card > div[style*="display:flex"] > span[style*="flex:1"],
  .card > div[style*="display:flex"] > div[style*="flex:1"] {
    flex-basis: 100%;
  }

  .row { gap: 9px; }
  .row > * { min-width: 100%; }
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tabs button { padding: 9px 10px; }
  .btn { width: 100%; }
  .btn.small { width: auto; }
  .match-head > div[style*="flex:1"] { flex-basis: 100%; }
  .right { text-align: left; }
  .toast { right: 12px; bottom: 12px; max-width: calc(100vw - 24px); }

  .login-box {
    margin-top: 28px;
  }

  .login-box .card {
    min-height: auto;
    padding: 28px 22px;
    border-radius: 14px;
  }

  .login-mark {
    margin-bottom: 16px;
  }

  .login-brand .big {
    font-size: 27px;
  }

  .login-rule {
    margin: 22px auto 28px;
  }

  .login-box input {
    min-height: 50px;
  }
}

@media (max-width: 440px) {
  .steps { grid-template-columns: 1fr; }
  .userchip .uname { display: none; }
}

@media print {
  .sidebar,
  .appbar,
  .scrim,
  .no-print,
  .tabs,
  .steps,
  .toast { display: none !important; }

  .has-sidebar .wrap { margin-left: 0; max-width: none; }

  body {
    background: #fff;
    color: #000;
    font-size: 11px;
  }

  .wrap {
    width: 100%;
    padding: 0;
  }

  .card {
    box-shadow: none;
    border: 0;
    padding: 0;
    overflow: visible;
  }

  table,
  .sec table {
    min-width: 0;
    width: 100%;
    font-size: 10.5px;
  }

  th {
    position: static;
    background: #fff;
  }

  /* The killer for "the full tab doesn't print": wide CAM tables (bank, financials) live in
     an overflow-x:auto scroller. On screen you scroll to the hidden columns; on paper they
     are simply clipped at the page edge and lost. Let everything overflow visibly and wrap
     so every column reaches the page. */
  .scroll-x {
    overflow: visible !important;
  }

  td,
  th {
    white-space: normal;
    word-break: break-word;
  }

  /* Keep a section and its heading together rather than orphaning a title at a page foot. */
  h2 {
    break-after: avoid;
    page-break-after: avoid;
  }
}

/* Short viewports (landscape phones, small laptops). The login card is fixed content, so
   rather than let it overflow, shrink the decorative parts and keep the fields usable. */
@media (max-height: 720px) {
  .login-box .card { padding: 26px 24px; }
  .login-mark { width: 46px; height: 46px; margin: 0 auto 12px; font-size: 16px; }
  .login-brand .big { font-size: 25px; }
  .login-rule { margin: 14px auto 18px; }
  .login-box .field { margin-bottom: 14px; }
  .login-box input { min-height: 46px; font-size: 15px; }
}

/* ---- Confirm dialog (replaces window.confirm) ---- */
.modal-back {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(20, 33, 29, .48);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal {
  width: min(420px, 100%);
  background: var(--card);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 24px 48px rgba(20, 33, 29, .22);
}

.modal h3 {
  font-size: 16px;
  color: var(--ink);
  margin-bottom: 6px;
  line-height: 1.3;
}

.modal p { margin-bottom: 0; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

/* Full width and reversed on a phone: the primary action sits under the thumb, and
   two side-by-side buttons at this width would each be too narrow to read. */
@media (max-width: 480px) {
  .modal-actions {
    flex-direction: column-reverse;
  }
  .modal-actions .btn { width: 100%; }
}

/* ---- Button rows ---- */
/* Buttons placed as bare siblings flow as inline-flex and wrap raggedly at different
   widths. This keeps them on a shared baseline with even gaps, and stacks them to full
   width on a phone rather than leaving a short button orphaned on its own line. */
.btn-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

@media (max-width: 720px) {
  .btn-row {
    flex-direction: column;
    align-items: stretch;
  }
}

/* Row actions must not wrap onto two lines inside a narrow table cell. */
.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  flex-wrap: nowrap;
  white-space: nowrap;
}

/* ---- Ask AI chat ---- */
.chat-log {
  max-height: 52vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px;
}

.chat-row { display: flex; }
.chat-row.you { justify-content: flex-end; }
.chat-row.ai { justify-content: flex-start; }

.chat-bubble {
  max-width: 82%;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.chat-bubble.you {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-bubble.ai {
  background: var(--bg2);
  border: 1px solid var(--line);
  color: var(--ink);
  border-bottom-left-radius: 4px;
}

.chat-bubble.ai ul { margin: 4px 0 0 18px; padding: 0; }

/* ---- Job progress bar (extraction / appraisal) ---- */
.job-bar {
  position: relative;
  height: 22px;
  margin-top: 10px;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.job-bar-fill {
  height: 100%;
  width: 2%;
  background: linear-gradient(90deg, var(--primary), #2f9e44);
  border-radius: 999px;
  transition: width .4s ease;
}

.job-bar-msg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  padding: 0 8px;
}

/* ---- LenderMatch AI split-screen sign in ---- */
body.login-page { padding: 0; background: #f6faf9; display: block; overflow-x: hidden; }
.login-shell { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 55%) minmax(0, 45%); }
.login-story { position: relative; overflow: hidden; min-height: 100dvh; padding: clamp(28px,4vw,62px); color: #fff; background: linear-gradient(138deg,#012f36 0%,#00554e 62%,#048267 100%); -webkit-mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='none'%3E%3Cpath fill='white' d='M0 0H93.6C93.6 22 98.2 32 98.2 50C98.2 68 93.6 78 93.6 100H0Z'/%3E%3C/svg%3E") center/100% 100% no-repeat; mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='none'%3E%3Cpath fill='white' d='M0 0H93.6C93.6 22 98.2 32 98.2 50C98.2 68 93.6 78 93.6 100H0Z'/%3E%3C/svg%3E") center/100% 100% no-repeat; }
.login-story-glow { position:absolute; inset:0; background:radial-gradient(circle at 85% 18%,rgba(88,236,139,.25),transparent 27%),radial-gradient(circle at 72% 72%,rgba(255,205,74,.16),transparent 25%); }
.lm-logo { position:relative; z-index:2; display:flex; align-items:center; gap:10px; }
.lm-logo svg { width:48px; height:44px; overflow:visible; }
.lm-logo svg path:not(.arrow) { fill:#1fa6dc; stroke:none; }
.lm-logo svg .arrow { fill:none; stroke:#31df82; stroke-width:4; stroke-linecap:round; stroke-linejoin:round; }
.lm-logo b { display:block; font-size:24px; line-height:1; font-weight:850; letter-spacing:-.6px; font-style:normal; }
.lm-logo b span { color:#31df82; }.lm-logo b em { color:#23aee4; font-style:normal; }
.lm-logo small { display:block; margin-top:5px; font-size:9px; letter-spacing:.2px; opacity:.8; }
.story-copy { position:relative; z-index:2; margin-top:clamp(30px,6.5vh,72px); max-width:620px; }
.story-copy h1 { font-size:clamp(34px,4.2vw,64px); line-height:1.05; letter-spacing:-1.8px; }.story-copy h1 span { color:#3ff18b; }
.story-copy p { max-width:452px; margin-top:15px; color:#d1ece6; font-size:clamp(13px,1.2vw,17px); }
.feature-strip { position:relative; z-index:3; display:grid; grid-template-columns:repeat(4,minmax(82px,1fr)); gap:12px; margin-top:28px; max-width:470px; }
.feature-strip div { text-align:left; min-width:0; }.feature-strip i { width:40px; height:40px; margin:0 0 7px; border-radius:10px; display:grid; place-items:center; background:rgba(255,255,255,.1); color:#4ef196; font-size:21px; font-style:normal; border:1px solid rgba(255,255,255,.1); }
.feature-strip b,.feature-strip span { display:block; }.feature-strip b { font-size:11px; }.feature-strip span { color:#acd3cb; font-size:8px; margin-top:2px; }
.growth-art { position:absolute; right:14%; bottom:12%; width:250px; height:210px; transform:scale(1.12); transform-origin:100% 100%; z-index:1; filter:drop-shadow(0 10px 22px rgba(0,0,0,.2)); }
.growth-art .bar { position:absolute; bottom:25px; width:28px; border-radius:5px 5px 0 0; background:linear-gradient(#fff36c,#28d98b); box-shadow:0 0 18px rgba(255,238,84,.5); }
.growth-art .b1{height:45px;left:35px}.growth-art .b2{height:77px;left:77px}.growth-art .b3{height:112px;left:119px}.growth-art .b4{height:155px;left:161px}
.rise-line { position:absolute; width:185px; height:4px; background:#ffe768; left:22px; top:77px; transform:rotate(-37deg); box-shadow:0 0 12px #ffe768; }.rise-arrow { position:absolute; color:#ffe768; font-size:35px; right:25px; top:4px; transform:rotate(-42deg); }
.plant { position:absolute; bottom:24px; width:4px; background:#80ec87; transform-origin:bottom; }.plant::before,.plant::after { content:""; position:absolute; width:26px; height:13px; background:#78e67e; border-radius:100% 0 100% 0; }.plant::before{left:-24px;top:24px;transform:rotate(25deg)}.plant::after{left:3px;top:8px;transform:rotate(-20deg)}
.plant.p1{height:70px;left:12px}.plant.p2{height:105px;left:65px}.plant.p3{height:145px;left:112px}
.trust-strip { position:absolute; z-index:2; left:clamp(28px,4vw,62px); bottom:54px; display:flex; gap:35px; }.trust-strip div { display:grid; grid-template-columns:auto auto; column-gap:7px; }.trust-strip b{color:#44eb91;font-size:15px}.trust-strip span{font-size:9px;color:#beded7;align-self:center}
.story-foot { position:absolute; z-index:2; bottom:22px; left:clamp(28px,4vw,62px); font-size:11px; color:#d6eee9; font-style:italic; }
.login-access { position:relative; z-index:2; min-height:100dvh; display:grid; place-items:center; padding:48px clamp(60px,4.5vw,90px) 26px clamp(20px,1.5vw,32px); }
.access-note { position:absolute; right:32px; top:22px; color:#58756e; font-size:10px; }
.login-access .login-box { width:clamp(480px,34vw,540px); margin:0; }
.login-access .login-box .card { padding:30px 32px; border:1px solid #dfebe7; border-radius:14px; box-shadow:0 20px 56px rgba(11,63,59,.12); }
.lm-logo-dark { justify-content:center; color:#073a3f; }.lm-logo-dark svg{width:54px;height:49px}.lm-logo-dark b{font-size:26px}.lm-logo-dark small{text-align:center;color:#315f5c;opacity:1;font-size:10px;margin-top:6px}
.login-access .login-rule { width:78px; margin:14px auto 8px; border-top:2px solid #29c987; }
.login-benefits{text-align:center;color:#244d54;font-size:12px;margin-bottom:14px}.login-benefits i{font-style:normal;color:#23c77e;padding:0 6px}
.welcome-box { display:flex; align-items:center; gap:10px; padding:9px 11px; margin-bottom:14px; border:1px solid #bcebd7; border-radius:8px; background:#eaf9f2; color:#164a40; }.welcome-box i{width:28px;height:28px;display:grid;place-items:center;border-radius:50%;background:#d3f5e5;color:#09975e;font-style:normal}.welcome-box b,.welcome-box span{display:block}.welcome-box b{font-size:13px}.welcome-box span{font-size:10px;color:#5d7770;margin-top:1px}
.login-access .login-box .field { margin-bottom:12px; }.login-access .login-box label{font-size:12px;font-weight:750;color:#102f42}.login-access .login-box input{min-height:42px;font-size:13px;border-radius:8px;padding-left:43px;background:#fff;border-color:#cbdadf}.login-access .field:first-child input{background-image:linear-gradient(transparent,transparent);}
.input-with-icon,.password-wrap{position:relative}.input-with-icon>svg,.field-leading-icon{position:absolute;left:14px;top:50%;transform:translateY(-50%);z-index:2;width:20px;height:20px;fill:none;stroke:#17394d;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;pointer-events:none}.clear-user{position:absolute;right:10px;top:50%;transform:translateY(-50%);width:22px;height:22px;border:1.5px solid #879ba5;border-radius:50%;background:#fff;color:#637c88;line-height:16px;font-weight:700;cursor:pointer}.input-with-icon input{padding-right:43px}
.login-options { display:flex; justify-content:space-between; align-items:center; margin:-3px 0 14px; color:#19875e; font-size:12px; }.login-options label{display:flex;align-items:center;gap:7px!important}.login-options input{min-height:0!important;width:15px!important;height:15px;padding:0!important;accent-color:#078d62}.login-options button{border:0;background:transparent;color:#05885d;font-size:12px;cursor:pointer;padding:2px 0}.login-options button:hover{text-decoration:underline}
.login-submit { width:100%; min-height:42px; border-radius:7px; background:linear-gradient(90deg,#078e65,#057e62); }.login-submit span{float:right}.login-error{display:none;color:var(--red);font-size:12px;margin-top:8px}
.login-powered { text-align:center; color:#71847e; font-size:10px; line-height:1.5; margin-top:12px; width:100%; }

@media (min-width:1025px) and (max-height:840px){
  .story-copy h1{font-size:clamp(32px,3.6vw,52px)}.growth-art{bottom:10%;transform:scale(.92)}
}
@media (min-width:1025px) and (min-height:1000px){
  .growth-art{bottom:15%;transform:scale(1.3)}
}
@media (max-width:1024px){
  .login-shell{grid-template-columns:1fr}.login-story{min-height:420px;padding:30px 28px;-webkit-mask:none;mask:none}.story-copy{margin-top:45px}.story-copy h1{font-size:40px}.growth-art{right:5%;bottom:5%;transform:scale(.7)}.trust-strip{display:none}.story-foot{bottom:18px}.login-access{min-height:auto;justify-items:center;margin-left:0;padding:65px 20px 35px}.login-access .login-box{width:min(440px,100%)}.login-access .login-box .card{padding:30px 28px}.access-note{top:22px;right:20px}.login-access .login-box{margin:0}.feature-strip{max-width:520px}
}
@media (max-width:560px){
  .login-story{min-height:390px}.story-copy h1{font-size:34px}.story-copy p{max-width:90%}.feature-strip{grid-template-columns:repeat(2,1fr);max-width:280px}.growth-art{opacity:.32;right:-40px}.login-access .login-box .card{padding:25px 20px}.lm-logo b{font-size:20px}.access-note{font-size:8px}
}

/* ============================================================================
   Product surface — shared components for Home, Cases, Ask Policy and Admin.
   Layout and presentation only; every page keeps its own markup ids and JS.
   ========================================================================== */

:root {
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(20, 33, 29, .05);
  --shadow-md: 0 1px 2px rgba(20, 33, 29, .04), 0 8px 20px rgba(20, 33, 29, .06);
  --shadow-lg: 0 2px 4px rgba(20, 33, 29, .04), 0 18px 40px rgba(20, 33, 29, .09);
}

/* ---- Page header ---- */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.page-head .ph-text { min-width: 0; }

.page-head h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -.5px;
  margin-bottom: 4px;
}

.page-head .sub { margin-bottom: 0; }

.page-head .ph-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 7px;
}

/* ---- Panels ---- */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  margin-bottom: 16px;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fcfdfd, #fff);
}

.panel-head h2 {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -.15px;
  color: var(--ink);
  margin: 0;
}

.panel-head .panel-sub {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-top: 2px;
}

.panel-head .panel-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.panel-body { padding: 18px; }
.panel-body.flush { padding: 0; }

.panel-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  background: #fbfdfc;
}

/* ---- Dashboard grids ---- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

/* ---- KPI card ---- */
.kpi {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  padding: 16px 16px 15px;
  transition: box-shadow .18s ease, transform .18s ease, border-color .18s ease;
}

.kpi:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.kpi-label {
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: .3px;
  text-transform: uppercase;
  color: var(--muted);
}

.kpi-icon {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 9px;
  font-size: 15px;
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.kpi-icon.amber { background: var(--accent-soft); color: var(--accent); }
.kpi-icon.blue { background: var(--info-soft); color: var(--info); }
.kpi-icon.gray { background: #eef2f0; color: var(--muted); }

.kpi-value {
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
}

.kpi-hint {
  margin-top: 7px;
  font-size: 12px;
  color: var(--muted);
}

.kpi-hint b { color: var(--primary-dark); font-weight: 700; }

/* ---- Quick actions ---- */
.qa-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.qa {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}

.qa:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  text-decoration: none;
  transform: translateY(-1px);
}

.qa-ico {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 16px;
}

.qa:hover .qa-ico { background: #fff; }
.qa b { display: block; font-size: 13px; font-weight: 750; }
.qa span { display: block; font-size: 11.5px; color: var(--muted); margin-top: 1px; }

/* ---- AI shortcut ---- */
.ai-cta {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-md);
  padding: 20px;
  color: #fff;
  background: linear-gradient(135deg, #0b3f3b 0%, var(--primary) 62%, #16a394 100%);
  box-shadow: var(--shadow-md);
  margin-bottom: 16px;
}

.ai-cta::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 88% 12%, rgba(88, 236, 139, .22), transparent 42%);
  pointer-events: none;
}

.ai-cta h2 { position: relative; z-index: 1; font-size: 17px; font-weight: 800; margin-bottom: 5px; }
.ai-cta p { position: relative; z-index: 1; font-size: 12.75px; color: #cfe9e3; margin-bottom: 14px; max-width: 46ch; }
.ai-cta .btn { position: relative; z-index: 1; background: #fff; color: var(--primary-dark); border-color: #fff; }
.ai-cta .btn:hover { background: #eafaf5; }

.ai-chips { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 13px; }

.ai-chip {
  border: 1px solid rgba(255, 255, 255, .28);
  background: rgba(255, 255, 255, .1);
  color: #eaf7f3;
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 11.75px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease;
}

.ai-chip:hover { background: rgba(255, 255, 255, .22); }

/* ---- Status overview ---- */
.status-list { display: grid; gap: 13px; }

.status-row .status-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 12.5px;
}

.status-row .status-meta b { font-weight: 700; font-variant-numeric: tabular-nums; }

.status-track {
  height: 7px;
  border-radius: 999px;
  background: #eef2f0;
  overflow: hidden;
}

.status-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--primary);
  transition: width .5s cubic-bezier(.2, .7, .3, 1);
}

.status-fill.gold { background: var(--gold); }
.status-fill.blue { background: var(--info); }
.status-fill.gray { background: var(--line-strong); }

/* ---- Activity trend ---- */
.trend {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  height: 132px;
  padding-top: 6px;
}

.trend-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  min-width: 0;
  height: 100%;
}

/* The bar is sized as a percentage of the plot area, so it needs a slot with a resolved
   height to measure against — a percentage against `auto` collapses to min-height. */
.trend-slot {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.trend-bar {
  width: 100%;
  max-width: 34px;
  border-radius: 6px 6px 3px 3px;
  background: linear-gradient(180deg, #2bb39f, var(--primary));
  min-height: 4px;
  transition: opacity .16s ease;
}

.trend-col:hover .trend-bar { opacity: .78; }
.trend-col small { font-size: 10.5px; color: var(--muted); white-space: nowrap; }

/* ---- Activity feed ---- */
.act-list { display: grid; gap: 2px; }

.act {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 10px 8px;
  border-radius: var(--r-sm);
  transition: background .15s ease;
}

.act:hover { background: #f7faf9; }

.act-dot {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 12px;
}

.act-dot.gold { background: var(--accent-soft); color: var(--accent); }
.act-dot.gray { background: #eef2f0; color: var(--muted); }
.act-body { min-width: 0; flex: 1; }
.act-body b { display: block; font-size: 13px; font-weight: 700; }
.act-body span { display: block; font-size: 11.75px; color: var(--muted); margin-top: 1px; }
.act-time { flex: 0 0 auto; font-size: 11px; color: var(--muted); white-space: nowrap; padding-top: 2px; }

/* ---- Toolbar (search + filters) ---- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.toolbar .search {
  position: relative;
  flex: 1;
  min-width: 220px;
  max-width: 420px;
}

.panel-head .toolbar .search { min-width: 300px; }

.toolbar .search input {
  padding-left: 36px;
  min-height: 40px;
  border-radius: var(--r-sm);
  background: #fbfdfc;
}

.toolbar .search input:focus { background: #fff; }

.toolbar .search .s-ico {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 13px;
  pointer-events: none;
}

/* ---- Tables ---- */
.data-table { min-width: 720px; }

.data-table th {
  background: #fbfdfc;
  font-size: 10.75px;
  font-weight: 800;
  letter-spacing: .5px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
}

.data-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
}

/* Column rules suit the dense year-wise analysis tables inside a case; a list of records
   reads better as clean rows. */
.data-table th + th,
.data-table td + td { border-left: 0; }

.data-table tbody tr { transition: background .13s ease; }
.data-table tbody tr:hover td { background: #f7faf9; }

.cell-primary {
  font-weight: 800;
  font-size: 13.5px;
  letter-spacing: -.1px;
  color: var(--primary-dark);
}

.cell-strong { font-weight: 700; color: var(--ink); }
.cell-sub { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; font-weight: 500; }

.count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #f1f5f4;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ---- Status badge with a leading dot ---- */
.badge.dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  margin-right: 6px;
  flex: 0 0 auto;
}

/* ---- Empty & loading states ---- */
.empty {
  text-align: center;
  padding: 46px 20px;
}

.empty-ico {
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 23px;
}

.empty b { display: block; font-size: 15px; font-weight: 750; margin-bottom: 5px; }
.empty p { color: var(--muted); font-size: 13px; max-width: 40ch; margin: 0 auto 16px; }

.skel {
  display: block;
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, #eef2f0 25%, #f6f9f8 50%, #eef2f0 75%);
  background-size: 200% 100%;
  animation: skel 1.3s ease-in-out infinite;
}

@keyframes skel { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }

/* ---- Admin console ---- */
.hub-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.hub {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: #fff;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  text-align: left;
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.hub:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-1px); }

.hub.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1px var(--primary);
}

.hub-ico {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 16px;
}

.hub.active .hub-ico { background: #fff; }
.hub b { display: block; font-size: 13.5px; font-weight: 750; }
.hub span { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; line-height: 1.35; }

/* ---- Ask Policy workspace ---- */
.ai-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 288px;
  gap: 16px;
  align-items: start;
}

.chat-log.tall {
  height: min(58vh, 560px);
  min-height: 340px;
  background: #fbfdfc;
  border-radius: var(--r-sm);
}

.chat-bubble { line-height: 1.5; }

.chat-msg { display: flex; gap: 10px; margin-bottom: 14px; align-items: flex-start; }
.chat-msg.you { flex-direction: row-reverse; }

.chat-avatar {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 800;
}

.chat-avatar.ai { background: linear-gradient(135deg, var(--primary), #16a394); color: #fff; }
.chat-avatar.you { background: #eef2f0; color: var(--muted); }

.chat-name {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .3px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 5px;
}

.chat-msg.you .chat-name { text-align: right; }

.composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.composer:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .1);
}

.composer input {
  border: 0;
  min-height: 34px;
  padding: 6px 4px;
  background: transparent;
}

.composer input:focus { border: 0; outline: none; }

.composer .btn { flex: 0 0 auto; white-space: nowrap; }

.suggest { display: grid; gap: 7px; }

.suggest button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: #fff;
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}

.suggest button:hover { border-color: var(--primary); background: var(--primary-soft); }

.note {
  display: flex;
  gap: 9px;
  padding: 11px 12px;
  border-radius: var(--r-sm);
  background: var(--info-soft);
  border: 1px solid #d3e0ff;
  font-size: 12px;
  color: #24406e;
}

.note .note-ico { flex: 0 0 auto; }

/* ---- Responsive ---- */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hub-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid,
  .ai-shell { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 720px) {
  /* .col-opt cells are hidden at this width, so the record lists no longer need the
     min-width that keeps the dense in-case analysis tables scrollable. */
  .data-table { min-width: 0; }
  .data-table th,
  .data-table td { padding: 11px 12px; }

  .page-head { align-items: flex-start; }
  .page-head h1 { font-size: 21px; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .qa-grid { grid-template-columns: minmax(0, 1fr); }
  .panel-body { padding: 14px; }
  .panel-head { padding: 12px 14px; }
  .kpi-value { font-size: 25px; }
  .toolbar .search { max-width: none; }
}

@media (max-width: 480px) {
  .kpi-grid,
  .hub-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ---- Welcome hero ---- */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-lg);
  border: 1px solid #d5ece1;
  background: linear-gradient(105deg, #eaf7f0 0%, #e6f6ee 42%, #dff3ea 100%);
  padding: 26px 30px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.hero::before {
  content: "";
  position: absolute;
  right: -60px;
  top: -90px;
  width: 420px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .75), transparent 62%);
  pointer-events: none;
}

.hero-text { position: relative; z-index: 1; min-width: 0; flex: 1; }

.hero h1 {
  font-size: 27px;
  font-weight: 800;
  letter-spacing: -.6px;
  color: #0d3b2e;
  margin-bottom: 6px;
}

.hero p { font-size: 13.75px; color: #3f6b5c; margin-bottom: 16px; }

.hero-pills { display: flex; flex-wrap: wrap; gap: 20px; }

.hero-pill { display: flex; align-items: center; gap: 9px; font-size: 12.75px; font-weight: 700; color: #22574a; }

.hero-pill i {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: #fff;
  font-style: normal;
  font-size: 13px;
  box-shadow: 0 1px 3px rgba(13, 59, 46, .12);
}

.hero-art { position: relative; z-index: 1; flex: 0 0 auto; display: flex; align-items: center; gap: 16px; }
.hero-art svg { width: 132px; height: 104px; }
.hero-art b { display: block; font-size: 14px; font-weight: 750; color: #1d5646; line-height: 1.35; }

/* ---- KPI card: icon and label on one line, delta underneath ---- */
.kpi-top { justify-content: flex-start; margin-bottom: 10px; }

.kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 17px;
  order: -1;
}

.kpi-label { font-size: 13px; font-weight: 700; letter-spacing: 0; text-transform: none; color: var(--muted); }

.kpi-icon.indigo { background: #eceafd; color: #5b4cc4; }
.kpi-icon.amber { background: #fdefe1; color: #c2701a; }
.kpi-icon.blue { background: #e6f0fe; color: #2563eb; }

.kpi-delta { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 12px; color: var(--muted); }

.kpi-delta b {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 800;
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.kpi-delta b.down { background: var(--danger-soft); color: var(--danger); }
.kpi-delta b.flat { background: #eef2f0; color: var(--muted); }

/* ---- Panel head icon ---- */
.panel-head .ph-ico {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 14px;
}

.panel-head .ph-left { display: flex; align-items: center; gap: 11px; min-width: 0; }

.link-more {
  font-size: 12.5px;
  font-weight: 750;
  color: var(--primary);
  white-space: nowrap;
}

/* ---- Tinted quick actions ---- */
.qa { align-items: flex-start; gap: 10px; padding: 12px 11px; border-color: transparent; }
.qa b { font-size: 12.5px; }
.qa .qa-body { flex: 1; min-width: 0; }
.qa .qa-arrow { flex: 0 0 auto; color: var(--muted); font-size: 13px; }

.qa.t-green { background: #eaf7f1; }
.qa.t-green .qa-ico { background: #d3efe2; color: #0f766e; }
.qa.t-indigo { background: #efedfd; }
.qa.t-indigo .qa-ico { background: #e0dcfa; color: #5b4cc4; }
.qa.t-blue { background: #e9f1fe; }
.qa.t-blue .qa-ico { background: #d8e6fd; color: #2563eb; }
.qa.t-amber { background: #fdf1e4; }
.qa.t-amber .qa-ico { background: #fae1c8; color: #c2701a; }

.qa:hover { background: #fff; border-color: var(--primary); }
.qa:hover .qa-ico { background: var(--primary-soft); }

/* ---- Inline Ask Policy widget ---- */
.askbox { display: flex; gap: 8px; align-items: center; }

.askbox input {
  min-height: 44px;
  border-radius: 11px;
  padding: 10px 13px;
  background: #fbfdfc;
  font-size: 13px;
}

.askbox input:focus { background: #fff; }

.askbox .send {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 11px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  transition: background .15s ease;
}

.askbox .send:hover { background: var(--primary-dark); }
.askbox .send svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.qlabel { font-size: 12px; font-weight: 750; color: var(--muted); margin: 15px 0 8px; }

.qchips { display: flex; flex-wrap: wrap; gap: 6px; }

.qchip {
  border: 1px solid var(--line);
  background: #fbfdfc;
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 11.75px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}

.qchip:hover { border-color: var(--primary); background: var(--primary-soft); }

/* ---- Donut ---- */
.donut-wrap { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.donut { position: relative; flex: 0 0 auto; width: 124px; height: 124px; }
.donut svg { width: 124px; height: 124px; transform: rotate(-90deg); }
.donut circle { fill: none; stroke-width: 15; stroke-linecap: butt; }

.donut-mid {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
}

.donut-mid b { display: block; font-size: 22px; font-weight: 800; letter-spacing: -.8px; line-height: 1; }
.donut-mid span { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; }

.legend { display: grid; gap: 11px; flex: 1; min-width: 118px; }
.legend div { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.legend i { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.legend .lv { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---- Line chart ---- */
.range { display: flex; gap: 4px; padding: 3px; border-radius: 9px; background: #f1f5f4; }

.range button {
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 750;
  padding: 6px 12px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}

.range button.active { background: var(--primary); color: #fff; }
.range button:hover:not(.active) { color: var(--ink); }

.linechart { width: 100%; height: 190px; display: block; overflow: visible; }
.linechart .grid { stroke: var(--line); stroke-width: 1; }
.linechart .axis { font-size: 10px; fill: var(--muted); }
.linechart .area { fill: url(#lcFill); }
.linechart .line { fill: none; stroke: var(--primary); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.linechart .pt { fill: #fff; stroke: var(--primary); stroke-width: 2.2; }

/* ---- Activity feed dots ---- */
.act-mark { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; margin-top: 6px; background: var(--primary); }
.act-mark.blue { background: var(--info); }
.act-mark.amber { background: var(--gold); }
.act-mark.gray { background: var(--line-strong); }

.act-row { display: flex; gap: 11px; align-items: flex-start; padding: 9px 6px; border-radius: var(--r-sm); }
.act-row:hover { background: #f7faf9; }
.act-row .at { flex: 1; min-width: 0; font-size: 12.5px; }
.act-row .aw { flex: 0 0 auto; font-size: 11px; color: var(--muted); white-space: nowrap; }

/* ---- Dashboard lower grid ---- */
.lower-grid {
  display: grid;
  grid-template-columns: minmax(0, .82fr) minmax(0, 1.18fr);
  gap: 16px;
  align-items: start;
}

@media (max-width: 1240px) {
  .lower-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 820px) {
  .hero { flex-direction: column; align-items: flex-start; padding: 22px; }
  .hero-art { align-self: stretch; justify-content: flex-start; }
  .hero h1 { font-size: 22px; }
  .hero-pills { gap: 12px 18px; }
}
