/* AHC Dashboard — what the web version adds to the desktop app's design (styles.css): sign-in, the cases table with
   pagination, the case panel and timeline, money cards, dialogs, and a phone layout. */

body { display: block; user-select: text; background: var(--bg); }
.shell { display: flex; height: 100vh; height: 100dvh; }
a { color: inherit; text-decoration: none; }
.btn { display: inline-flex; align-items: center; gap: 7px; text-decoration: none; }
.btn.wide { width: 100%; justify-content: center; height: 40px; }
.btn.danger { color: var(--rose); }
.btn.danger:hover { border-color: rgba(174, 78, 68, .4); color: var(--rose); }
.btn:disabled { opacity: .55; cursor: default; }
.link.light { color: #A9CBC3; display: inline-flex; align-items: center; gap: 6px; }
.link.light .ic { width: 14px; height: 14px; }
.link.light:hover { color: #fff; }
.select {
  height: 36px; padding: 0 30px 0 11px; border-radius: 10px; border: 1px solid var(--hair-2); background: var(--surface);
  font: inherit; color: var(--ink); appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237A8684' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; background-size: 14px;
}
.select:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(46, 125, 116, .14); }
textarea {
  width: 100%; min-height: 70px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--hair-2); background: #fff;
  font: inherit; color: var(--ink); resize: vertical;
}
textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(46, 125, 116, .14); }

/* ---------- sign in ---------- */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(900px 500px at 10% 0%, rgba(46, 125, 116, .16), transparent 60%),
              radial-gradient(700px 500px at 100% 100%, rgba(217, 174, 95, .14), transparent 60%), var(--bg);
}
.login-card {
  width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 8px; padding: 30px 28px 24px;
  background: var(--surface); border: 1px solid var(--hair); border-radius: 22px; box-shadow: var(--shadow-lg);
}
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.login-brand h1 { font-size: 21px; }
.brand-mark.big svg { width: 48px; height: 48px; display: block; }
.login-card label { font-size: 12.5px; font-weight: 500; color: var(--ink-2); margin-top: 6px; }
.login-card input {
  height: 42px; padding: 0 13px; border-radius: 11px; border: 1px solid var(--hair-2); background: #fff; font-size: 14px;
}
.login-card .btn { margin-top: 14px; }
.login-error { color: var(--rose); background: var(--rose-50); border-radius: 10px; padding: 9px 12px; font-size: 12.5px; margin-top: 8px; }
.hint.center { text-align: center; display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 12px; }
.hint.center .ic { width: 13px; height: 13px; }

/* ---------- sidebar additions ---------- */
.sidebar { overflow-y: auto; }
.nav-item { text-decoration: none; }
.nav-label.spaced { margin-top: 20px; }
.nav-count {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; display: grid; place-items: center;
  font-size: 11px; font-weight: 650; background: #C9584C; color: #fff;
}
.nav-count.amber { background: #C8902F; }
.foot-user { display: flex; align-items: center; gap: 9px; margin-top: 4px; }
.foot-user-text { display: flex; flex-direction: column; min-width: 0; }
.foot-user-text b { color: #fff; font-weight: 600; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.foot-user-text small { color: #85B0A7; font-size: 11px; }
.avatar.small { width: 28px; height: 28px; border-radius: 8px; font-size: 11px; }
.foot-actions { display: flex; gap: 10px; margin-top: 2px; }
.watch-dot.stopped { background: #EB9C91; box-shadow: 0 0 0 3px rgba(235, 156, 145, .2); }
.topbar, .scrim { display: none; }

/* ---------- dashboard ---------- */
.link-card { display: block; cursor: pointer; color: inherit; }
.kpi.danger .kpi-icon { background: var(--rose-50); color: var(--rose); }
.kpi.danger.hot { border-color: rgba(174, 78, 68, .35); background: linear-gradient(180deg, #FFF8F6, var(--surface)); }
.kpi.danger.hot .kpi-value { color: var(--rose); }
.money { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.money-card {
  display: flex; flex-direction: column; gap: 2px; padding: 13px 16px; border-radius: 14px;
  background: linear-gradient(180deg, #FBF7EF, #F6F0E4); border: 1px solid rgba(217, 174, 95, .25);
}
.money-card b { font-size: 21px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.money-label { font-size: 11.5px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
.money-card small { color: var(--muted); font-size: 11.5px; }
.money-card.good b { color: var(--teal-700); }
.money-card.warn { cursor: pointer; transition: box-shadow .15s; }
.money-card.warn:hover { box-shadow: var(--shadow); }
.money-card.warn.has b { color: var(--amber); }
.dash-grid.even { grid-template-columns: 1fr 1fr; }
.row.clickable { cursor: pointer; grid-template-columns: 34px minmax(0, 1fr) auto; }
.days {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; white-space: nowrap;
  font-size: 11.5px; font-weight: 650; background: #EEEBE4; color: var(--ink-2); font-variant-numeric: tabular-nums;
}
.days.ahc { background: var(--rose-50); color: var(--rose); }
.days.attorney { background: var(--amber-50); color: var(--amber); }

/* status badges */
.badge.s-ahc { background: var(--amber-50); color: var(--amber); }
.badge.s-attorney { background: var(--blue-50); color: var(--blue); }
.badge.s-agreed { background: #F4EBD6; color: #8A6417; }
.badge.s-paid { background: var(--teal-100); color: var(--teal-700); }
.badge.s-closed, .badge.s-open { background: #EEEBE4; color: var(--muted); }
.badge.review { background: var(--amber-50); color: var(--amber); }

/* ---------- toolbars, tables, pagination ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.toolbar.wrap { flex-wrap: wrap; }
.toolbar .search { flex: 1; min-width: 220px; max-width: 420px; }
.segmented.scroll { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.segmented.scroll::-webkit-scrollbar { display: none; }
.seg { white-space: nowrap; }
.grid-table { width: 100%; border-collapse: collapse; table-layout: auto; }
.grid-table th {
  text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap;
  color: var(--muted); background: #FAF7F1; padding: 11px 12px; border-bottom: 1px solid var(--hair);
}
.grid-table td { padding: 12px; border-bottom: 1px solid var(--hair); font-size: 12.5px; vertical-align: top; }
.grid-table tr:last-child td { border-bottom: 0; }
.grid-table tbody tr.click { cursor: pointer; }
.grid-table tbody tr.click:hover td { background: var(--teal-50); }
.grid-table tr.hot td:first-child { box-shadow: inset 3px 0 0 var(--rose); }
.grid-table .r { text-align: right; }
.grid-table td.r { font-variant-numeric: tabular-nums; white-space: nowrap; }
.grid-table .main { font-weight: 600; color: var(--ink); }
.grid-table small, .grid-table .sub2 { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; font-weight: 400; }
.grid-table .clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 340px; }
.grid-table .actions { white-space: nowrap; text-align: right; }
.grid-table .actions .icon-btn { display: inline-grid; }
.table-wrap.flat { box-shadow: none; }
.skeleton td { color: transparent !important; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.pager .count { color: var(--muted); font-size: 12.5px; }
.pages { display: flex; align-items: center; gap: 4px; }
.page-btn {
  min-width: 34px; height: 34px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--hair-2); background: var(--surface);
  cursor: pointer; font-weight: 500; font-variant-numeric: tabular-nums; display: inline-flex; align-items: center; justify-content: center;
}
.page-btn .ic { width: 15px; height: 15px; }
.page-btn:hover:not(:disabled) { border-color: var(--teal); color: var(--teal-700); }
.page-btn.active { background: var(--teal); border-color: var(--teal-600); color: #fff; font-weight: 600; }
.page-btn:disabled { opacity: .4; cursor: default; }
.pages .gap { color: var(--muted); padding: 0 4px; }
.per-page { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; }
.per-page .select { height: 34px; }

/* ---------- case panel ---------- */
.drawer-scrim { position: fixed; inset: 0; background: rgba(23, 40, 38, .32); backdrop-filter: blur(2px); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(720px, 100vw); z-index: 41; background: var(--bg);
  box-shadow: -20px 0 50px -20px rgba(23, 67, 63, .35); transform: translateX(100%); transition: transform .25s cubic-bezier(.2, .8, .2, 1);
  overflow-y: auto;
}
.drawer.open { transform: none; }
.drawer-inner { padding: 22px 26px 40px; }
.case-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.case-head h1 { font-size: 24px; }
.case-head .sub { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.case-status {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 14px 16px; border-radius: 14px; margin-bottom: 14px;
  background: var(--surface); border: 1px solid var(--hair); box-shadow: var(--shadow);
}
.case-status .select { min-width: 250px; }
.case-status .spacer { flex: 1; }
.steps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 14px; }
.step { padding: 11px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--hair); min-width: 0; }
.step span { display: block; font-size: 10.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.step b { display: block; font-size: 14px; font-weight: 650; margin-top: 3px; overflow-wrap: anywhere; }
.step.empty-step b { color: #B9BFBD; font-weight: 500; }
.step.on { border-color: rgba(46, 125, 116, .35); background: linear-gradient(180deg, #F4FAF8, var(--surface)); }
.section { background: var(--surface); border: 1px solid var(--hair); border-radius: 14px; padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px; }
.fact span { display: block; font-size: 11px; color: var(--muted); font-weight: 500; }
.fact b { display: block; font-weight: 500; overflow-wrap: anywhere; }
.fact b:empty::after { content: "—"; color: #B9BFBD; }
.fact input {
  width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--hair-2); border-radius: 9px; background: #fff; margin-top: 2px;
}
.fact.full { grid-column: 1 / -1; }
.timeline { display: flex; flex-direction: column; }
.tl { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; padding: 9px 0; border-top: 1px solid var(--hair); }
.tl:first-child { border-top: 0; }
.tl-icon { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--teal-50); color: var(--teal-700); }
.tl-icon .ic { width: 14px; height: 14px; }
.tl.reply .tl-icon { background: var(--blue-50); color: var(--blue); }
.tl.note .tl-icon { background: #F4EBD6; color: #8A6417; }
.tl.status .tl-icon, .tl.edit .tl-icon, .tl.merge .tl-icon { background: #EEEBE4; color: var(--ink-2); }
.tl-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.tl-meta { color: var(--muted); font-size: 11.5px; margin-top: 1px; }
.mail { padding: 11px 0; border-top: 1px solid var(--hair); }
.mail:first-child { border-top: 0; padding-top: 2px; }
.mail-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mail-top b { font-weight: 600; }
.mail-meta { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.mail-detail { margin-top: 4px; color: var(--ink-2); }
.files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.file-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 9px; font-size: 12px; font-weight: 500;
  background: #F4F1EA; border: 1px solid var(--hair); color: var(--ink-2); cursor: pointer;
}
.file-chip:hover { border-color: var(--teal); color: var(--teal-700); }
.file-chip .ic { width: 13px; height: 13px; }
.note-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.note-form .btn { align-self: flex-end; }
.merged-banner { background: var(--amber-50); color: var(--amber); padding: 10px 14px; border-radius: 12px; margin-bottom: 14px; font-weight: 500; }

/* ---------- dialog ---------- */
.modal-scrim { position: fixed; inset: 0; z-index: 60; background: rgba(23, 40, 38, .38); backdrop-filter: blur(2px); display: grid; place-items: center; padding: 16px; }
.modal { width: 100%; max-width: 460px; background: var(--surface); border-radius: 18px; padding: 22px; box-shadow: var(--shadow-lg); }
.modal h2 { font-size: 16px; margin-bottom: 4px; }
.modal .form-col { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.modal input {
  height: 38px; padding: 0 12px; border: 1px solid var(--hair-2); border-radius: 10px; background: #fff; width: 100%;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.pick-list { display: flex; flex-direction: column; max-height: 280px; overflow-y: auto; margin-top: 8px; }
.pick { text-align: left; padding: 9px 11px; border-radius: 10px; border: 1px solid transparent; background: none; cursor: pointer; }
.pick:hover, .pick.on { background: var(--teal-50); border-color: var(--teal-100); }
.pick small { display: block; color: var(--muted); }

/* ---------- users ---------- */
.add-user { display: grid; grid-template-columns: 1fr 1.3fr 120px 1.4fr auto; gap: 8px; margin-top: 14px; }
.add-user input { height: 36px; padding: 0 11px; border: 1px solid var(--hair-2); border-radius: 10px; background: #fff; min-width: 0; }
.form input.num.wide { width: 120px; }
.role-select { height: 32px; }
.toast { z-index: 80; }

/* ---------- smaller screens ---------- */
@media (max-width: 1100px) {
  .money { grid-template-columns: repeat(2, 1fr); }
  .dash-grid.even { grid-template-columns: 1fr; }
  .add-user { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .hide-md { display: none; }
}
@media (max-width: 760px) {
  .shell { flex-direction: column; height: auto; min-height: 100vh; }
  .topbar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30; padding: 10px 14px;
    padding-top: max(10px, env(safe-area-inset-top));
    background: linear-gradient(180deg, #1B4C47, #163F3B); color: #fff;
  }
  .topbar-title { flex: 1; font-weight: 650; font-size: 15px; }
  .icon-btn.light { color: #fff; }
  .icon-btn.light:hover { background: rgba(255, 255, 255, .1); border-color: transparent; }
  .sidebar { position: fixed; z-index: 50; top: 0; bottom: 0; left: 0; width: 260px; transform: translateX(-100%); transition: transform .22s; }
  .sidebar.open { transform: none; }
  .scrim:not(.hidden) { display: block; position: fixed; inset: 0; z-index: 45; background: rgba(23, 40, 38, .35); }
  main { overflow: visible; }
  .page { padding: 16px 14px 28px; }
  .hero { flex-direction: column; align-items: flex-start; gap: 14px; padding: 20px; }
  .hero h1 { font-size: 24px; }
  .hero-side { align-items: flex-start; width: 100%; }
  .kpis, .money { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-value { font-size: 26px; }
  .money-card b { font-size: 18px; }
  .page-head { flex-direction: column; gap: 10px; }
  .toolbar .search { max-width: none; width: 100%; flex-basis: 100%; }
  .toolbar .select { flex: 1; min-width: 140px; }
  .hide-sm { display: none; }
  .grid-table td, .grid-table th { padding: 10px 9px; }
  .grid-table .clamp { max-width: 200px; }
  .table-wrap { overflow-x: auto; }
  .drawer { width: 100vw; }
  .drawer-inner { padding: 16px 14px 32px; }
  .steps { grid-template-columns: repeat(2, 1fr); }
  .facts { grid-template-columns: 1fr; }
  .case-status .select { min-width: 0; flex: 1; }
  .form { grid-template-columns: 1fr; }
  .form > label:not(.switch) { text-align: left; }
  .test-row { padding-left: 0; flex-wrap: wrap; }
  .add-user { grid-template-columns: 1fr; }
  .pager { justify-content: center; }
}
.link-text { color: var(--teal-700); }
.link-text:hover { text-decoration: underline; }
.pill-link { white-space: nowrap; }
.grid-table td:first-child { min-width: 170px; }
.show-sm { display: none; }
@media (max-width: 760px) {
  .case-status .select { flex-basis: 100%; }
  .grid-table td:first-child { min-width: 0; }
  .show-sm { display: block; }
  #casesTable .wide-col { display: none; }
  .table-wrap.cases-wrap { overflow-x: visible; }
}

/* ---------- loading, jobs, setup ---------- */
.loadbar { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 90; pointer-events: none; opacity: 0; transition: opacity .2s; overflow: hidden; }
.loadbar::before { content: ""; position: absolute; inset: 0; width: 40%; background: linear-gradient(90deg, transparent, var(--gold), transparent); animation: slide 1s ease-in-out infinite; }
.loadbar.on { opacity: 1; transition-delay: .25s; }  /* only shows if a request takes longer than a blink */
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
.table-wrap { transition: opacity .15s; }
.table-wrap.loading { opacity: .55; pointer-events: none; }

.tray { position: fixed; right: 20px; bottom: 20px; z-index: 70; display: flex; flex-direction: column; gap: 8px; width: min(340px, calc(100vw - 32px)); }
.job {
  display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 12px 12px 12px 14px;
  background: var(--surface); border: 1px solid var(--hair); border-radius: 14px; box-shadow: var(--shadow-lg); animation: rise .2s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.job-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--teal-50); color: var(--teal-700); }
.job-icon .ic { width: 15px; height: 15px; }
.job.queued .job-icon .ic, .job.running .job-icon .ic { animation: spin 1.1s linear infinite; }
.job.done .job-icon { background: var(--teal-100); }
.job.failed .job-icon { background: var(--rose-50); color: var(--rose); }
.job-main b { display: block; font-size: 13px; }
.job-main small { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; overflow-wrap: anywhere; }
.job.failed .job-main small { color: var(--rose); }
.job .link { padding: 0; margin-top: 4px; }
.bar { height: 5px; border-radius: 999px; background: #EAE5DA; margin-top: 8px; overflow: hidden; position: relative; }
.bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #5DB0A2, var(--teal)); transition: width .4s ease; }
.bar.indeterminate span { position: absolute; animation: slide 1.2s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn.working .ic { animation: spin 1.1s linear infinite; }

.setup-banner {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px; margin-bottom: 16px; padding: 16px 18px;
  border-radius: 16px; background: linear-gradient(180deg, #FFF8EC, #FBF1DE); border: 1px solid rgba(217, 174, 95, .45); box-shadow: var(--shadow);
}
.setup-banner b { display: block; font-size: 14px; }
.setup-banner small { display: block; color: var(--ink-2); margin-top: 2px; }
.setup-banner .card-icon { background: #F4E3C1; color: #8A6417; }
.nav-dot { margin-left: auto; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 3px rgba(217, 174, 95, .25); }

.card-head .conn-pill { margin-left: auto; }
.conn-pill { flex: none; padding: 4px 11px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #EEEBE4; color: var(--muted); white-space: nowrap; }
.conn-pill.ok { background: var(--teal-100); color: var(--teal-700); }
.conn-pill.bad { background: var(--rose-50); color: var(--rose); }
.card.dirty { border-color: rgba(217, 174, 95, .55); }
.section-save:disabled { opacity: .45; }
.howto { color: var(--ink-2); font-size: 12.5px; }
.howto summary { cursor: pointer; color: var(--teal-700); font-weight: 500; width: fit-content; }
.howto ol { margin: 8px 0 6px; padding-left: 20px; line-height: 1.7; }
.howto p { margin: 0; color: var(--muted); }
.inline.end { justify-content: flex-end; margin-top: 8px; }
.test-row { flex-wrap: wrap; }
.test-row .test-result { flex-basis: 100%; }
@media (min-width: 761px) { .test-row .test-result { flex-basis: auto; } }

@media (max-width: 760px) {
  .setup-banner { grid-template-columns: 1fr; }
  .setup-banner .card-icon { display: none; }
  .tray { right: 12px; bottom: 12px; }
  .card-head { flex-wrap: wrap; }
}
.field-hint { color: var(--muted); font-size: 12px; margin-top: -6px; }
.status-line { margin: 6px 0 0; font-size: 12.5px; font-weight: 500; color: var(--teal-700); }
.section-head .hint { margin-top: 2px; }
