:root {
  color-scheme: light;
  --navy: #0b1a4a;
  --navy-deep: #050a30;
  --accent: #b3122e;
  --brand-red: #ad2323;   /* the red in the VetsForever logo; footer in both themes (white text 6.9:1) */
  --ink: #1d2433;
  --muted: #5d6677;
  --line: #dfe3ea;
  --bg: #f4f6f9;
  --card: #ffffff;
  --ok: #1f7a4d;
  --ok-bg: #e5f4ec;
  --warn-bg: #fff5d9;
  --warn-ink: #6a4a00;
  --warn-line: #f0dc9a;
  --err: #a8182e;
  --err-bg: #fde8eb;
  --link: #0b1a4a;
  --link-hover: #b3122e;
  --primary: #0b1a4a;
  --primary-hover: #050a30;
  --soft: #eef2ff;
  --soft-2: #f2f4f7;
  --pill-bg: #eef1f6;
  --overlay: rgba(244, 246, 249, .9);
  --field-bg: #ffffff;
  --field-line: #858fa1;
  --step-done: #0b1a4a;
  --step-current: #b3122e;
  --focus: #8fb0ff;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Dark theme: used when the client picks it, or when their device is set to
   dark and they have not picked light. The header keeps its navy brand colour. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ink: #e7eaf1; --muted: #a3acbf; --line: #2a3450; --bg: #0b1020; --card: #141b2e;
    --ok: #6fd6a2; --ok-bg: #12301f; --warn-bg: #3a300d; --warn-ink: #f2d47e; --warn-line: #5b4b16;
    --err: #ff8fa0; --err-bg: #3b1520; --link: #a9c1ff; --link-hover: #ffffff;
    --primary: #3a57b8; --primary-hover: #2c4699; --soft: #1d2a4f; --soft-2: #1b2235; --pill-bg: #232c44; --overlay: rgba(11, 16, 32, .9);
    --field-bg: #0f1627; --field-line: #64739c; --step-done: #7f9bff; --step-current: #ff6b81;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e7eaf1; --muted: #a3acbf; --line: #2a3450; --bg: #0b1020; --card: #141b2e;
  --ok: #6fd6a2; --ok-bg: #12301f; --warn-bg: #3a300d; --warn-ink: #f2d47e; --warn-line: #5b4b16;
  --err: #ff8fa0; --err-bg: #3b1520; --link: #a9c1ff; --link-hover: #ffffff;
  --primary: #3a57b8; --primary-hover: #2c4699; --soft: #1d2a4f; --soft-2: #1b2235; --pill-bg: #232c44; --overlay: rgba(11, 16, 32, .9);
  --field-bg: #0f1627; --field-line: #64739c; --step-done: #7f9bff; --step-current: #ff6b81;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); line-height: 1.55; }
a { color: var(--link); }
a:hover { color: var(--link-hover); }
h1, h2 { line-height: 1.25; margin: 0 0 .6rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.1rem; }
p { margin: 0 0 .75rem; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.test-banner { background: var(--warn-bg); color: var(--warn-ink); text-align: center; font-size: .9rem; padding: 6px 12px; border-bottom: 1px solid var(--warn-line); }

.site-header { background: var(--navy-deep); color: #fff; }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 10px; padding-bottom: 10px; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; }
.brand img { height: 52px; width: auto; }
.brand-sub { font-size: .95rem; letter-spacing: .04em; opacity: .9; }
.header-user { display: flex; align-items: center; gap: 14px; font-size: .95rem; }
.header-user .link-button { color: #fff; }
.main-nav { display: flex; gap: 4px; overflow-x: auto; }
.main-nav a { color: #dfe5ff; text-decoration: none; padding: 10px 14px; border-bottom: 3px solid transparent; white-space: nowrap; }
.main-nav a:hover { color: #fff; }
.main-nav a[aria-current="page"] { color: #fff; border-bottom-color: var(--accent); }

.main { padding-top: 24px; padding-bottom: 40px; min-height: 60vh; }
.page-title { margin-bottom: 1rem; }
.grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.col-main, .col-side { display: grid; gap: 20px; }
@media (max-width: 820px) { .grid { grid-template-columns: 1fr; } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.auth-page .main { display: flex; justify-content: center; align-items: flex-start; }
form + p { margin-top: 14px; }
.auth-card { width: 100%; max-width: 460px; margin: 24px auto; }

label { display: block; font-weight: 600; margin: 12px 0 6px; font-size: .95rem; }
input[type="email"], input[type="text"], input[type="password"], select, textarea {
  width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--field-line); border-radius: 8px; background: var(--field-bg); color: var(--ink);
}
input[type="file"] { font: inherit; width: 100%; }
input:focus, select:focus, textarea:focus, .button:focus, a:focus, button:focus { outline: 3px solid var(--focus); outline-offset: 2px; }
#id_code { font-size: 1.5rem; letter-spacing: .35em; text-align: center; }

.button { display: inline-block; font: inherit; font-weight: 600; text-decoration: none; text-align: center; cursor: pointer;
  padding: 10px 18px; border-radius: 8px; border: 1px solid var(--link); background: var(--card); color: var(--link); margin-top: 14px; }
.button:hover { background: var(--soft); color: var(--link); }
.button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.button.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.button.block { display: block; width: 100%; }
.button.small { padding: 6px 12px; margin-top: 0; font-size: .9rem; }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--link); text-decoration: underline; cursor: pointer; }
.auth-links { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; font-size: .95rem; flex-wrap: wrap; }
.auth-links form { margin: 0; }

.form-error, .flash-error { background: var(--err-bg); color: var(--err); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.form-error p { margin: 0; }
.field-error { color: var(--err); font-size: .9rem; margin: 6px 0 0; }
.flash { border-radius: 8px; padding: 10px 14px; margin: 0 0 12px; }
.flash-success { background: var(--ok-bg); color: var(--ok); }
.dev-code { background: var(--warn-bg); border-radius: 8px; padding: 10px 12px; }

.badge { display: inline-block; min-width: 1.4em; padding: 0 6px; border-radius: 999px; background: var(--accent); color: #fff; font-size: .8rem; text-align: center; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--pill-bg); color: var(--muted); font-size: .85rem; }
.pill-open { background: var(--warn-bg); color: var(--warn-ink); }
.pill-paid { background: var(--ok-bg); color: var(--ok); }
.pill-won { background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.pill-lost { background: var(--err-bg); color: var(--err); font-weight: 600; }
.step-result { display: table; margin-top: 6px; }

[hidden] { display: none !important; }

/* Loading animation between pages (loader.js) */
.page-loader { position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 14px; background: var(--overlay); }
.loader-mark { position: relative; width: 104px; height: 104px; display: grid; place-items: center; }
.loader-logo { width: 72px; height: 72px; border-radius: 50%; animation: vf-pulse 1.4s ease-in-out infinite; }
.loader-ring { position: absolute; inset: 0; border-radius: 50%; border: 4px solid var(--line);
  border-top-color: var(--step-current); border-right-color: var(--step-done); animation: vf-spin .9s linear infinite; }
.loader-text { color: var(--muted); font-size: .95rem; letter-spacing: .03em; }
@keyframes vf-spin { to { transform: rotate(360deg); } }
@keyframes vf-pulse { 0%, 100% { transform: scale(.94); } 50% { transform: scale(1.04); } }
@media (prefers-reduced-motion: reduce) {
  .loader-logo, .loader-ring { animation: none; }
}

/* Messages: claim picker above the thread */
.claim-picker { margin: 4px 0 16px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.claim-picker label { margin-top: 0; }
.claim-picker p.small { margin: 0 0 8px; }
.picker-row { display: flex; gap: 10px; align-items: center; }
.picker-row select { flex: 1; min-width: 0; }
.picker-row .button { margin-top: 0; white-space: nowrap; }
.picker-card { margin-bottom: 20px; }
.picker-card .claim-picker { margin: 0; padding-bottom: 0; border-bottom: 0; }
.upload-for { font-weight: 600; margin: 0 0 8px; }

/* Welcome line: client's city and local time */
.welcome-row { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; margin-bottom: 16px; }
.welcome-row .page-title { margin: 0; }
.welcome-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.welcome-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line); color: var(--ink); font-size: .92rem; }
.welcome-chip svg { flex: none; color: var(--step-current); }

/* Claim switcher (clients with more than one claim) */
.claim-switch { margin-bottom: 20px; }
.claim-switch h2 { margin-bottom: 4px; }
.claim-list { list-style: none; padding: 0; margin: 12px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.claim-item { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; height: 100%; box-sizing: border-box;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); text-decoration: none; }
.claim-item:hover { border-color: var(--link); background: var(--soft); color: var(--ink); }
.claim-item.is-selected { border: 2px solid var(--step-current); padding: 11px 13px; background: var(--soft); }
.claim-title { font-weight: 600; }
.claim-when { font-size: .85rem; color: var(--muted); }
.pill-progress { background: var(--warn-bg); color: var(--warn-ink); }
.pill-decided { background: var(--pill-bg); color: var(--ink); }
.h-sub { display: block; font-size: .95rem; font-weight: 400; color: var(--muted); margin-top: 2px; }
@media (max-width: 560px) { .claim-list { grid-template-columns: 1fr; } }

.stepper { list-style: none; padding: 0; margin: 16px 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.step { position: relative; padding-top: 28px; font-size: .92rem; color: var(--muted); }
.step::before { content: ""; position: absolute; top: 9px; left: 0; right: 0; height: 4px; background: var(--line); border-radius: 2px; }
.step-dot { position: absolute; top: 2px; left: 0; width: 18px; height: 18px; border-radius: 50%; background: var(--card); border: 3px solid var(--line); z-index: 1; }
.step-done::before, .step-current::before { background: var(--step-done); }
.step-done .step-dot { background: var(--step-done); border-color: var(--step-done); }
.step-current .step-dot { border-color: var(--step-current); }
.step-current { color: var(--ink); font-weight: 600; }
.step-done { color: var(--ink); }
.step-now { margin: 0; }
@media (max-width: 560px) {
  .stepper { grid-template-columns: 1fr; gap: 14px; }
  .step { padding: 0 0 0 30px; min-height: 20px; }
  .step::before { top: 20px; bottom: -14px; left: 7px; right: auto; width: 4px; height: auto; }
  .step:last-child::before { display: none; }
  .step-dot { top: 1px; }
  .header-user .user-name { display: none; }
  .brand-sub { display: none; }
  .main-nav a { padding: 10px 7px; font-size: .95rem; }
}

.facts { margin: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 20px; }
.fact dt { font-size: .85rem; color: var(--muted); }
.fact dd { margin: 2px 0 0; font-weight: 600; }
@media (max-width: 560px) { .facts { grid-template-columns: 1fr; } }

.rating-row { display: flex; align-items: center; gap: 18px; margin-bottom: 12px; }
.rating-big { font-size: 2.4rem; font-weight: 700; color: var(--link); min-width: 90px; }
.rating-big .muted { font-size: 1rem; font-weight: 400; }
.rating-label { font-weight: 600; margin: 0; }

.table { width: 100%; border-collapse: collapse; margin: 8px 0 12px; font-size: .95rem; }
.table th, .table td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: .85rem; color: var(--muted); font-weight: 600; }
.table .num { text-align: right; }
.table .actions { white-space: nowrap; text-align: right; }
.table .actions a { margin-left: 10px; }
.table .actions .button { margin-left: 6px; }
.table .file-name { overflow-wrap: break-word; font-weight: 600; }
/* On phones, each row becomes a small card with labels, so nothing is cut off. */
@media (max-width: 560px) {
  .table-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tr { border-bottom: 1px solid var(--line); padding: 10px 0; }
  .table-stack td, .table-stack .num { border: 0; padding: 2px 0; text-align: left; }
  .table-stack td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-weight: 400; }
  .table-stack td.file-name::before { content: none; }
  .table-stack .actions { white-space: normal; text-align: left; padding-top: 8px; display: flex; gap: 8px; align-items: center; }
  .table-stack .actions a { margin: 0; }
  .table-stack .actions .button { margin: 0; flex: 1; }
}
.card { overflow-x: auto; }

.adv-name { font-size: 1.15rem; font-weight: 600; margin-bottom: 2px; }
.link-list { margin: 0; padding-left: 18px; }
.link-list li { margin: 4px 0; }
.balance { margin: 0; }

.doc-list { list-style: none; margin: 0; padding: 0; }
.doc-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.doc-list li:last-child { border-bottom: 0; }
.doc-title { margin: 0; font-weight: 600; }

.thread { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 10px; }
.msg { padding: 12px 14px; border-radius: 10px; max-width: 85%; }
.msg-client { background: var(--soft); justify-self: end; }
.msg-staff { background: var(--soft-2); justify-self: start; }
.msg-meta { font-size: .8rem; color: var(--muted); margin: 0 0 4px; }
.msg-body { margin: 0; overflow-wrap: anywhere; }
.reply-form { border-top: 1px solid var(--line); padding-top: 4px; }

.site-footer { background: var(--brand-red); color: #fff; padding: 18px 0; font-size: .9rem; }
.site-footer p { margin: 4px 0; }
.site-footer a, .site-footer a:hover { color: #fff; }
.site-footer a:focus { outline-color: #fff; }
.site-footer .muted { color: rgba(255, 255, 255, .88); }

/* Calendar of booked calls (My claim sidebar) */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.cal-head h2 { margin: 0; }
.cal-nav { display: flex; align-items: center; gap: 6px; }
.cal-month { font-weight: 600; font-size: .95rem; min-width: 8.5em; text-align: center; }
.cal-arrow { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-size: 1.2rem; line-height: 1; }
.cal-arrow:hover { background: var(--soft); color: var(--ink); }
.cal-arrow.is-off { opacity: .35; }
.cal { width: 100%; border-collapse: collapse; table-layout: fixed; margin: 12px 0 6px; }
.cal th { font-size: .75rem; font-weight: 600; color: var(--muted); padding: 4px 0; text-align: center; }
.cal th abbr { text-decoration: none; }
.cal td { text-align: center; padding: 2px 0; }
.cal-day { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; font-size: .9rem;
  color: var(--ink); text-decoration: none; }
.cal-day.out-month { color: var(--muted); opacity: .45; }
.cal-day.is-today { box-shadow: inset 0 0 0 2px var(--step-current); font-weight: 600; }
a.cal-day.has-call { background: var(--primary); color: #fff; font-weight: 600; }
a.cal-day.has-call:hover { background: var(--primary-hover); color: #fff; }
.cal-next { margin: 8px 0 2px; font-size: .92rem; }

/* Meetings */
.meeting-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 12px; }
.meeting { display: flex; align-items: center; justify-content: space-between; gap: 16px;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.meeting-info p { margin: 0; }
.meeting-when { font-weight: 600; }
.meeting-with { margin-top: 4px !important; }
.meeting-join { margin-top: 0; white-space: nowrap; }
@media (max-width: 560px) {
  .meeting { flex-direction: column; align-items: stretch; }
  .meeting-join { width: 100%; }
}

/* Five tabs do not fit one row on a phone: wrap instead of hiding the last ones. */
@media (max-width: 560px) {
  .main-nav { flex-wrap: wrap; overflow-x: visible; row-gap: 0; }
}

/* Theme toggle in the header */
.header-actions { display: flex; align-items: center; gap: 14px; }
.theme-form { margin: 0; }
.install-button, .theme-toggle { display: inline-flex; align-items: center; gap: 6px; background: none; border: 1px solid rgba(255, 255, 255, .35);
  color: #fff; font: inherit; font-size: .9rem; padding: 5px 12px; border-radius: 999px; cursor: pointer; }
.install-button:hover, .theme-toggle:hover { background: rgba(255, 255, 255, .12); }
.install-button svg, .theme-toggle svg { flex: none; }
.install-help { color: #fff; font-size: .9rem; margin: 0 auto; padding-bottom: 10px; }
.theme-icon-sun { display: none; }
.is-dark .theme-icon-sun { display: inline; }
.is-dark .theme-icon-moon { display: none; }
@media (max-width: 560px) {
  .header-actions { gap: 10px; }
  .install-button, .theme-toggle { padding: 6px; border-radius: 50%; }
  .install-button .install-label, .theme-toggle .theme-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
