/* Kalel panel. The drafting world of the public site, at a fixed product scale. */

@font-face {
  font-family: "Archivo";
  src: url("../fonts/archivo-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --ground: #1a1e21;
  --ground-deep: #15181b;
  --panel: #22272b;
  --panel-2: #2a3034;
  --ink: #e3e0d8;
  --ink-2: #b4b8b5;
  --muted: #9aa3a8;
  --line: rgba(227, 224, 216, 0.12);
  --line-strong: rgba(227, 224, 216, 0.28);
  --accent: #4fa3ff;
  --accent-hover: #6db4ff;
  --accent-ink: #0b1622;
  --bar: #7d868c;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --danger-text: #ff8a7a;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --top-h: 56px;
  --pad: 28px;

  --fs-xs: 0.75rem;
  --fs-sm: 0.8438rem;
  --fs-md: 0.9375rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.375rem;
  --fs-2xl: 1.75rem;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  background: var(--ground);
  scrollbar-color: #3b4247 var(--ground);
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--ground);
  color: var(--ink);
  font: 400 var(--fs-md)/1.5 "Archivo", "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}

::selection { background: var(--accent); color: var(--accent-ink); }
input, textarea, select { caret-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
a { color: inherit; text-underline-offset: 0.2em; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-weight: 560; text-wrap: balance; }
button { font: inherit; color: inherit; }
img, svg { display: block; }

.label {
  font-size: var(--fs-xs);
  font-stretch: 125%;
  font-weight: 560;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.ink2 { color: var(--ink-2); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ------------------------------------------------------------ Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-size: var(--fs-md);
  font-weight: 540;
  font-stretch: 104%;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 120ms var(--ease-out), background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}
.btn:active:not([disabled]) { transform: scale(0.97); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--quiet { border-color: transparent; color: var(--ink-2); }
.btn--danger { color: var(--danger-text); border-color: rgba(255, 138, 122, 0.4); }
.btn--sm { min-height: 32px; padding: 0 12px; font-size: var(--fs-sm); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; fill: currentColor; flex: none; }
@media (hover: hover) and (pointer: fine) {
  .btn:hover:not([disabled]) { border-color: var(--ink); }
  .btn--primary:hover:not([disabled]) { background: var(--accent-hover); border-color: var(--accent-hover); }
  .btn--quiet:hover:not([disabled]) { color: var(--ink); border-color: transparent; background: var(--panel); }
}

/* ------------------------------------------------------------ Top bar: the sheet index */

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: stretch;
  gap: 20px;
  height: calc(var(--top-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) var(--pad) 0;
  background: var(--ground);
  border-bottom: 1px solid var(--line-strong);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  text-decoration: none;
  font-stretch: 125%;
  font-weight: 600;
  letter-spacing: 0.18em;
  font-size: var(--fs-sm);
}
.brand svg { width: 24px; height: 24px; }
.brand small { color: var(--muted); letter-spacing: 0.12em; font-weight: 500; }

.tabs {
  display: flex;
  align-items: stretch;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-x: auto;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  flex: 1 1 auto;
  min-width: 0;
}
.tabs::-webkit-scrollbar { display: none; }
/* The strip fades only on a side that still hides tabs (data-less / data-more are set from scroll position). */
.tabs {
  --fade-l: 0px;
  --fade-r: 0px;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent);
  mask-image: linear-gradient(to right, transparent, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent);
}
.tabs[data-less] { --fade-l: 28px; }
.tabs[data-more] { --fade-r: 44px; }
.tab {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 var(--tab-pad, 14px);
  color: var(--ink-2);
  text-decoration: none;
  white-space: nowrap;
  font-size: var(--fs-md);
  touch-action: manipulation;
  transition: color 160ms ease;
}
.tab[aria-current="page"] { color: var(--ink); font-weight: 560; }
.tab[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
}
.tab .count {
  min-width: 20px;
  padding: 1px 6px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: var(--fs-xs);
  font-weight: 650;
  text-align: center;
}
@media (hover: hover) and (pointer: fine) { .tab:hover { color: var(--ink); } }

.who {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}
.who button { background: none; border: 0; padding: 0; cursor: pointer; display: flex; align-items: center; gap: 10px; }
.who .name { font-size: var(--fs-sm); color: var(--ink-2); }

.avatar {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  font-size: var(--fs-xs);
  font-weight: 650;
  font-stretch: 112%;
  letter-spacing: 0.04em;
}
.avatar--lg { width: 56px; height: 56px; font-size: var(--fs-md); }

.menu {
  position: fixed;
  top: calc(var(--top-h) + env(safe-area-inset-top, 0px) + 6px);
  right: var(--pad);
  z-index: 30;
  min-width: 220px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  box-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.6);
  padding: 6px;
}
.menu p { padding: 8px 10px; font-size: var(--fs-sm); color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 4px; overflow-wrap: anywhere; }
.menu button { display: block; width: 100%; text-align: left; padding: 10px; background: none; border: 0; cursor: pointer; }
@media (hover: hover) and (pointer: fine) { .menu button:hover { background: var(--panel-2); } }

/* ------------------------------------------------------------ Sheet */

.sheet {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px var(--pad) calc(32px + env(safe-area-inset-bottom, 0px));
}
.sheet-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 20px;
  padding-bottom: 18px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line-strong);
}
.sheet-head h1 { font-size: var(--fs-2xl); letter-spacing: -0.015em; line-height: 1.1; font-stretch: 100%; }
.sheet-head .sub { margin-top: 6px; color: var(--ink-2); font-size: var(--fs-md); }
.sheet-head .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.back { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 10px; color: var(--muted); text-decoration: none; font-size: var(--fs-sm); }
.back svg { width: 14px; height: 14px; fill: currentColor; }
@media (hover: hover) and (pointer: fine) { .back:hover { color: var(--ink); } }

.cols { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 28px; align-items: start; }
.cols--even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.block + .block { margin-top: 28px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.block-head h2 { font-size: var(--fs-lg); font-stretch: 104%; }

/* Title block: closes every sheet */
.titleblock {
  margin-top: 36px;
  display: grid;
  grid-template-columns: repeat(var(--tb, 4), minmax(0, 1fr));
  border: 1px solid var(--line-strong);
}
.titleblock > div { padding: 10px 14px; border-right: 1px solid var(--line-strong); min-width: 0; }
.titleblock > div:last-child { border-right: 0; }
.titleblock dt { margin: 0 0 2px; }
.titleblock dd { margin: 0; font-size: var(--fs-sm); overflow-wrap: anywhere; }

/* ------------------------------------------------------------ Hoy: action list */

.todo { margin: 0; padding: 0; list-style: none; }
.todo li {
  display: grid;
  grid-template-columns: 176px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.todo .what { min-width: 0; }
.todo .what strong { display: block; font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.todo .what span { display: block; color: var(--ink-2); font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.todo .kind { display: flex; align-items: center; gap: 8px; }

.figures { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.figures > div { padding: 14px 0 14px; border-bottom: 1px solid var(--line); }
.figures > div:nth-child(odd) { padding-right: 14px; border-right: 1px solid var(--line); }
.figures > div:nth-child(even) { padding-left: 14px; }
.figures b { display: block; margin-top: 4px; font-size: var(--fs-xl); font-weight: 560; font-stretch: 100%; letter-spacing: -0.01em; }
.figures small { display: block; margin-top: 2px; color: var(--muted); font-size: var(--fs-xs); }
.figures .warn b { color: var(--danger-text); }

.agenda { margin: 0; padding: 0; list-style: none; }
.agenda li { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.agenda time { font-weight: 560; }
.agenda .t { min-width: 0; }
.agenda .t strong { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agenda .t span { color: var(--muted); font-size: var(--fs-sm); }
.agenda .day { grid-column: 1 / -1; padding: 14px 0 4px; border-bottom: 0; }

/* ------------------------------------------------------------ Status vocabulary: shape + word */

.st { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-sm); white-space: nowrap; }
.st::before { content: ""; width: 10px; height: 10px; flex: none; border: 1.5px solid var(--ink-2); }
.st--nueva::before { background: var(--ink); border-color: var(--ink); }
.st--contactada::before { border-color: var(--ink); }
.st--propuesta::before { border-color: var(--ink); background: linear-gradient(135deg, var(--ink) 50%, transparent 50%); }
.st--ganada::before { background: var(--good); border-color: var(--good); border-radius: 50%; }
.st--perdida { color: var(--muted); }
.st--perdida::before { border-color: var(--muted); background: linear-gradient(45deg, transparent 45%, var(--muted) 45% 55%, transparent 55%); }
.st--borrador::before { border-style: dashed; border-color: var(--muted); }
.st--emitida::before { border-color: var(--ink); }
.st--cobrada::before { background: var(--good); border-color: var(--good); border-radius: 50%; }
.st--vencida { color: var(--danger-text); }
.st--vencida::before { border: 0; width: 11px; height: 10px; background: var(--critical); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.st--activo::before { background: var(--good); border-color: var(--good); border-radius: 50%; }
.st--baja { color: var(--muted); }
.st--gcal::before { border-style: dashed; border-color: var(--ink-2); }
.st--panel::before { background: var(--ink); border-color: var(--ink); }

.tag { font-size: var(--fs-xs); font-stretch: 118%; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); white-space: nowrap; }

/* ------------------------------------------------------------ Filters, search */

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink-2);
  font-size: var(--fs-sm);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease;
}
.chip b { font-weight: 600; color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--ground); font-weight: 560; }
.chip[aria-pressed="true"] b { color: var(--ground); }
@media (hover: hover) and (pointer: fine) { .chip[aria-pressed="false"]:hover { border-color: var(--ink); color: var(--ink); } }

.search { position: relative; flex: 1 1 220px; max-width: 340px; }
.search input { padding-left: 36px; }
.search svg { position: absolute; left: 11px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); fill: var(--muted); pointer-events: none; }

/* ------------------------------------------------------------ Tables */

.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
.list th {
  text-align: left;
  padding: 8px 12px 8px 0;
  border-bottom: 1px solid var(--line-strong);
  font-size: var(--fs-xs);
  font-stretch: 125%;
  font-weight: 560;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.list td { padding: 12px 12px 12px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
.list td.r, .list th.r { text-align: right; padding-right: 24px; }
.list td.r:last-child, .list th.r:last-child { padding-right: 0; }
.list tbody tr { cursor: pointer; transition: background-color 120ms ease; }
.list tbody tr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.list .main { font-weight: 560; }
.list .sub { color: var(--muted); font-size: var(--fs-sm); }
@media (hover: hover) and (pointer: fine) { .list tbody tr:hover { background: var(--panel); } }

/* ------------------------------------------------------------ Empty and loading */

.empty {
  border: 1px dashed var(--line-strong);
  padding: 28px;
  text-align: left;
  max-width: 640px;
}
.empty h3 { font-size: var(--fs-lg); font-stretch: 104%; }
.empty p { margin-top: 6px; color: var(--ink-2); }
.empty .btn { margin-top: 16px; }

.skeleton { display: grid; gap: 10px; }
.skeleton i { display: block; height: 44px; background: linear-gradient(90deg, var(--panel) 0%, var(--panel-2) 50%, var(--panel) 100%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ------------------------------------------------------------ Record sheet (cajetín) */

.kv { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line-strong); border-left: 1px solid var(--line-strong); }
.kv > div { padding: 10px 14px; border-right: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong); min-width: 0; }
.kv dt { margin-bottom: 3px; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.kv dd a { text-decoration: none; border-bottom: 1px solid var(--line-strong); }
.kv .wide { grid-column: 1 / -1; }

.quote { margin: 0; padding: 14px 18px; border: 1px solid var(--line-strong); background: var(--panel); color: var(--ink); white-space: pre-wrap; }

.needs { display: flex; flex-wrap: wrap; gap: 6px; }
.needs span { padding: 4px 10px; border: 1px solid var(--line-strong); font-size: var(--fs-sm); }

.contact-bar { display: flex; flex-wrap: wrap; gap: 8px; }

.notes { margin: 0; padding: 0; list-style: none; }
.notes li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.notes li p { white-space: pre-wrap; }
.notes li small { display: block; margin-top: 4px; color: var(--muted); font-size: var(--fs-xs); }
.note-form { display: grid; gap: 8px; margin-top: 12px; }

/* Mail: conversations mirrored from Gmail, on the Correo sheet and inside lead and client pages */
.mail-list { margin: 0; padding: 0; list-style: none; }
.mail-list > li { display: grid; gap: 8px; justify-items: start; padding: 14px 0; border-bottom: 1px solid var(--line); }
.mail-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; width: 100%; }
.mail-top strong { min-width: 0; font-weight: 560; overflow-wrap: anywhere; }
.mail-msg { display: grid; gap: 2px; margin: 0; color: var(--ink); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.mail-msg.out { color: var(--ink-2); }
.mail-msg .label { font-size: var(--fs-xs); }
.list--mail .mail-cell { width: 46%; max-width: 0; }
.list--mail .mail-cell strong,
.list--mail .mail-cell span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list--mail .mail-cell strong { font-weight: 560; }
.list--mail .mail-cell span { color: var(--ink-2); font-size: var(--fs-sm); }
.row-actions { display: inline-flex; gap: 6px; }

.segmented { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line-strong); }
.segmented button { min-height: 36px; padding: 0 12px; border: 0; border-right: 1px solid var(--line); background: transparent; color: var(--ink-2); cursor: pointer; font-size: var(--fs-sm); touch-action: manipulation; }
.segmented button:last-child { border-right: 0; }
.segmented button[aria-pressed="true"] { background: var(--ink); color: var(--ground); font-weight: 560; }
@media (hover: hover) and (pointer: fine) { .segmented button[aria-pressed="false"]:hover { color: var(--ink); background: var(--panel); } }

/* ------------------------------------------------------------ Forms */

.field { display: grid; gap: 6px; min-width: 0; }
.field > span:first-child { font-size: var(--fs-sm); font-weight: 560; color: var(--ink); }
.field .hint { font-size: var(--fs-xs); color: var(--muted); }
.input, .select, .textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--ground-deep);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  transition: border-color 140ms ease;
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8'><path d='M1 1.5l5 5 5-5' fill='none' stroke='%23e3e0d8' stroke-width='1.5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}
.select option { background: var(--panel); }
.input::placeholder, .textarea::placeholder { color: #848d92; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); }
@media (pointer: fine) { .input, .select, .textarea { font-size: var(--fs-md); } }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .span2 { grid-column: 1 / -1; }
.form-error { color: var(--danger-text); font-size: var(--fs-sm); }
.check { display: flex; flex-wrap: wrap; gap: 6px; }

/* Lines editor (invoices) */
.lines { width: 100%; border-collapse: collapse; }
.lines th { text-align: left; padding: 6px 8px 6px 0; }
.lines td { padding: 4px 8px 4px 0; vertical-align: top; }
.lines td:last-child { padding-right: 0; width: 36px; }
.lines .input { min-height: 38px; }
.totals { margin-left: auto; width: min(340px, 100%); display: grid; grid-template-columns: 1fr auto; row-gap: 4px; column-gap: 0; padding-top: 10px; }
.totals > span:nth-child(odd) { padding-right: 16px; }
.totals > span:nth-child(even) { text-align: right; }
.totals .grand { font-size: var(--fs-lg); font-weight: 600; border-top: 1px solid var(--line-strong); padding-top: 6px; }

/* ------------------------------------------------------------ Side sheet (dialog) */

dialog.side {
  position: fixed;
  inset: 0 0 0 auto;
  margin: 0;
  width: min(560px, 100vw);
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--line-strong);
  background: var(--ground);
  color: var(--ink);
  overscroll-behavior: contain;
}
dialog.side[open] { display: flex; flex-direction: column; animation: slide-in 220ms var(--ease-out); }
dialog.side::backdrop { background: rgba(10, 12, 14, 0.62); }
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: calc(16px + env(safe-area-inset-top, 0px)) 22px 14px; border-bottom: 1px solid var(--line-strong); }
.side-head h2 { font-size: var(--fs-xl); font-stretch: 102%; }
.side-body { flex: 1 1 auto; overflow-y: auto; padding: 20px 22px; overscroll-behavior: contain; }
.side-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 14px 22px calc(14px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line-strong); }
.side-foot .form-error { margin-right: auto; align-self: center; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--line-strong); background: transparent; cursor: pointer; }
.icon-btn svg { width: 18px; height: 18px; fill: currentColor; }

/* ------------------------------------------------------------ Toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  z-index: 60;
  transform: translateX(-50%);
  padding: 12px 16px;
  background: var(--ink);
  color: var(--ground);
  font-weight: 540;
  box-shadow: 0 16px 40px -18px rgba(0, 0, 0, 0.7);
  animation: toast-in 200ms var(--ease-out);
}
.toast[popover] { inset: auto; margin: 0; border: 0; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
.load-error { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; padding: 14px 16px; border: 1px solid rgba(255, 138, 122, 0.5); color: var(--danger-text); }
.load-error p { color: var(--ink); }
.toast--error { background: var(--danger-text); color: #1a0d0b; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ------------------------------------------------------------ Sign-in sheet */

.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.gate-card { width: min(460px, 100%); border: 1px solid var(--line-strong); }
.gate-card .in { padding: 32px 28px; }
.gate-card h1 { font-size: var(--fs-2xl); margin-top: 18px; letter-spacing: -0.015em; }
.gate-card p { margin-top: 10px; color: var(--ink-2); }
.gate-card .btn { margin-top: 24px; width: 100%; min-height: 48px; }
.gate-card .form-error { margin-top: 14px; }
.gate-card .titleblock { margin-top: 0; border-width: 1px 0 0; --tb: 2; }

/* ------------------------------------------------------------ Calendar */

.cal-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.cal-head h2 { font-size: var(--fs-xl); min-width: 180px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-left: auto; }
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line-strong); border-left: 1px solid var(--line-strong); }
.month .dow { padding: 8px 10px; border-right: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong); }
.month .cell { min-height: 112px; padding: 6px 6px 8px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); min-width: 0; }
.month .cell.out { background: var(--ground-deep); }
.month .cell.out .d { color: #6c757b; }
.month .cell.today .d { background: var(--accent); color: var(--accent-ink); }
.month .d { display: inline-block; min-width: 24px; padding: 1px 5px; font-size: var(--fs-sm); font-weight: 560; }
.ev {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 3px 6px;
  border: 1px solid var(--ink-2);
  background: transparent;
  color: var(--ink);
  font-size: var(--fs-xs);
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.ev--panel { background: var(--ink); border-color: var(--ink); color: var(--ground); font-weight: 560; }
.ev--gcal { border-style: dashed; color: var(--ink-2); }
.more { margin-top: 4px; font-size: var(--fs-xs); color: var(--muted); }
.cal-list { display: none; }
.gcal-note { margin-bottom: 14px; padding: 12px 14px; border: 1px dashed var(--line-strong); color: var(--ink-2); font-size: var(--fs-sm); display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }

/* ------------------------------------------------------------ Money chart */

.chart { position: relative; }
.chart svg { width: 100%; height: 220px; overflow: visible; }
.chart .tick { fill: var(--muted); font-size: 11px; }
.chart .val { fill: var(--ink); font-size: 11px; font-weight: 600; }
.chart .barpath { fill: var(--bar); transition: fill 120ms ease; }
.chart g.hit { outline: none; }
.chart g.hit:hover .barpath, .chart g.hit:focus .barpath { fill: var(--ink); }
.chart .band { fill: transparent; }
.ctip { position: absolute; pointer-events: none; padding: 7px 10px; background: var(--panel-2); border: 1px solid var(--line-strong); font-size: var(--fs-sm); white-space: nowrap; transform: translate(-50%, -100%) translateY(-6px); opacity: 0; transition: opacity 120ms ease; }
.ctip.show { opacity: 1; }

/* ------------------------------------------------------------ Team */

.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0; border-top: 1px solid var(--line-strong); border-left: 1px solid var(--line-strong); }
.person { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 14px; padding: 16px; border-right: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong); text-decoration: none; transition: background-color 120ms ease; }
.person strong { display: block; font-weight: 560; }
.person span { display: block; color: var(--ink-2); font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person .avatar { display: grid; place-items: center; color: var(--ink); }
.person .st { display: inline-flex; overflow: visible; }
@media (hover: hover) and (pointer: fine) { .person:hover { background: var(--panel); } }

/* ------------------------------------------------------------ Printable invoice */

.invoice-paper { max-width: 820px; border: 1px solid var(--line-strong); padding: 40px; background: var(--ground-deep); }
.invoice-paper header { display: flex; justify-content: space-between; gap: 24px; padding-bottom: 20px; border-bottom: 1px solid var(--line-strong); }
.invoice-paper h2 { font-size: var(--fs-2xl); }
.invoice-paper .parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; padding: 20px 0; border-bottom: 1px solid var(--line); }
.invoice-paper .parties p { color: var(--ink-2); white-space: pre-line; }
.invoice-paper table { width: 100%; border-collapse: collapse; margin-top: 16px; }
.invoice-paper th { text-align: left; padding: 8px 0; border-bottom: 1px solid var(--line-strong); }
.invoice-paper td { padding: 10px 0; border-bottom: 1px solid var(--line); }
.invoice-paper .r { text-align: right; }
.invoice-paper footer { margin-top: 24px; color: var(--muted); font-size: var(--fs-sm); white-space: pre-line; }

@media print {
  @page { margin: 16mm; }
  html, body { background: #fff !important; color: #111 !important; }
  .top, .sheet-head, .no-print, .titleblock, .toast { display: none !important; }
  .sheet { padding: 0; max-width: none; }
  .invoice-paper { border: 0; padding: 0; background: #fff; color: #111; max-width: none; }
  .invoice-paper p, .invoice-paper footer, .invoice-paper .label { color: #333 !important; }
  .invoice-paper th, .invoice-paper td, .invoice-paper header, .invoice-paper .parties { border-color: #bbb !important; }
}

/* ------------------------------------------------------------ Narrow screens */

@media (max-width: 900px) {
  :root { --pad: 16px; }
  .top { flex-wrap: wrap; height: auto; padding-top: env(safe-area-inset-top, 0px); gap: 0; }
  .brand { height: 52px; }
  .who { margin-left: auto; height: 52px; }
  .who .name { display: none; }
  .tabs { order: 3; flex-basis: 100%; height: 46px; margin: 0 calc(var(--pad) * -1); padding: 0 calc(var(--pad) - 10px); border-top: 1px solid var(--line); }
  .kv .wide-sm { grid-column: 1 / -1; }
  .tab { scroll-snap-align: start; }
  .cols, .cols--even { grid-template-columns: minmax(0, 1fr); }
  .kv { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .titleblock { --tb: 2 !important; }
  .titleblock > div:nth-child(2n) { border-right: 0; }
  .titleblock > div { border-bottom: 1px solid var(--line-strong); }
  .todo li { grid-template-columns: minmax(0, 1fr) auto; }
  .todo .kind { grid-column: 1 / -1; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .month { display: none; }
  .cal-list { display: block; }
  .legend { margin-left: 0; }
  .list thead { display: none; }
  .list, .list tbody, .list tr, .list td { display: block; width: 100%; }
  .list tr { padding: 12px 0; border-bottom: 1px solid var(--line); }
  .list td { padding: 2px 0; border: 0; }
  .list--mail .mail-cell { width: auto; max-width: none; }
  .list--mail .mail-cell span { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .list--mail td.r { padding-top: 8px; text-align: left; }
  .list td.r { text-align: left; }
  .list td.hide-sm { display: none; }
  .invoice-paper { padding: 20px; }
  .invoice-paper .parties { grid-template-columns: 1fr; }
  .contact-bar .btn { flex: 1 1 0; }
}

@media (max-width: 520px) {
  .segmented { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); width: 100%; }
  .segmented button { grid-column: span 2; border-bottom: 1px solid var(--line); min-height: 42px; }
  .segmented button:nth-child(n+4) { grid-column: span 3; border-bottom: 0; }
  .segmented button:nth-child(3) { border-right: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}
