/* ============================================================
   Vidasi app: white and clean, in the vidasi.dev colours.
   Lime is only ever a fill with ink on top; as text on white it fails contrast.
   Layout: a fixed left sidebar on wide screens, a top bar with a menu on phones.
   ============================================================ */

:root {
  color-scheme: light;

  --bg: #ffffff;
  --surface: #f7f7f4;         /* panels, table heads, a hair warmer than grey */
  --surface-2: #efefea;
  --line: #e4e4de;
  --line-strong: #cfcfc7;
  --ink: #0c0c0e;
  --muted: #62626b;
  --accent: #c6ff3d;          /* fills only */
  --accent-strong: #b3ef1f;   /* hover on lime fills */
  --accent-soft: #f0ffd1;     /* active nav, highlights */
  --good: #1a8a4f;
  --good-soft: #e3f5ea;
  --mid: #9a5b00;
  --mid-soft: #fdf1dc;
  --bad: #c4362b;
  --bad-soft: #fbe7e5;
  --info-soft: #e8f0fb;

  /* The menu, in the website's dark palette (vidasi.dev's --bg, --panel, --line, --fg, --muted). */
  --side-bg: #0c0c0e;
  --side-hover: #1c1c20;
  --side-line: #2a2a30;
  --side-fg: #f2f2f0;
  --side-muted: #8d8d96;

  --font: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --radius: 12px;
  --radius-sm: 8px;
  --gutter: clamp(16px, 3vw, 32px);
  --sidebar: 232px;
  --sidebar-rail: 72px;
  --ease-nav: cubic-bezier(0.32, 0.72, 0, 1);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.2; text-wrap: balance; margin: 0; }
h1 { font-size: clamp(1.6rem, 3vw, 2.1rem); font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.1rem; font-weight: 700; letter-spacing: -0.01em; }
h3 { font-size: 0.95rem; font-weight: 700; }
p { margin: 0; }
small { font-size: 0.82rem; }

a { color: var(--ink); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }

.mono, code, pre { font-family: var(--mono); }
.num, .mono { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }
.icon { flex: none; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 7px 16px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--ink);
  font: 600 0.92rem/1.2 var(--font);
  text-decoration: none;
  border: 1px solid var(--ink);
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--accent-strong); }
.btn-secondary { background: var(--bg); border-color: var(--line-strong); }
.btn-secondary:hover { background: var(--surface); border-color: var(--ink); }
.btn-danger { background: var(--bg); color: var(--bad); border-color: currentColor; }
.btn-danger:hover { background: var(--bad-soft); }
.btn-small { min-height: 30px; padding: 4px 12px; font-size: 0.85rem; }
.btn-link { background: none; border: 0; padding: 0; font: inherit; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.btn-link.danger { color: var(--bad); }

/* ---------- plain pages: sign-in, invitations, errors ---------- */

.plain-main {
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  align-content: center; /* the logo and the panel sit in the middle of the screen */
  padding-block: clamp(24px, 6vh, 64px);
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
  display: grid;
  gap: 28px;
}
.logo { font: 700 26px/1 var(--font); letter-spacing: -0.03em; color: var(--ink); text-decoration: none; }
.logo > span:last-child { color: var(--accent); }
.plain-logo { justify-self: center; font-size: 36px; }

.panel {
  display: grid;
  gap: 16px;
  padding: clamp(24px, 5vw, 36px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}
.panel p { max-width: 60ch; }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.detail {
  margin: 0;
  padding: 16px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  overflow-x: auto;
  white-space: pre-wrap;
}

/* ---------- app frame ---------- */

.app { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  display: flex;
  flex-direction: column;
  border-right: 2px solid var(--accent);
  background: var(--side-bg);
  color: var(--side-fg);
  padding: 20px 12px 16px;
  z-index: 20;
}
.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 0 10px 18px; margin-bottom: 12px; border-bottom: 2px solid var(--accent); }
.menu-toggle { display: none; background: none; border: 0; padding: 6px; cursor: pointer; color: var(--side-fg); }
.sidebar .logo { color: var(--side-fg); }
.nav-burger { display: inline-grid; place-items: center; width: 34px; height: 34px; margin: -4px -6px -4px 0; background: none; border: 0; border-radius: 8px; color: var(--side-muted); cursor: pointer; }
.nav-burger:hover { color: var(--side-fg); background: var(--side-hover); }
.nav-collapsed .nav-burger { display: none; }
@media (max-width: 860px) { .nav-burger { display: none; } }
.logo-expand { display: none; background: none; border: 0; padding: 4px 6px; margin: -4px -6px; border-radius: 6px; cursor: pointer; position: relative; }
.logo-expand:hover { background: var(--side-hover); }
.sidebar :focus-visible { outline-color: var(--accent); }

.nav { display: flex; flex-direction: column; flex: 1; gap: 8px; min-height: 0; }
.nav ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; } /* minmax: the hidden words mustn't hold the rail open */
.nav > ul:first-child { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--side-line) transparent; } /* a long menu scrolls; the foot stays put */
.nav > ul:first-child a:focus-visible { outline-offset: -2px; } /* inside the scroller, so it isn't clipped */
.nav-foot { margin-top: auto !important; padding-top: 12px !important; border-top: 1px solid var(--side-line) !important; }
.nav a, .nav-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--side-fg);
  text-decoration: none;
  font: 500 0.93rem/1.3 var(--font);
  background: none;
  border: 0;
  cursor: pointer;
  text-align: left;
}
.nav a:hover, .nav-button:hover { background: var(--side-hover); }
.nav a[aria-current="page"] { background: var(--accent); color: var(--ink); font-weight: 700; }
.nav .icon { opacity: 0.85; }
.nav a[aria-current="page"] .icon { opacity: 1; }
.nav .nav-user { padding: 8px 6px; font-weight: 600; font-size: 0.88rem; }
.nav-user .who { display: grid; min-width: 0; }
.nav-user .who, .nav-user small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-user small { color: var(--side-muted); font-weight: 400; }
.nav-user[aria-current="page"] small { color: inherit; opacity: 0.7; }

/* A person's picture, or their initials. */
.avatar { flex: none; width: 30px; height: 30px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); font: 700 0.72rem/1 var(--font); letter-spacing: 0.02em; }
.sidebar .avatar { background: var(--side-hover); color: var(--side-fg); border-color: var(--side-line); }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-lg { width: 88px; height: 88px; font-size: 1.6rem; }
.avatar-edit { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 20px; }
.avatar-edit .avatar-form { flex: 1 1 260px; }
.dropzone { position: relative; display: grid; justify-items: center; gap: 4px; padding: 18px 16px; border: 1.5px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface); text-align: center; cursor: pointer; transition: background 0.15s, border-color 0.15s; }
.dropzone:hover, .dropzone.is-over { border-color: var(--ink); background: var(--accent-soft); }
.dropzone:focus-within { outline: 2px solid var(--ink); outline-offset: 2px; }
.dropzone input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; } /* still a real file input: clicks and drops land on it */
.dropzone .icon { color: var(--muted); }
.cropper { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 20px; }
.crop-stage { position: relative; flex: none; width: 200px; height: 200px; overflow: hidden; border-radius: var(--radius-sm); background: var(--surface-2); cursor: grab; touch-action: none; user-select: none; }
.crop-stage:active { cursor: grabbing; }
.crop-stage img { position: absolute; top: 0; left: 0; max-width: none; transform-origin: 0 0; pointer-events: none; -webkit-user-drag: none; }
.crop-stage::after { content: ''; position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 0 200px rgb(12 12 14 / 0.5); pointer-events: none; } /* what's kept: the circle */
.cropper .stack { flex: 1 1 160px; }
.crop-zoom { display: grid; gap: 4px; font-weight: 500; }
.crop-zoom input { width: 100%; accent-color: var(--ink); }
.person { display: inline-flex; align-items: center; gap: 10px; }

/* ---------- the menu collapsed to icons (wide screens only) ---------- */

@media (min-width: 861px) {
  /*
   * Only what can move smoothly changes: the widths, the links' left padding (the icons
   * glide to the middle of the rail) and the words' opacity. The words shrink away inside
   * their links rather than jumping out of the layout, and stay for screen readers.
   * .nav-animating is on <body> only while app.js toggles, so pages never animate on load.
   */
  .nav a > span:not(.avatar), .nav-button > span { min-width: 0; overflow: hidden; white-space: nowrap; }
  .nav-animating .sidebar { transition: width 0.3s var(--ease-nav), padding 0.3s var(--ease-nav); }
  .nav-animating .main { transition: margin-left 0.3s var(--ease-nav), max-width 0.3s var(--ease-nav); }
  .nav-animating .nav a, .nav-animating .nav-button { transition: padding 0.3s var(--ease-nav); }
  .nav-animating .nav a > span:not(.avatar), .nav-animating .nav-button > span { transition: opacity 0.2s ease 0.1s; }
  .nav-animating.nav-collapsed .nav a > span:not(.avatar), .nav-animating.nav-collapsed .nav-button > span { transition: opacity 0.1s ease; }
  .nav-animating .logo-home, .nav-animating .logo-expand, .nav-animating .nav-burger { animation: nav-fade 0.25s ease 0.08s both; }

  .nav-collapsed .sidebar { width: var(--sidebar-rail); padding-inline: 10px; }
  .nav-collapsed .main { margin-left: var(--sidebar-rail); max-width: calc(1240px + var(--sidebar-rail)); }
  .nav-collapsed .sidebar-top { justify-content: center; padding-inline: 0; }
  .nav-collapsed .logo-home { display: none; }
  .nav-collapsed .logo-expand { display: inline-block; }
  /* The rail is 50px inside: 16px either side of an 18px icon, 10px either side of a 30px picture. */
  .nav-collapsed .nav a, .nav-collapsed .nav-button { padding-left: 16px; padding-right: 0; position: relative; }
  .nav-collapsed .nav .nav-user { padding-left: 10px; }
  .nav-collapsed .nav a > span:not(.avatar), .nav-collapsed .nav-button > span { opacity: 0; }
  /* Fixed, so the scrolling menu doesn't clip them; app.js sets --tip-y to the item's middle. */
  .nav-collapsed [data-tip]:hover::after, .nav-collapsed [data-tip]:focus-visible::after {
    content: attr(data-tip);
    position: fixed;
    left: calc(var(--sidebar-rail) + 12px);
    top: var(--tip-y, 50%);
    transform: translateY(-50%);
    padding: 5px 10px;
    border-radius: 6px;
    background: var(--side-bg);
    color: var(--side-fg);
    border: 1px solid var(--side-line);
    font: 600 0.82rem/1.2 var(--font);
    white-space: nowrap;
    pointer-events: none;
    z-index: 30;
  }
}

.main {
  margin-left: var(--sidebar);
  padding-block: 28px 64px;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
  max-width: calc(1240px + var(--sidebar));
  display: grid;
  gap: 20px;
  align-content: start;
}
.main > * { min-width: 0; }

@media (max-width: 860px) {
  .sidebar { position: sticky; top: 0; width: auto; inset: auto; border-right: 0; border-bottom: 2px solid var(--accent); padding: 10px 12px; }
  .sidebar-top { padding: 0 4px; margin-bottom: 0; border-bottom: 0; }
  .menu-open .nav { border-top: 2px solid var(--accent); margin-top: 10px; }
  .menu-toggle { display: inline-flex; }
  .nav { display: none; padding-top: 12px; }
  .menu-open .nav { display: flex; max-height: calc(100dvh - 70px); }
  .main { margin-left: 0; padding-top: 20px; }
}

/* ---------- page furniture ---------- */

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 20px; }
.page-head .actions { margin: 0; }
.crumbs { font-size: 0.85rem; color: var(--muted); margin-bottom: 4px; }
.crumbs a { color: var(--muted); }
.subtitle { color: var(--muted); margin-top: 4px; }

.demo-banner { padding: 8px 14px; border-radius: var(--radius-sm); background: var(--ink); color: var(--accent); font: 600 0.85rem/1.4 var(--font); }
.flash { padding: 10px 14px; border-radius: var(--radius-sm); font-weight: 500; background: var(--info-soft); }
.flash-success { background: var(--good-soft); color: #0f5a33; }
.flash-error { background: var(--bad-soft); color: #8a2018; }
.flash-info { background: var(--info-soft); }

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(16px, 2.4vw, 24px);
  background: var(--bg);
  display: grid;
  gap: 14px;
  align-content: start;
  min-width: 0;
}
.card.narrow { max-width: 620px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.cols-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 20px; align-items: start; }
.cols-main { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 20px; align-items: start; }
@media (max-width: 1000px) { .cols-main { grid-template-columns: 1fr; } }
.stack { display: grid; gap: 14px; }
.stack-lg { display: grid; gap: 20px; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.actions.split { justify-content: space-between; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--ink);
  white-space: nowrap;
  vertical-align: middle;
}
a.pill { text-decoration: none; }
a.pill:hover { background: var(--line); }
.pill-good { background: var(--good-soft); color: var(--good); }
.pill-mid { background: var(--mid-soft); color: var(--mid); }
.pill-bad { background: var(--bad-soft); color: var(--bad); }
.pill-lime { background: var(--accent); }
.pill-info { background: var(--info-soft); color: #1f4f8f; }

.empty { padding: 28px; text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted); display: grid; gap: 10px; justify-items: center; }
.empty p { max-width: 46ch; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 2px; }
.stat b { font: 600 1.35rem/1.2 var(--mono); font-variant-numeric: tabular-nums; }
.stat small { color: var(--muted); }
.stat.warn { border-color: var(--mid); background: var(--mid-soft); }
.stat.over { border-color: var(--bad); background: var(--bad-soft); }

.meter { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--ink); border-radius: inherit; }
.meter.warn > span { background: var(--mid); }
.meter.over > span { background: var(--bad); }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ---------- forms ---------- */

.grid-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.grid-form .span-2, .grid-form .actions { grid-column: 1 / -1; }
.grid-form .span-all { grid-column: 1 / -1; }
@media (max-width: 640px) { .grid-form { grid-template-columns: 1fr; } }

.field { display: grid; gap: 5px; align-content: start; min-width: 0; }
.field > label { font-weight: 600; font-size: 0.88rem; }
.field > label small { font-weight: 400; color: var(--muted); }
.field .req { color: var(--bad); }
.field .help { color: var(--muted); }
.field .error { color: var(--bad); font-weight: 500; }
.field .static { padding: 8px 0; }
.field.bare > label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.field.bare input { max-width: 120px; font-family: var(--mono); }
.field.check label { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; }
.field.check input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--ink); }

input:not([type]), input[type="text"], input[type="email"], input[type="password"], input[type="tel"], input[type="date"],
input[type="time"], input[type="number"], input[type="search"], input[type="url"], select, textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink);
  font: 400 0.95rem/1.4 var(--font);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--ink); outline-offset: -1px; border-color: var(--ink); }
.has-error input, .has-error select, .has-error textarea { border-color: var(--bad); }
select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%230c0c0e' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.affix { display: flex; align-items: stretch; }
.affix .prefix { display: grid; place-items: center; padding: 0 10px; border: 1px solid var(--line-strong); border-right: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); background: var(--surface); color: var(--muted); }
.affix input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-family: var(--mono); }
.code-input { font: 600 1.3rem/1 var(--mono) !important; letter-spacing: 0.2em; max-width: 220px; }

.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.inline-form .field { flex: 1 1 180px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: end; }
.filters .field { flex: 0 1 200px; min-width: 0; }
.filters .field:has(input[type="search"]) { flex: 1 1 280px; max-width: 420px; }
.filters .btn { min-height: 40px; }

.copy-row { display: flex; gap: 8px; }
.copy-row input { font-family: var(--mono); font-size: 0.85rem; }
.link-box { background: var(--accent-soft); border-color: var(--ink); }

fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.radio { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.radio input { width: 18px; height: 18px; accent-color: var(--ink); }
.indent { padding-left: 26px; }
details > summary { cursor: pointer; }
details:not(.contact) > summary { font-weight: 600; font-size: 0.9rem; padding: 4px 0; }

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th { text-align: left; font-weight: 600; font-size: 0.8rem; color: var(--muted); background: var(--surface); padding: 9px 12px; white-space: nowrap; border-bottom: 1px solid var(--line); }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fbfbf9; }
.table .num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tfoot td { font-weight: 700; background: var(--surface); border-top: 1px solid var(--line); border-bottom: 0; }
.table .is-off td { color: var(--muted); }
.table a { font-weight: 600; }
.table-compact td, .table-compact th { padding: 6px 10px; }

/* ---------- lists ---------- */

.history { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 0.9rem; }
.history li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.history li:last-child { border-bottom: 0; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.timeline li { display: grid; gap: 2px; padding-left: 16px; border-left: 2px solid var(--line); }
.timeline .note-body { white-space: pre-wrap; }

.steps { margin: 0; padding-left: 1.4em; display: grid; gap: 28px; }
.steps li { display: grid; gap: 10px; }
.qr svg { width: 200px; height: 200px; display: block; }
.qr .qr-data-dark, .qr path { fill: var(--ink); }
.secret { font-size: 1.05rem; letter-spacing: 0.05em; padding: 10px 12px; background: var(--surface); border-radius: var(--radius-sm); overflow-wrap: anywhere; }
.recovery-codes { list-style: none; padding: 16px; margin: 0; display: grid; grid-template-columns: repeat(2, max-content); gap: 8px 32px; background: var(--surface); border-radius: var(--radius-sm); font-size: 1.05rem; }
.logo-preview { max-height: 60px; width: auto; }

/* ---------- contacts ---------- */

details.contact { border: 1px solid var(--line); border-radius: var(--radius-sm); }
details.contact > summary { padding: 10px 12px; cursor: pointer; list-style: none; line-height: 1.5; }
details.contact > summary::-webkit-details-marker { display: none; }
details.contact[open] > summary { border-bottom: 1px solid var(--line); background: var(--surface); }
details.contact > form { padding: 12px; }
details.contact.add > summary { display: flex; align-items: center; gap: 6px; font-weight: 600; }
form.inline { display: inline; }

/* ---------- tasks ---------- */

.task-group { display: grid; gap: 6px; }
.task-group h3 { display: flex; gap: 8px; align-items: baseline; padding-top: 6px; }
.tasks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.task { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 10px; align-items: start; }
.task-status select { min-height: 32px; padding: 4px 28px 4px 10px; font-size: 0.82rem; font-weight: 600; border-radius: 999px; background-position: right 10px center; }
.task-status .status-in_progress { background-color: var(--accent-soft); border-color: var(--ink); }
.task-status .status-done { background-color: var(--good-soft); border-color: var(--good); color: var(--good); }
.task-body { border: 1px solid var(--line); border-radius: var(--radius-sm); min-width: 0; }
.task-body > summary { list-style: none; padding: 6px 10px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; cursor: pointer; }
.task-body > summary::-webkit-details-marker { display: none; }
.task-body[open] > summary { border-bottom: 1px solid var(--line); background: var(--surface); }
.task-body > form { padding: 12px; }
.task-name { font-weight: 500; overflow-wrap: anywhere; }
.task-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 0.82rem; color: var(--muted); }
.task.is-done .task-name { text-decoration: line-through; color: var(--muted); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px 16px; }
.checks .radio { font-weight: 500; }
.meter-cell { min-width: 110px; vertical-align: middle !important; }

/* ---------- quotes and invoices: the line editor ---------- */

.lines-table td { vertical-align: top; padding: 8px; }
.lines-table .line-desc { min-width: 240px; display: grid; gap: 6px; }
.lines-table .line-desc textarea { min-height: 36px; font-size: 0.88rem; }
.lines-table .line-qty { width: 110px; }
.lines-table .line-qty input { margin-bottom: 6px; }
.lines-table .line-price { width: 160px; }
.lines-table .line-price .check-inline { margin-top: 6px; font-size: 0.85rem; }
.lines-table .line-hours { width: 70px; }
.lines-table .line-amount { width: 110px; padding-top: 16px; }
.lines-table input, .lines-table textarea { min-height: 36px; padding: 6px 9px; }
.line-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.line-tools .field { flex: 1 1 260px; max-width: 420px; }
.totals-preview { margin-left: auto; width: min(100%, 380px); border-collapse: collapse; }
.totals-preview td { padding: 6px 4px; }
.totals-preview .num { font-family: var(--mono); text-align: right; white-space: nowrap; }
.totals-preview .grand td { border-top: 2px solid var(--ink); font-weight: 700; font-size: 1.05rem; }
.discount-row select { width: auto; min-height: 32px; padding: 4px 30px 4px 8px; margin-left: 6px; font-size: 0.85rem; }
.discount-row .discount-value { width: 80px; min-height: 32px; padding: 4px 8px; margin-left: 4px; font-family: var(--mono); }
.milestones-table input.pct { width: 80px; font-family: var(--mono); }
.milestones-table select { min-width: 190px; }
.mono-text { font-family: var(--mono); font-size: 0.85rem; line-height: 1.5; }
.small-facts { font-size: 0.82rem; gap: 4px 12px; }
a.stat { text-decoration: none; color: inherit; }
a.stat:hover { border-color: var(--ink); }

/* ---------- the client's pages (private links) ---------- */

.public { background: var(--surface); }
.public-bar { background: var(--side-bg); border-bottom: 2px solid var(--accent); padding: 14px max(var(--gutter), env(safe-area-inset-left, 0px)); }
.public-bar .logo { color: var(--side-fg); font-size: 24px; }
.public-main { max-width: 880px; margin: 0 auto; padding-block: 24px 48px; padding-left: max(var(--gutter), env(safe-area-inset-left, 0px)); padding-right: max(var(--gutter), env(safe-area-inset-right, 0px)); display: grid; gap: 16px; }
.public-actions { display: flex; justify-content: flex-end; gap: 10px; }
.accept-card { border-color: var(--ink); }
.public-foot { text-align: center; }

/* ---------- tabs ---------- */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs a { padding: 8px 14px; text-decoration: none; font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; color: var(--muted); }
.tabs a[aria-current="page"] { border-bottom-color: var(--ink); color: var(--ink); font-weight: 700; }
.tabs .count { font-family: var(--mono); font-size: 0.78rem; margin-left: 4px; }

/* ---------- prospects board ---------- */

.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.column { background: var(--surface); border-radius: var(--radius); padding: 10px; display: grid; gap: 8px; align-content: start; min-height: 120px; }
.column-head { display: flex; justify-content: space-between; align-items: center; padding: 2px 4px 6px; font-weight: 700; font-size: 0.88rem; }
.column-head .count { font-family: var(--mono); font-weight: 400; color: var(--muted); }
.prospect-card { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; display: grid; gap: 4px; text-decoration: none; }
.prospect-card:hover { border-color: var(--ink); }
.prospect-card b { font-weight: 600; }
.prospect-card .meta { display: flex; flex-wrap: wrap; gap: 4px 8px; font-size: 0.8rem; color: var(--muted); align-items: center; }
.prospect-card .estimate { font-family: var(--mono); font-size: 0.82rem; }
.due { color: var(--bad); font-weight: 600; }

.payload { display: grid; gap: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.payload div { display: grid; grid-template-columns: 140px 1fr; gap: 12px; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 0.9rem; }
.payload div:last-child { border-bottom: 0; }
.payload span { color: var(--muted); }
.payload b { font-weight: 500; white-space: pre-wrap; overflow-wrap: anywhere; }
.message { white-space: pre-wrap; background: var(--surface); padding: 14px; border-radius: var(--radius-sm); }

/* ---------- timer ---------- */

.timer-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--ink); background: var(--accent-soft); }
.timer-bar .clock { font: 700 1.5rem/1 var(--mono); font-variant-numeric: tabular-nums; }
.timer-bar .what { flex: 1 1 200px; min-width: 0; }
.timer-bar .what small { display: block; color: var(--muted); }
.timer-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; align-items: end; }
.running-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); flex: none; }
@media (prefers-reduced-motion: no-preference) { .running-dot { animation: pulse 1.6s ease-in-out infinite; } }
@keyframes pulse { 50% { opacity: 0.35; } }
@keyframes nav-fade { from { opacity: 0; } }

.timer-stop { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; flex: 1 1 360px; }
.timer-stop input[type="text"] { flex: 1 1 220px; min-width: 0; }
.timer-bar .flash { flex-basis: 100%; }
.check-inline { display: inline-flex; gap: 6px; align-items: center; font-weight: 500; white-space: nowrap; }
.check-inline input { width: 16px; height: 16px; accent-color: var(--ink); }
.time-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.time-row input[type="time"] { width: auto; flex: 1 1 110px; }
.time-row input.duration { width: 90px; flex: 0 0 90px; font-family: var(--mono); }
.time-row span { color: var(--muted); font-size: 0.85rem; }
details.card:not([open]) { padding-block: 14px; }
.nowrap { white-space: nowrap; }
details.add-entry > summary { display: flex; align-items: center; gap: 6px; font-weight: 600; list-style: none; }
details.add-entry > summary::-webkit-details-marker { display: none; }
details.add-entry[open] > summary { margin-bottom: 4px; }
.day { display: grid; gap: 8px; }
.entries .when { width: 104px; color: var(--muted); }
.week-foot h2 .mono { margin-left: 8px; }

/* ---------- weekly timesheet grid ---------- */

.week-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.week-grid th, .week-grid td { text-align: center; }
.week-grid th:first-child, .week-grid td:first-child { text-align: left; min-width: 200px; }
.week-grid input { width: 64px; min-height: 34px; padding: 4px 6px; text-align: center; font-family: var(--mono); }
.week-grid .today { background: var(--accent-soft); }
.week-grid td.total, .week-grid th.total { font-family: var(--mono); font-weight: 700; }
.locked-note { display: flex; gap: 8px; align-items: center; }

/* ---------- products ---------- */

.product-group { display: grid; gap: 10px; }
.estimate-box { display: grid; gap: 4px; padding: 16px; border-radius: var(--radius); background: var(--accent-soft); border: 1px solid var(--ink); }
.estimate-box b { font: 700 1.4rem/1.2 var(--mono); }

/* ---------- dashboard and reports ---------- */

.period-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; }
.period-bar .tabs { border-bottom: 0; }
.period-step { display: flex; align-items: center; gap: 8px; }
.period-step .btn { min-width: 32px; padding-inline: 8px; font-size: 1rem; }
.period-custom > summary { font-size: 0.85rem; color: var(--muted); }
.period-custom[open] > summary { margin-bottom: 6px; }
.period-custom .field { flex: 0 1 160px; }
.delta { color: var(--muted); }
.delta.good { color: var(--good); }
.delta.bad { color: var(--bad); }
.bar-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; font-size: 0.9rem; }
.bar-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 12px; }
.bar-list li > :first-child { min-width: 0; overflow-wrap: anywhere; }
.bar-list .meter { grid-column: 1 / -1; height: 6px; }
.bar-list .avatar { width: 24px; height: 24px; font-size: 0.62rem; }
.table tr.is-current td { background: var(--accent-soft); }
.table tbody + tbody tr:first-child td { border-top: 1px solid var(--line); }

/* Columns per month: this year in ink, last year in grey behind it. Heights come from data-h (app.js). */
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 0.85rem; color: var(--muted); }
.chart-legend .key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--ink); margin-right: 6px; vertical-align: -1px; }
.chart-legend .key.last, .col-chart .bar.last { background: var(--line-strong); }
.col-chart { margin: 0; display: grid; gap: 6px; }
.col-chart-plot { position: relative; height: 200px; margin-left: 52px; border-bottom: 1px solid var(--line-strong); }
.col-chart-grid { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.col-chart-grid span { position: relative; border-top: 1px solid var(--line); }
.col-chart-grid span:last-child { border-top-color: transparent; }
.col-chart-grid small { position: absolute; right: calc(100% + 8px); transform: translateY(-50%); font: 0.72rem/1 var(--mono); color: var(--muted); white-space: nowrap; }
.col-chart-cols { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); }
.col-chart-col { display: flex; align-items: flex-end; justify-content: center; gap: 2px; }
.col-chart .bar { display: block; width: min(14px, 40%); height: 0; background: var(--ink); border-radius: 4px 4px 0 0; }
.col-chart-x { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); margin-left: 52px; font-size: 0.75rem; color: var(--muted); text-align: center; }
@media (max-width: 520px) {
  .col-chart-x span:nth-child(even) { visibility: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

@media print {
  .sidebar, .page-head .actions, .btn { display: none !important; }
  .main { margin: 0; }
}

/* ---------- onboarding, the portal and care ---------- */

.lead { font-size: 1.05rem; max-width: 64ch; }
.field .label { font-weight: 600; font-size: 0.88rem; }
.public-main fieldset { margin: 0; min-width: 0; }
.public-main fieldset[disabled] { opacity: 0.85; }
.login-fields { padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.file-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 0.9rem; }
.file-list li { display: flex; align-items: center; gap: 6px; }
.builder-table td { vertical-align: top; }
.builder-table input, .builder-table select { width: 100%; }
.builder-table td:first-child { width: 22%; min-width: 140px; }
.builder-table td:nth-child(3) { width: 24%; min-width: 170px; }
.builder-table .help-input { margin-top: 6px; font-size: 0.85rem; }
.builder-table select + select { margin-top: 6px; }
.row-tools { white-space: nowrap; }
.row-tools .btn-link { text-decoration: none; padding: 2px 4px; }
.public-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.public-nav { display: flex; align-items: center; gap: 16px; font-size: 0.9rem; }
.public-nav a, .public-nav .btn-link { color: var(--side-fg); }
.public-nav form { margin: 0; }
.narrow-panel { max-width: 520px; width: 100%; margin: 24px auto 0; }
.public-main > header h1 { margin-top: 2px; }

/* ---------- expenses: the parts of the form that apply ---------- */

.is-aud .is-foreign, .no-person .is-personal, .no-repeat .is-repeating { display: none; }
.rate-note { margin: -6px 0 0; }
.repeating summary { cursor: pointer; }
.repeating .table-wrap { margin-top: 12px; }
.avatar-form .error { color: var(--bad); font-weight: 500; margin: 0; }
.good { color: var(--good); }
