/* Ledger - a receipt book and time card.
   Tokens: copy-paper blue, ballpoint ink, highlighter, rubber stamp. */

:root {
  --paper: #EEF0F5;
  --sheet: #FFFFFF;
  --sheet-2: #F7F8FB;
  --ink: #151A33;
  --ink-2: #4A5070;
  --ink-3: #8389A6;
  --rule: #DCE0EA;
  --ink-blue: #2B3FD6;
  --ink-blue-soft: #E4E7FC;
  --hi: #FFE45C;            /* highlighter: unbilled, projected */
  --hi-soft: #FFF6C2;
  --stamp: #D2373C;         /* overdue, destructive */
  --ok: #1F8A5B;            /* received */
  --ok-soft: #DDF3E8;

  --f-display: "Bricolage Grotesque", "IBM Plex Sans", system-ui, sans-serif;
  --f-body: "IBM Plex Sans", "IBM Plex Sans Hebrew", system-ui, -apple-system, sans-serif;

  --r-lg: 18px;
  --r-md: 12px;
  --r-sm: 8px;
  --shadow: 0 1px 0 rgba(21, 26, 51, .04), 0 8px 24px -12px rgba(21, 26, 51, .18);
  --rail: 208px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

:root[data-theme="dark"] {
    --paper: #12152A;
    --sheet: #1A1E38;
    --sheet-2: #20254A;
    --ink: #EEF0FA;
    --ink-2: #B4B9D6;
    --ink-3: #7D83A8;
    --rule: #2C3260;
    --ink-blue: #7D8CFF;
    --ink-blue-soft: #262C5E;
    --hi: #F2D545;
    --hi-soft: #3A3720;
    --stamp: #FF6B6F;
    --ok: #4CD49A;
    --ok-soft: #173A33;
    --shadow: 0 1px 0 rgba(0, 0, 0, .2), 0 10px 30px -14px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.5 var(--f-body);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--ink-blue); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2.5px solid var(--ink-blue); outline-offset: 2px; border-radius: 6px; }
[dir=auto] { unicode-bidi: plaintext; }

h1, h2, h3 { font-family: var(--f-display); font-weight: 700; letter-spacing: -0.02em; margin: 0; line-height: 1.1; }
h1 { font-size: clamp(28px, 4vw, 40px); font-weight: 800; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
.muted { color: var(--ink-3); }
.orig { font: 500 12px var(--f-body); color: var(--ink-3); margin-left: 4px; white-space: nowrap; }
.small { font-size: 13px; }
.num { font-family: var(--f-display); font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- layout ------------------------------------------------------------- */
.page {
  margin-left: var(--rail);
  padding: 28px clamp(16px, 3.5vw, 44px) 80px;
  max-width: calc(1320px + var(--rail));
}
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { margin: 6px 0 0; color: var(--ink-2); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grid { display: grid; gap: 18px; }
/* minmax(0, …): a long unbreakable line can't force its column wider than its share */
.cols-2 { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
.cols-even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 1080px) { .cols-2, .cols-even { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 520px) { .hide-sm { display: none; } }

/* ---------- rail (desktop nav) -------------------------------------------------- */
.rail {
  position: fixed; inset: 0 auto 0 0; width: var(--rail);
  display: flex; flex-direction: column; gap: 2px;
  padding: 20px 14px; border-right: 1px solid var(--rule); background: var(--paper);
  z-index: 20;
}
.rail a, .rail .linkish {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: var(--r-sm);
  color: var(--ink-2); font-weight: 500; text-decoration: none; width: 100%;
  font: 500 15px/1.2 var(--f-body); background: none; border: 0; cursor: pointer; text-align: left;
}
.rail a:hover, .rail .linkish:hover { background: var(--sheet); color: var(--ink); }
.rail a.on { background: var(--sheet); color: var(--ink); box-shadow: var(--shadow); }
.rail a.on svg { color: var(--ink-blue); }
.rail .brand { font: 800 20px/1 var(--f-display); color: var(--ink); margin-bottom: 18px; padding-left: 8px; letter-spacing: -0.02em; }
.rail .brand svg { width: 30px; height: 30px; stroke: none; }
.rail .brand:hover { background: none; }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.cur-switch { display: flex; background: var(--sheet-2); border: 1px solid var(--rule); border-radius: 999px; padding: 3px; margin: 0 6px 10px; }
.cur-switch button { flex: 1; border: 0; background: none; border-radius: 999px; padding: 5px 0; font: 600 14px var(--f-display); color: var(--ink-3); cursor: pointer; }
.cur-switch button.on { background: var(--sheet); color: var(--ink); box-shadow: var(--shadow); }

/* ---------- tab bar (mobile nav) -------------------------------------------------- */
.tabbar { display: none; }
@media (max-width: 760px) {
  .rail { display: none; }
  .page { margin-left: 0; padding: 18px 16px calc(110px + var(--safe-b)); }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    padding: 6px 8px calc(8px + var(--safe-b));
    background: color-mix(in srgb, var(--sheet) 88%, transparent);
    backdrop-filter: blur(16px) saturate(1.4); -webkit-backdrop-filter: blur(16px) saturate(1.4);
    border-top: 1px solid var(--rule);
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 500; color: var(--ink-3); padding: 4px 0; text-decoration: none; }
  .tabbar a.on { color: var(--ink); }
  .tabbar a.on svg { color: var(--ink-blue); }
  .tabbar .punch-btn {
    width: 60px; height: 60px; margin: -24px auto 0; border-radius: 50%;
    background: var(--ink-blue); color: #fff; justify-content: center;
    box-shadow: 0 10px 24px -8px var(--ink-blue), 0 0 0 5px var(--paper);
  }
  .tabbar .punch-btn svg { width: 28px; height: 28px; }
}

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--ink-3)); flex: none; }

/* ---------- panels ----------------------------------------------------------------- */
.panel { background: var(--sheet); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 20px 22px; min-width: 0; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-head a { font-size: 14px; font-weight: 500; }
.panel.flat { box-shadow: none; border: 1px solid var(--rule); background: transparent; }

/* ---------- quick log (the dashboard hero) ---------------------------------------- */
.punch {
  position: relative; overflow: hidden;
  background: var(--ink); color: var(--paper);
  border-radius: 24px; padding: 22px 26px 24px; margin-bottom: 18px;
  display: grid; grid-template-columns: 1fr minmax(0, 1.25fr); gap: 18px 36px; align-items: center;
}
.punch::before { /* time-card perforation along the top edge */
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 6px;
  background: radial-gradient(circle at 6px -1px, var(--paper) 3.5px, transparent 4px) 0 0 / 14px 6px repeat-x;
  opacity: .55;
}
:root[data-theme="dark"] .punch { background: #0A0C1C; color: var(--ink); }
.punch .greet { font: 600 15px var(--f-body); color: color-mix(in srgb, currentColor 65%, transparent); margin-bottom: 6px; }
.punch-clock {
  font: 800 clamp(54px, 8vw, 96px)/0.95 var(--f-display); letter-spacing: -0.04em;
  display: flex; align-items: baseline; gap: .12em;
}
.punch-clock .sec { font-size: .3em; font-weight: 600; letter-spacing: 0; color: color-mix(in srgb, currentColor 55%, transparent); }
.punch-form { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.punch-form input[type=text], .punch-form input[type=number] {
  background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .16); color: inherit;
}
.punch-form input::placeholder { color: rgba(255, 255, 255, .45); }
.punch .chips .chip > span { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .14); color: var(--paper); }
:root[data-theme="dark"] .punch .chips .chip > span { color: var(--ink); }
/* selected client: white chip with the client's color as ring + dot, so text is readable for any color */
:root .punch .chips .chip input:checked + span { background: #fff; color: #151A33; border-color: var(--c); box-shadow: 0 0 0 2px var(--c); }
.punch .chips .chip input:checked + span .dot { box-shadow: none; }
.punch-stats { display: flex; gap: 26px; margin-top: 18px; font-size: 13px; color: color-mix(in srgb, currentColor 60%, transparent); flex-wrap: wrap; }
.punch-stats b { display: block; font: 700 22px var(--f-display); color: var(--paper); }
:root[data-theme="dark"] .punch-stats b { color: var(--ink); }

/* the hour picker: big targets, pick one (or type), then Save */
.hour-btns { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.hour-btn, .hour-custom { position: relative; margin: 0; display: block; }
.hour-btn input { position: absolute; opacity: 0; inset: 0; cursor: pointer; margin: 0; }
.hour-btn > span, .hour-custom input {
  display: flex; align-items: baseline; justify-content: center; gap: 3px;
  height: clamp(84px, 11vw, 104px); width: 100%; border-radius: 18px;
  background: rgba(255, 255, 255, .07); border: 2px solid rgba(255, 255, 255, .16);
  color: var(--paper); font: 800 clamp(38px, 4.6vw, 50px)/clamp(80px, 10.6vw, 100px) var(--f-display);
  letter-spacing: -0.03em; cursor: pointer;
  transition: background .12s ease, border-color .12s ease, transform .1s ease;
}
.hour-btn small { font-size: .42em; font-weight: 600; letter-spacing: 0; opacity: .65; }
.hour-btn:hover > span { background: rgba(255, 255, 255, .12); }
.hour-btn:active > span { transform: scale(.96); }
.hour-btn input:checked + span { background: var(--hi); border-color: var(--hi); color: #151A33; }
.hour-btn input:focus-visible + span { outline: 2.5px solid var(--hi); outline-offset: 3px; }
.punch-form .hour-custom input {
  display: block; padding: 0 8px; text-align: center; cursor: text;
  font-size: clamp(26px, 3.4vw, 36px); line-height: normal;
  background: rgba(255, 255, 255, .07); border: 2px dashed rgba(255, 255, 255, .3);
}
.punch-form .hour-custom input::placeholder { font: 600 17px var(--f-body); letter-spacing: 0; color: rgba(255, 255, 255, .55); }
@media (max-width: 520px) {
  .punch-form .hour-custom input { padding: 0 2px; }
  .punch-form .hour-custom input::placeholder { font-size: 14px; }
}
.punch-form .hour-custom input:focus { border-style: solid; border-color: var(--hi); box-shadow: none; }
.punch-form .hour-custom input:not(:placeholder-shown) { background: var(--hi); border: 2px solid var(--hi); color: #151A33; }
.btn-save {
  height: 60px; border: 0; border-radius: 16px; cursor: pointer;
  background: #fff; color: #151A33; font: 800 20px var(--f-display); letter-spacing: -0.01em;
  transition: transform .1s ease, filter .1s ease;
}
.btn-save:hover { filter: brightness(.94); }
.btn-save:active { transform: scale(.98); }
:root[data-theme="dark"] .hour-btn > span { color: var(--ink); }
:root[data-theme="dark"] .punch-form .hour-custom input:not(:placeholder-shown) { color: #151A33; }
.btn-punch {
  border: 0; border-radius: 999px; padding: 12px 24px; font: 700 16px var(--f-display); cursor: pointer;
  background: var(--hi); color: #151A33; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  transition: transform .12s ease; text-decoration: none;
}
.btn-punch:active { transform: scale(.97); }
.punch .logged { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-radius: 12px; background: rgba(255, 255, 255, .08); font-weight: 500; animation: toast-in .3s cubic-bezier(.2, .9, .3, 1.2) both; }
.punch .logged span { display: inline-flex; align-items: center; gap: 8px; }
.punch .logged svg { color: var(--ok); stroke-width: 2.6; }
.punch .linkish { background: none; border: 0; color: var(--hi); font: 600 14px var(--f-body); cursor: pointer; padding: 4px; text-decoration: underline; text-underline-offset: 3px; }
.punch .more-link { color: inherit; opacity: .6; font-size: 13.5px; }
@media (max-width: 860px) { .punch { grid-template-columns: 1fr; } .punch-clock { font-size: 64px; } }

/* ---------- figures strip ---------------------------------------------------------- */
.figures { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; background: var(--sheet); border-radius: var(--r-lg); box-shadow: var(--shadow); margin-bottom: 18px; overflow: hidden; }
.figure { padding: 18px 22px 20px; border-left: 1px solid var(--rule); position: relative; display: block; color: inherit; text-decoration: none; }
a.figure:hover { background: var(--sheet-2); text-decoration: none; }
.figure:first-child { border-left: 0; }
.figure .lbl { font-size: 13.5px; color: var(--ink-2); font-weight: 500; display: flex; gap: 6px; align-items: center; }
.figure .val { font: 800 clamp(26px, 3vw, 34px)/1.15 var(--f-display); letter-spacing: -0.03em; margin-top: 6px; }
.figure .sub { font-size: 13px; color: var(--ink-3); margin-top: 2px; }
.figure.hi .val { background: linear-gradient(transparent 58%, var(--hi) 58%, var(--hi) 92%, transparent 92%); display: inline; }
.figure .up { color: var(--ok); } .figure .down { color: var(--stamp); }
:root[data-theme="dark"] .figure.hi .val { background: none; color: var(--hi); }
@media (max-width: 900px) { .figures { grid-template-columns: 1fr 1fr; } .figure:nth-child(3) { border-left: 0; } .figure:nth-child(n+3) { border-top: 1px solid var(--rule); } }

/* ---------- bar chart ------------------------------------------------------------------ */
.chart { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; align-items: end; height: 240px; padding-top: 22px; }
.bar { display: flex; flex-direction: column; justify-content: flex-end; height: 100%; position: relative; }
.bar .stack { display: flex; flex-direction: column-reverse; border-radius: 6px 6px 3px 3px; overflow: hidden; min-height: 2px; background: var(--rule); }
.bar .seg { width: 100%; background: var(--c); }
.bar .seg.forecast {
  background: repeating-linear-gradient(-45deg, var(--c) 0 3px, color-mix(in srgb, var(--c) 35%, transparent) 3px 7px);
}
.bar .amt { font: 600 11.5px var(--f-display); color: var(--ink-2); text-align: center; margin-bottom: 4px; white-space: nowrap; }
.bar .mon { font-size: 12px; color: var(--ink-3); text-align: center; margin-top: 6px; }
.bar.current .mon { color: var(--ink); font-weight: 600; }
.bar.current .stack { box-shadow: 0 0 0 2px var(--sheet), 0 0 0 3.5px var(--ink); }
.bar[data-tip]:hover::after {
  content: attr(data-tip); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--paper); font-size: 12px; padding: 6px 9px; border-radius: 7px; white-space: pre; z-index: 5; pointer-events: none;
}
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 14px; font-size: 13px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .hatch { width: 14px; height: 10px; border-radius: 2px; background: repeating-linear-gradient(-45deg, var(--ink-3) 0 2px, transparent 2px 5px); }
@media (max-width: 760px) { .chart { height: 190px; gap: 4px; } .bar .amt { display: none; } .bar.current .amt, .bar:last-child .amt { display: block; } }

/* ---------- ceiling gauge -------------------------------------------------------------- */
.gauge { position: relative; height: 16px; margin-bottom: 26px !important; background: var(--sheet-2); border-radius: 999px; border: 1px solid var(--rule); margin: 14px 0 8px; }
.gauge .fill { height: 100%; border-radius: 999px; background: var(--ink-blue); }
.gauge .fill.warn { background: linear-gradient(90deg, var(--ink-blue), var(--stamp)); }
.gauge .pace { position: absolute; top: -6px; bottom: -6px; width: 2px; background: var(--ink); border-radius: 2px; }
.gauge .pace::after { content: "pace"; position: absolute; top: calc(100% + 2px); left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--ink-2); }
.gauge-row { display: flex; justify-content: space-between; font-size: 13.5px; color: var(--ink-2); gap: 10px; flex-wrap: wrap; }
.gauge-row b { color: var(--ink); font-family: var(--f-display); }

/* ---------- heatmap -------------------------------------------------------------------- */
.heat { display: flex; gap: 3px; overflow-x: auto; padding-bottom: 4px; }
.heat .col { display: flex; flex-direction: column; gap: 3px; }
.heat i { width: 13px; height: 13px; border-radius: 3px; background: var(--sheet-2); border: 1px solid var(--rule); display: block; }
.heat i[data-l="1"] { background: color-mix(in srgb, var(--ink-blue) 25%, var(--sheet)); border-color: transparent; }
.heat i[data-l="2"] { background: color-mix(in srgb, var(--ink-blue) 50%, var(--sheet)); border-color: transparent; }
.heat i[data-l="3"] { background: color-mix(in srgb, var(--ink-blue) 75%, var(--sheet)); border-color: transparent; }
.heat i[data-l="4"] { background: var(--ink-blue); border-color: transparent; }
.heat i.today { outline: 2px solid var(--hi); outline-offset: 1px; }

/* ---------- lists / rows ---------------------------------------------------------------- */
.rows { list-style: none; margin: 0; padding: 0; }
.rows li, .row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--rule); }
.rows li:first-child { border-top: 0; }
.row-main { flex: 1; min-width: 0; }
.row-main .t { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* long descriptions: two lines, then … (full text on hover) */
.row-main .t.clamp { white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow-wrap: anywhere; }
.row-main .s { font-size: 13px; color: var(--ink-3); }
.row-amt { font: 700 16px var(--f-display); white-space: nowrap; }
.avatar { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font: 800 13px var(--f-display); color: #151A33; background: var(--c); flex: none; }
/* Logos are shown exactly as uploaded: never clipped by a rounded frame, scaled to fit, not cropped. */
.avatar.has-logo { background: none; padding: 0; border-radius: 0; overflow: visible; box-shadow: none; }
.avatar.has-logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.logo-row { display: flex; gap: 14px; align-items: flex-start; }
.meter { height: 6px; border-radius: 99px; background: var(--sheet-2); overflow: hidden; margin-top: 6px; }
.meter > span { display: block; height: 100%; background: var(--c, var(--ink-blue)); border-radius: 99px; }

.empty { text-align: center; padding: 28px 12px; color: var(--ink-2); }
.empty p { margin: 4px 0 14px; }

/* ---------- tables ----------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; margin: 0 -22px; padding: 0 22px; }
table.ledger { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.ledger th { text-align: left; font-weight: 500; font-size: 13px; color: var(--ink-3); padding: 8px 10px; border-bottom: 1.5px solid var(--ink); white-space: nowrap; }
.ledger td { padding: 10px; border-bottom: 1px solid var(--rule); vertical-align: middle; overflow-wrap: anywhere; }
.ledger tr:last-child td { border-bottom: 0; }
.ledger tfoot td { border-top: 1.5px solid var(--ink); font-weight: 700; font-family: var(--f-display); border-bottom: 0; }
.ledger .r { text-align: right; white-space: nowrap; }
.ledger tbody tr:hover td { background: var(--sheet-2); }
.ledger td.exp { background: var(--hi-soft); }
.ledger .clickrow { cursor: pointer; }

/* ---------- status badges and the stamp ---------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; background: var(--sheet-2); color: var(--ink-2); border: 1px solid var(--rule); }
.badge.sent { background: var(--ink-blue-soft); color: var(--ink-blue); border-color: transparent; }
.badge.paid { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.overdue { background: color-mix(in srgb, var(--stamp) 14%, var(--sheet)); color: var(--stamp); border-color: transparent; }
.badge.draft { border-style: dashed; }
.badge.cancelled { text-decoration: line-through; }
.badge.hi { background: var(--hi-soft); color: var(--ink); border-color: transparent; }

.stamp {
  position: absolute; top: 26px; right: 30px; transform: rotate(-11deg);
  font: 800 38px/1 var(--f-display); letter-spacing: .06em; padding: 6px 16px;
  color: var(--ok); border: 4px solid currentColor; border-radius: 10px; opacity: .85;
  mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='60'><filter id='n'><feTurbulence baseFrequency='.9' numOctaves='2'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 -2.2 1.6'/></filter><rect width='120' height='60' filter='url(%23n)'/></svg>");
  pointer-events: none;
}
.stamp.overdue { color: var(--stamp); }
.stamp.thump { animation: thump .45s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes thump { from { transform: rotate(-11deg) scale(2.2); opacity: 0; } to { transform: rotate(-11deg) scale(1); opacity: .85; } }

/* ---------- forms --------------------------------------------------------------------------- */
label { font-size: 13.5px; font-weight: 500; color: var(--ink-2); display: block; margin-bottom: 5px; }
input[type=text], input[type=number], input[type=email], input[type=url], input[type=date], input[type=month], input[type=password], input:not([type]), select, textarea {
  width: 100%; font: 15px/1.3 var(--f-body); color: var(--ink);
  background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-sm); padding: 10px 12px;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink-blue); box-shadow: 0 0 0 3px var(--ink-blue-soft); }
input[type=color] { width: 54px; height: 38px; padding: 2px; border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--sheet); }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--ink-blue); vertical-align: middle; }
textarea { resize: vertical; }
.field { margin-bottom: 14px; }
.field .help { font-size: 12.5px; color: var(--ink-3); margin-top: 4px; }
.field .err, .errorlist { color: var(--stamp); font-size: 13px; margin: 4px 0 0; padding: 0; list-style: none; }
.field.check { display: flex; gap: 10px; align-items: flex-start; }
.field.check label { margin: 0; color: var(--ink); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 16px; }
.form-grid .wide { grid-column: 1 / -1; }
fieldset { border: 0; padding: 0; margin: 0 0 18px; }
legend { font: 700 16px var(--f-display); margin-bottom: 10px; padding: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 999px; border: 1px solid var(--rule); background: var(--sheet);
  color: var(--ink); font: 600 14.5px var(--f-body); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .12s, transform .1s;
}
.btn:hover { background: var(--sheet-2); text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--ink-blue); color: #fff; border-color: var(--ink-blue); }
.btn.primary:hover { background: color-mix(in srgb, var(--ink-blue) 88%, #000); }
.btn.dark { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn.ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn.danger { color: var(--stamp); }
.btn.sm { padding: 6px 12px; font-size: 13.5px; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn svg { width: 17px; height: 17px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* chips: radio/checkbox pills for clients and durations */
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip { position: relative; margin: 0; }
.chip input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.chip > span {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; border-radius: 999px;
  border: 1px solid var(--rule); background: var(--sheet); font: 500 14px var(--f-body); color: var(--ink); cursor: pointer;
  transition: background .1s, border-color .1s;
}
.chip input:checked + span { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip input:checked + span .dot { box-shadow: 0 0 0 2px var(--paper); }
.chip input:focus-visible + span { outline: 2.5px solid var(--ink-blue); outline-offset: 2px; }
.chip.dur span { font-family: var(--f-display); font-weight: 600; min-width: 48px; justify-content: center; }

/* quick log */
.quick { display: grid; gap: 14px; }
.quick-row { display: grid; grid-template-columns: 1fr 150px 120px; gap: 12px; align-items: end; }
@media (max-width: 760px) { .quick-row { grid-template-columns: 1fr 1fr; } .quick-row .desc { grid-column: 1 / -1; } }

/* time log days */
.day { margin-bottom: 10px; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; padding: 16px 0 6px; border-bottom: 1.5px solid var(--ink); }
.day-head h3 { font-size: 15px; }
.day-head .num { font-weight: 700; }
.entry { display: grid; grid-template-columns: auto 1fr auto auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.entry .desc { min-width: 0; }
.entry .desc .t { overflow-wrap: anywhere; }
.entry .desc .s { font-size: 12.5px; color: var(--ink-3); display: flex; gap: 10px; flex-wrap: wrap; }
.entry .h { font: 700 16px var(--f-display); white-space: nowrap; }
.entry .edit { opacity: .45; }
.entry:hover .edit { opacity: 1; }
.month-nav { display: flex; align-items: center; gap: 6px; }
.month-nav .cur { font: 700 18px var(--f-display); min-width: 9.5em; text-align: center; }

/* invoice editor */
.lines td { padding: 6px 6px; }
.lines input { padding: 8px 10px; }
.lines td:first-child { width: 100%; min-width: 220px; }
.lines .q { min-width: 84px; width: 84px; } .lines .p { min-width: 110px; width: 110px; }
.inv-sheet { position: relative; }
.total-big { font: 800 40px/1 var(--f-display); letter-spacing: -0.03em; }

.month-group { border: 1px solid var(--rule); border-radius: var(--r-md); margin-bottom: 12px; overflow: hidden; }
.month-group header { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; background: var(--sheet-2); }
.month-group label.pick { display: flex; gap: 10px; align-items: center; padding: 9px 14px; border-top: 1px solid var(--rule); margin: 0; color: var(--ink); font-weight: 400; cursor: pointer; }
.month-group label.pick:hover { background: var(--sheet-2); }
.month-group label.pick .t { flex: 1; min-width: 0; }
.client-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.client-pick a { display: flex; gap: 12px; align-items: center; padding: 14px; border-radius: var(--r-md); background: var(--sheet); border: 1px solid var(--rule); color: var(--ink); text-decoration: none; }
.client-pick a:hover { border-color: var(--ink-blue); }
.client-pick a.on { border-color: var(--ink-blue); box-shadow: 0 0 0 3px var(--ink-blue-soft); }

.sticky-bar { position: sticky; bottom: 12px; z-index: 10; display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; background: var(--ink); color: var(--paper); border-radius: var(--r-md); padding: 12px 14px 12px 20px; margin-top: 16px; }
.sticky-bar .num { font-size: 20px; font-weight: 800; }
@media (max-width: 760px) { .sticky-bar { bottom: calc(96px + var(--safe-b)); } }

/* tabs */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs a { padding: 6px 13px; border-radius: 999px; color: var(--ink-2); font-weight: 500; font-size: 14px; }
.tabs a.on { background: var(--ink); color: var(--paper); text-decoration: none; }
.tabs a .c { opacity: .6; margin-left: 4px; }

/* list tools: active/all toggle + sort */
.list-tools { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.seg { display: inline-flex; background: var(--sheet); border: 1px solid var(--rule); border-radius: 999px; padding: 3px; }
.seg a { padding: 6px 14px; border-radius: 999px; color: var(--ink-2); font-weight: 500; font-size: 14px; text-decoration: none; }
.seg a.on { background: var(--ink); color: var(--paper); }
.seg .c { opacity: .6; font-size: 12.5px; }
.sort-by { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 14px; }
.sort-by select { width: auto; padding: 7px 12px; border-radius: 999px; font-weight: 500; }
.kv .sorted .k { color: var(--ink-blue); font-weight: 600; }
@media (max-width: 520px) {
  .sort-by { width: 100%; }
  .sort-by select { flex: 1; }
}

/* mobile-only top bar: currency + settings (the desktop rail has these) */
.mobile-top { display: none; }
@media (max-width: 760px) {
  .mobile-top { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin: -4px 0 12px; }
  .mobile-top .cur-switch { margin: 0; width: 96px; }
  .mobile-top .gear { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: var(--sheet); border: 1px solid var(--rule); color: var(--ink-2); }
}

/* new-invoice modes, past-invoice upload and review */
.mode-tabs { margin-bottom: 18px; flex-wrap: wrap; }
.upload-panel { max-width: 720px; }
.drop {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  padding: 34px 20px; border: 2px dashed var(--rule); border-radius: var(--r-lg); background: var(--sheet-2);
  color: var(--ink); cursor: pointer; margin: 0;
}
.drop:hover, .drop:focus-within { border-color: var(--ink-blue); }
.drop svg { width: 34px; height: 34px; color: var(--ink-blue); }
.drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop [data-filename-label] { font-weight: 600; color: var(--ink-blue); }
.review-banner { background: var(--hi-soft); border-radius: var(--r-md); padding: 12px 16px; margin-bottom: 16px; }
.pick-line { display: flex; gap: 10px; align-items: center; color: var(--ink); font-weight: 400; padding: 4px 0; margin: 0; }
.lines td.c { text-align: center; }
.lines input[name$=DELETE] { accent-color: var(--stamp); }
.lines th.c { text-align: center; }
.link-list { max-height: 320px; overflow-y: auto; border: 1px solid var(--rule); border-radius: var(--r-md); }
.link-list label.pick { display: flex; gap: 10px; align-items: center; padding: 8px 12px; border-top: 1px solid var(--rule); margin: 0; color: var(--ink); font-weight: 400; cursor: pointer; }
.link-list label.pick:first-child { border-top: 0; }
.link-list .t { flex: 1; min-width: 0; }

.ledger tfoot tr.sub td { font-weight: 500; font-family: var(--f-body); border-top: 0; color: var(--ink-2); padding-top: 6px; padding-bottom: 6px; }
.ledger tfoot tr.sub:first-child td { border-top: 1.5px solid var(--ink); }
.ledger tfoot tr.sub + tr:not(.sub) td { border-top: 1px solid var(--rule); }
.discount-edit { display: inline-flex; align-items: center; gap: 8px; }
.discount-edit input { width: 110px; padding: 6px 10px; }
.discount-edit select { width: auto; padding: 6px 10px; }
.edit-bar { display: flex; justify-content: flex-end; margin: -4px 0 8px; position: relative; z-index: 2; }
.danger-zone { border: 1px solid color-mix(in srgb, var(--stamp) 35%, var(--rule)); box-shadow: none; }
.danger-zone h2 { color: var(--stamp); margin-bottom: 8px; }
.btn.danger { border-color: color-mix(in srgb, var(--stamp) 45%, var(--rule)); }
.month-link { color: inherit; text-decoration: none; padding: 2px 4px; border-radius: 6px; }
.month-link:hover, .month-link.on { background: var(--ink); color: var(--paper); text-decoration: none; }
.cell-link { color: inherit; text-decoration: none; }
.cell-link:hover { color: var(--ink-blue); text-decoration: underline; }
.month-tabs a { padding: 5px 10px; }
/* appearance switch: the chosen option is highlighted straight from the <html> attribute */
.theme-switch button { display: grid; place-items: center; }
.theme-switch svg { width: 16px; height: 16px; }
:root[data-theme-choice="light"] .theme-switch [data-theme-set="light"],
:root[data-theme-choice="dark"] .theme-switch [data-theme-set="dark"],
:root[data-theme-choice="auto"] .theme-switch [data-theme-set="auto"] { background: var(--sheet); color: var(--ink); box-shadow: var(--shadow); }
.mobile-top .theme-switch { margin: 0; width: 112px; }
.filter-note { margin: 0 0 12px; font-size: 14px; color: var(--ink-2); }
.missing-banner { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  margin-bottom: 18px; background: var(--hi-soft); box-shadow: none; }
.missing-banner > div { flex: 1; min-width: 240px; }

/* client cards: the whole card opens the client (stretched link) */
.client-card { position: relative; }
.client-card .card-link { color: inherit; text-decoration: none; }
.client-card .card-link::after { content: ""; position: absolute; inset: 0; border-radius: inherit; z-index: 1; }
.client-card:has(.card-link:focus-visible) { outline: 2.5px solid var(--ink-blue); outline-offset: 2px; }
.client-card .card-link:focus-visible { outline: none; }

/* client cards */
.client-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.client-card { background: var(--sheet); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 18px; color: var(--ink); text-decoration: none; display: flex; flex-direction: column; gap: 14px; border-top: 5px solid var(--c); }
.client-card:hover { text-decoration: none; transform: translateY(-1px); }
/* Inactive cards are greyed with colors only: opacity would layer the card over its own link. */
.client-card.inactive { background: var(--sheet-2); box-shadow: none; border: 1px solid var(--rule); border-top: 5px solid var(--rule); }
.client-card.inactive h3, .client-card.inactive .v, .client-card.inactive .kv .k, .client-card.inactive .small { color: var(--ink-3); }
.client-card.inactive .avatar { filter: grayscale(1); opacity: .55; }
.client-card .kv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kv .k { font-size: 12.5px; color: var(--ink-3); }
.kv .v { font: 700 17px var(--f-display); }

/* toasts */
.toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(520px, calc(100% - 24px)); }
.toast { background: var(--ink); color: var(--paper); padding: 12px 16px; border-radius: var(--r-md); box-shadow: var(--shadow); font-weight: 500; animation: toast-in .3s cubic-bezier(.2, .9, .3, 1.2) both; }
.toast.error { background: var(--stamp); color: #fff; }
.toast.warning { background: var(--hi); color: #151A33; }
.toast.out { opacity: 0; transform: translateY(-8px); transition: .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-12px) scale(.98); } }

/* details / disclosure */
details.more summary { cursor: pointer; color: var(--ink-blue); font-weight: 500; list-style: none; }
details.more summary::-webkit-details-marker { display: none; }
details.more[open] summary { margin-bottom: 12px; }

/* login */
body.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: min(400px, 100%); background: var(--sheet); border-radius: 24px; box-shadow: var(--shadow); padding: 34px 30px 28px; position: relative; overflow: hidden; }
.auth-card::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 8px; background: var(--ink-blue); }
.auth-card h1 { font-size: 30px; margin: 8px 0 4px; }

/* print view */
.print-sheet { background: #fff; color: #151A33; max-width: 820px; margin: 30px auto; padding: 56px; border-radius: 6px; box-shadow: var(--shadow); }
@media print {
  body { background: #fff; }
  .rail, .tabbar, .no-print, .toasts { display: none !important; }
  .page { margin: 0; padding: 0; }
  .print-sheet { box-shadow: none; margin: 0; padding: 0; }
}

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