/*
 * Sphire theme: the shared look of the redesigned pages (Dashboard, Jobs).
 * Dark is the default. <html data-theme="light"> switches to light; /js/ui.js sets it
 * from localStorage before the page draws.
 */

:root {
  --bg: #0D0C0A; --surface: #15130F; --surface-2: #1C1A15;
  --line: #2A261F; --line-soft: #211E18;
  --text: #F3EEE4; --muted: #A69D8B; --faint: #8F8776;
  --gold: #C4A265; --gold-text: #D4B77E; --on-gold: #14110B;
  --paid: #6FCF9F; --due: #F0A35E; --over: #FF8A7A; --info: #8DB3E2;
  --zelle: #C4A265; --card: #7FA7D9; --cash: #8E8676;
  --paid-bg: rgba(111,207,159,.12); --due-bg: rgba(240,163,94,.13); --over-bg: rgba(255,138,122,.13);
  --info-bg: rgba(141,179,226,.12); --gold-bg: rgba(196,162,101,.12);

  /* Older names that shared widgets (appointments.js dialogs and list) still read */
  --border: var(--line); --border2: var(--line); --surface2: var(--surface-2);
  --muted2: var(--faint); --gold-dim: var(--gold);
  --error: var(--over); --success: var(--paid); --amber: var(--due);

  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #F6F3EC; --surface: #FFFFFF; --surface-2: #FAF8F3;
  --line: #E3DCCF; --line-soft: #EEE8DD;
  --text: #1A1712; --muted: #5F5748; --faint: #6E6553;
  --gold: #B08D4C; --gold-text: #7D5F25; --on-gold: #14110B;
  --paid: #1E7A52; --due: #A3570C; --over: #B42318; --info: #2F5F9E;
  --zelle: #B08D4C; --card: #4A78B5; --cash: #A39B8A;
  --paid-bg: rgba(30,122,82,.10); --due-bg: rgba(163,87,12,.10); --over-bg: rgba(180,35,24,.09);
  --info-bg: rgba(47,95,158,.09); --gold-bg: rgba(176,141,76,.14);
  color-scheme: light;
}

/* ── Base ── */
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0; min-height: 100vh;
  background: var(--bg); color: var(--text);
  font-family: 'DM Sans', system-ui, sans-serif; font-size: 14px; line-height: 1.45;
  font-variant-numeric: tabular-nums lining-nums;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
a { color: var(--gold-text); }
a:hover { color: var(--text); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.serif { font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 600; letter-spacing: .005em; }
.lbl { font-size: 11.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.masked { filter: blur(8px); user-select: none; }

/* ── Top bar ── */
.topbar { position: sticky; top: 0; z-index: 100; background: var(--bg); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1360px; margin: 0 auto; padding: 0 40px; display: flex; align-items: center; gap: 40px; }
.brand { display: flex; align-items: baseline; gap: 10px; text-decoration: none; padding: 14px 0; flex: none; }
.brand-name { font-size: 28px; color: var(--gold); line-height: 1; }
.brand-sub { font-size: 10.5px; }
.mainnav { display: flex; gap: 26px; flex: 1; min-width: 0; flex-wrap: wrap; }
.navlink {
  color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500;
  padding: 20px 2px; border-bottom: 2px solid transparent; white-space: nowrap;
}
.navlink:hover { color: var(--text); }
.navlink.on { color: var(--text); border-bottom-color: var(--gold); }
button.navlink { font: inherit; font-size: 14px; font-weight: 500; background: none; border: 0; border-bottom: 2px solid transparent; cursor: pointer; }
.topbar-actions { display: flex; gap: 8px; align-items: center; flex: none; }
.theme-btn .ic-sun { display: none; }
[data-theme="light"] .theme-btn .ic-sun { display: inline; }
[data-theme="light"] .theme-btn .ic-moon { display: none; }

@media (max-width: 1300px) {
  .topbar-in { gap: 24px; }
  .mainnav { gap: 18px; }
}
@media (max-width: 1100px) {
  .topbar-in { padding: 0 24px; }
  .brand-sub { display: none; }
}
@media (max-width: 700px) {
  .topbar-in { padding: 0 16px; gap: 0 12px; flex-wrap: wrap; }
  .brand { padding: 10px 0; flex: 1; }
  /* One row of links that scrolls sideways inside the bar, never the page */
  .mainnav {
    order: 3; flex: 0 0 calc(100% + 32px); margin: 0 -16px; padding: 0 16px;
    flex-wrap: nowrap; overflow-x: auto; gap: 20px; scrollbar-width: none;
  }
  .mainnav::-webkit-scrollbar { display: none; }
  .navlink { padding: 12px 2px; }
  .topbar-actions .navlink { padding: 10px 2px; }
}

/* ── Page frame ── */
.page { max-width: 1360px; margin: 0 auto; padding: 32px 40px 64px; display: flex; flex-direction: column; gap: 24px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-title { margin-top: 6px; font-size: 44px; line-height: 1.05; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
@media (max-width: 1100px) { .page { padding: 28px 24px 56px; } }
@media (max-width: 700px) {
  .page { padding: 20px 16px 48px; gap: 16px; }
  .page-title { font-size: 36px; margin-top: 4px; }
}

/* ── Building blocks ── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }

.btn {
  font: inherit; font-size: 13px; font-weight: 500; color: var(--text);
  background: transparent; border: 1px solid var(--line); border-radius: 8px;
  padding: 0 12px; height: 34px; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
}
.btn:hover { border-color: var(--gold); color: var(--text); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--on-gold); }
.btn.gold:hover { filter: brightness(1.07); color: var(--on-gold); }
.btn.danger { color: var(--over); }
.btn.danger:hover { border-color: var(--over); color: var(--over); }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); border-color: var(--line); }
.btn.icon { width: 34px; padding: 0; }
.btn svg { flex: none; }
/* The eye's slash shows while costs are hidden */
.costs-btn[aria-pressed="true"] .eye-slash { display: none; }

.pill {
  font: inherit; font-size: 13px; font-weight: 500; color: var(--muted);
  background: transparent; border: 1px solid var(--line); border-radius: 999px;
  height: 32px; padding: 0 12px; display: inline-flex; align-items: center; gap: 8px;
  cursor: pointer; white-space: nowrap; flex: none;
}
.pill:hover { color: var(--text); border-color: var(--faint); }
.pill.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.pill .ct { font-size: 12px; opacity: .8; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500;
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex: none; }
.s-paid  { color: var(--paid);  background: var(--paid-bg); }  .s-paid .dot  { background: var(--paid); }
.s-due   { color: var(--due);   background: var(--due-bg); }   .s-due .dot   { background: var(--due); }
.s-over  { color: var(--over);  background: var(--over-bg); }  .s-over .dot  { background: var(--over); }
.s-info  { color: var(--info);  background: var(--info-bg); }  .s-info .dot  { background: var(--info); }
.s-muted { color: var(--muted); background: var(--surface-2); } .s-muted .dot { background: var(--faint); }

.legend { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }

.row-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 4px;
  text-decoration: none; color: var(--text); border-top: 1px solid var(--line-soft);
}
.row-link:hover { background: var(--surface-2); color: var(--text); }

.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  font-weight: 500; text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tbl th button { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.tbl th button:hover { color: var(--text); }
.tbl th button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
.tbl th.r, .tbl td.r { text-align: right; }
.tbl td { padding: 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.tbl tr.sel td { background: var(--gold-bg); }
.tbl tbody tr:hover td { background: var(--surface-2); }
.tbl tbody tr.sel:hover td { background: var(--gold-bg); }
.ck { width: 16px; height: 16px; accent-color: var(--gold); margin: 0; cursor: pointer; vertical-align: middle; }
.flag { display: flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 500; color: var(--over); margin-top: 3px; }

/* Loading placeholders */
@keyframes shimmer { 0% { background-position: -600px 0; } 100% { background-position: 600px 0; } }
.skel {
  display: inline-block; width: 80px; height: 1em; border-radius: 4px; vertical-align: middle;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--line) 50%, var(--surface-2) 75%);
  background-size: 600px 100%; animation: shimmer 1.5s infinite linear;
}
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }

.empty-note { color: var(--muted); font-size: 13px; padding: 12px 4px; }
.error-note { color: var(--over); font-size: 13px; padding: 12px 4px; }

/* appointments.js dialogs pin a dark date/time picker; follow the theme instead */
[data-theme="light"] .appt-input { color-scheme: light; }
