﻿/* ==========================================================================
   Khata - "Slate & Emerald"

   One rule drives the whole palette: red and green are the ONLY loud colours,
   so they read as money out / money in and nothing else competes with them.

   Two shells, one stylesheet:
     < 960px   phone/tablet - bottom tab bar, stacked rows, large touch targets
     >= 960px  laptop/desktop - fixed sidebar, dense data tables

   Controls are compact on desktop and grow on touch devices, so the same
   markup is precise with a mouse and still tappable with a thumb.
   ========================================================================== */

/* --- Tokens ------------------------------------------------------------- */

:root {
  /* surfaces */
  --bg:            #FAFAF9;
  --surface:       #FFFFFF;
  --surface-2:     #F5F5F4;
  --surface-3:     #EFEDEC;

  /* text */
  --text:          #1C1917;
  --muted:         #78716C;
  --faint:         #A8A29E;

  /* lines */
  --line:          #E7E5E4;
  --line-strong:   #D6D3D1;

  /* accent */
  --accent:        #047857;
  --accent-hover:  #065F46;
  --accent-soft:   #ECFDF5;
  --accent-line:   #A7F3D0;

  /* money - the only loud colours in the app */
  --in:            #059669;
  --in-soft:       #ECFDF5;
  --out:           #DC2626;
  --out-soft:      #FEF2F2;
  --warn:          #B45309;
  --warn-soft:     #FFFBEB;

  /* Sharp, not bubbly. Soft corners and drop shadows read consumer-friendly;
     financial software should read precise. Borders do the separating. */
  --radius:        6px;
  --radius-sm:     4px;
  --radius-pill:   999px;

  /* 4px scale */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px;

  --font-sans: "Space Grotesk", system-ui, -apple-system, "Segoe UI Variable Text",
               "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --sidebar-w:  244px;
  --topbar-h:   52px;
  --mobilenav-h: 58px;

  --ctl-h-sm:   28px;   /* dense actions on a card, raised on touch below */
  --ctl-h:      34px;   /* compact default, raised on touch below */
  --ctl-h-lg:   40px;
}

/* --- Reset -------------------------------------------------------------- */

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

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p, figure { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
table { border-collapse: collapse; width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-radius: var(--radius-sm);
}

/* --- Shell -------------------------------------------------------------- */

.shell {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100dvh;
}

.shell__main {
  min-width: 0;              /* lets wide tables shrink instead of pushing the page */
  display: flex;
  flex-direction: column;
}

.content {
  flex: 1;
  padding: var(--s4);
  width: 100%;
  /* Deliberately uncapped. Capping it left a dead strip beside a full-width top
     bar on large monitors; tables are also the one thing that genuinely benefits
     from the extra width. Individual forms are narrowed with .form-narrow. */
}

/* --- Sidebar (desktop only) --------------------------------------------- */

.sidebar {
  display: none;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
  height: 100dvh;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--s2);
  /* min-height rather than height: a long business name is allowed to wrap to a
     second line instead of being clipped or forced into a tiny font. */
  min-height: var(--topbar-h);
  padding: var(--s2) var(--s4);
  border-bottom: 1px solid var(--line);
  flex: none;
}

.brandmark {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  flex: none;
}

.brandname {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--text);
  min-width: 0;
}

/* On the mobile top bar there is no room to wrap, so it truncates instead. */
.topbar__brand .brandname {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__nav { flex: 1; overflow-y: auto; padding: var(--s3) var(--s2); }

.sidebar__group {
  padding: var(--s4) var(--s3) var(--s1);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--faint);
}
.sidebar__group:first-child { padding-top: var(--s1); }

.sidenav {
  display: flex;
  align-items: center;
  gap: var(--s3);
  height: 34px;
  padding: 0 var(--s3);
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted);
}
.sidenav svg { width: 16px; height: 16px; flex: none; stroke-width: 1.75; }
.sidenav:hover { background: var(--surface-2); color: var(--text); }
.sidenav.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* --- Grouped navigation ---------------------------------------------------
   One entry that opens into several, built on <details> so it needs no script.
   ------------------------------------------------------------------------ */

.navgroup__head {
  list-style: none;
  cursor: pointer;
  user-select: none;
}
.navgroup__head::-webkit-details-marker { display: none; }

/* The parent says where you are without pretending to be the page you are on -
   that highlight belongs to whichever child is actually open. */
.navgroup__head.is-inside { color: var(--text); font-weight: 600; }

.navgroup__chevron {
  width: 14px !important;
  height: 14px !important;
  color: var(--faint);
  transition: transform .12s ease;
}
.navgroup[open] .navgroup__chevron { transform: rotate(180deg); }

/* Indented against a hairline, so the three read as belonging to the entry
   above them rather than as three more top level areas. */
.navgroup__items {
  margin: 2px 0 2px 19px;
  padding-left: var(--s2);
  border-left: 1px solid var(--line);
}

.sidebar__foot {
  flex: none;
  border-top: 1px solid var(--line);
  padding: var(--s3);
  display: flex;
  align-items: center;
  gap: var(--s3);
}
.sidebar__user { flex: 1; min-width: 0; }
.sidebar__username {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar__userrole { font-size: 11.5px; color: var(--faint); }

/* --- Top bar ------------------------------------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--s3);
  height: var(--topbar-h);
  padding: 0 var(--s4);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar__title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar__actions { display: flex; align-items: center; gap: var(--s2); flex: none; }

.topbar__back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin-left: -6px;
  border-radius: var(--radius);
  color: var(--muted);
  flex: none;
}
.topbar__back:hover { background: var(--surface-2); color: var(--text); }

/* Brand shown in the top bar only on mobile, where there is no sidebar. */
.topbar__brand { display: flex; align-items: center; gap: var(--s2); flex: 1; min-width: 0; }

/* --- Mobile bottom nav -------------------------------------------------- */

.mobilenav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  height: calc(var(--mobilenav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.mobilenav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--muted);
}
.mobilenav__item svg { width: 20px; height: 20px; stroke-width: 1.75; }
.mobilenav__item.is-active { color: var(--accent); }

.has-mobilenav .content { padding-bottom: calc(var(--mobilenav-h) + 16px + env(safe-area-inset-bottom)); }

/* --- Panels ------------------------------------------------------------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel__head {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.panel__title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  flex: 1;
}

.panel__body { padding: var(--s4); }
.panel__foot { padding: var(--s3) var(--s4); border-top: 1px solid var(--line); }

.panel + .panel { margin-top: var(--s4); }

/* --- Stats -------------------------------------------------------------- */

.stat-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s3);
  margin-bottom: var(--s4);
}

.stat {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--s3) var(--s4);
  /* Most stats are links; without this they would inherit the global link
     colour and a neutral figure like cash in hand would read as money in. */
  color: var(--text);
}
a.stat:hover { border-color: var(--line-strong); background: var(--surface); color: var(--text); }

.stat__label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat__value {
  margin-top: 2px;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat__meta { font-size: 12px; color: var(--faint); margin-top: 2px; }

.stat--in  .stat__value { color: var(--in); }
.stat--out .stat__value { color: var(--out); }

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

/* tabular-nums is what makes columns of rupees line up. Small detail, large
   effect on whether the app reads as serious financial software. */
.money { font-variant-numeric: tabular-nums; font-weight: 600; }
.money--in  { color: var(--in); }
.money--out { color: var(--out); }

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

.table-wrap { overflow-x: auto; }

.table { font-size: 13px; }

.table th {
  text-align: left;
  padding: var(--s2) var(--s4);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.table td {
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }

/* Links inside data are plain text until hovered. If every party name were
   emerald it would compete with the money colours, which are supposed to be
   the only thing on screen carrying colour meaning. */
.table a, .rows a { color: inherit; }
.table a:hover, .rows a:hover { color: var(--accent); text-decoration: underline; }

.table__num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* The heading sits over its figures, beating the left alignment every th starts with. */
.table th.table__num { text-align: right; }
.table__nowrap { white-space: nowrap; }
.table__strong { font-weight: 500; }
.table__muted { color: var(--muted); }
/* Wraps rather than stretching the grid, since an address is the one free-text column.
   Only where there are columns at all: stacked on a phone it has the whole line. */
@media (min-width: 640px) {
  .table__address { min-width: 160px; max-width: 260px; }
}

/* A reversed entry stays visible but is struck through - the ledger is
   append-only, so a correction never removes the original row. */
.table__void { color: var(--faint); text-decoration: line-through; }

/* On phones a wide table cannot work. Two strategies, both keeping one markup:

   .table--stack  generic fallback - each cell becomes a "Label: value" line.
                  Correct for any column set, but verbose.
   .table--feed   purpose-built for the name / details / date / amount shape used
                  by activity and party lists. Reflows into a compact two-line row
                  with the amount pinned right, so many more entries fit on screen.
   .table--day    purpose-built for the attendance sheet, which is the one screen
                  somebody stands in the gate with. Keeps the punches, the pay and
                  the In/Out button on three tight lines instead of eight.
*/
@media (max-width: 639px) {
  .table--stack thead,
  .table--day thead,
  .table--feed thead { display: none; }

  .table--stack tbody tr {
    display: block;
    padding: var(--s3) var(--s4);
    border-bottom: 1px solid var(--line);
  }
  .table--stack tbody tr:last-child { border-bottom: 0; }
  .table--stack td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--s4);
    padding: 2px 0;
    border: 0;
    text-align: right;
  }
  .table--stack td::before {
    content: attr(data-label);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--muted);
    text-align: left;
    flex: none;
  }
  .table--stack td[data-label=""]::before { content: none; }
  /* A cell with nothing to say for this row, left out rather than shown as a bare label. */
  .table--stack td.table__blank { display: none; }
  /* With no label to its left, a row's buttons still belong on the right. */
  .table--stack td[data-label=""] { justify-content: flex-end; }

  .table--feed tbody tr {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "name   amount"
      "detail date";
    column-gap: var(--s4);
    padding: var(--s3) var(--s4);
    border-bottom: 1px solid var(--line);
  }
  .table--feed tbody tr:last-child { border-bottom: 0; }
  .table--feed td { display: block; padding: 0; border: 0; }
  .table--feed td::before { content: none; }

  .table--feed td[data-label="Name"]    { grid-area: name; font-weight: 500; }
  .table--feed td[data-label="Details"] { grid-area: detail; font-size: 12px; margin-top: 3px; }
  /* The date rides under the amount rather than being dropped - on a phone the
     entry still has to say when it happened. */
  .table--feed td[data-label="Date"]    {
    grid-area: date;
    text-align: right;
    font-size: 11.5px;
    color: var(--faint);
    margin-top: 3px;
  }
  .table--feed td[data-label="Amount"]  {
    grid-area: amount;
    text-align: right;
    font-size: 15px;
    font-weight: 600;
  }

  .table--day tbody tr {
    display: grid;
    grid-template-columns: auto auto auto 1fr;
    grid-template-areas:
      "name   name  name  name"
      "punch  punch punch punch"
      "status hours ot    pay"
      "act    act   act   act";
    align-items: baseline;
    column-gap: var(--s2);
    row-gap: 5px;
    padding: var(--s3) var(--s4);
    border-bottom: 1px solid var(--line);
  }
  .table--day tbody tr:last-child { border-bottom: 0; }
  .table--day td { display: block; padding: 0; border: 0; text-align: left; }
  .table--day td::before { content: none; }

  .table--day td[data-label="Naam"]  { grid-area: name; font-weight: 500; }
  .table--day td[data-label="Halat"] { grid-area: status; }

  /* Every spell of the day on one line. A phone has no room for the tree rows the
     desktop table opens, so the cell itself carries the whole list. */
  /* A line of its own: several spells is a lot of words, and squeezed into a
     column beside the money it stops reading as times at all. */
  .table--day td[data-label="In / Out"] {
    grid-area: punch;
    font-size: 12px;
    color: var(--muted);
  }

  .table--day td[data-label="Ghantay"] { grid-area: hours; font-size: 12px; }
  .table--day td[data-label="Extra"]   { grid-area: ot; font-size: 12px; color: var(--muted); }
  .table--day td[data-label="Mazdoori"] {
    grid-area: pay;
    text-align: right;
    font-size: 15px;
    font-weight: 600;
  }
  .table--day td[data-label=""]         { grid-area: act; text-align: right; margin-top: 4px; }

}

.table tbody tr.subrow > td {
  padding-top: var(--s1);
  padding-bottom: var(--s1);
  background: var(--surface-2);
  border-bottom: 0;
  font-size: 12.5px;
  color: var(--muted);
}
.table tbody tr.subrow:last-of-type > td { border-bottom: 1px solid var(--line); }

/* On a phone there is no room for child rows, and none is needed: the punches
   cell lists every spell itself. Stated here rather than up with the other
   mobile table rules, because it has to come after the rules it overrides. */
@media (max-width: 639px) {
  .table tbody tr.subrow { display: none; }
  .treetoggle { display: none; }
}

/* --- Rows (mobile list pattern) ----------------------------------------- */

.rows { display: flex; flex-direction: column; }

.row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--line);
  color: inherit;
  min-height: 52px;
}
.row:last-child { border-bottom: 0; }
a.row:hover { background: var(--surface-2); color: inherit; }

.row__main { flex: 1; min-width: 0; }
.row__name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row__sub {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row__end { text-align: right; flex: none; }
.row__amount { font-variant-numeric: tabular-nums; font-weight: 600; }
.row__hint { font-size: 11px; color: var(--faint); }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--ctl-h);
  padding: 0 var(--s3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s ease, border-color .12s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; stroke-width: 2; }

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }

/* Dense enough that five actions fit on one line of a card, and still a real
   target under a thumb because the height comes from the same token that grows
   on a touch screen. */
.btn--sm {
  height: var(--ctl-h-sm);
  padding: 0 7px;
  font-size: 12.5px;
  gap: 4px;
}
.btn--sm svg { width: 14px; height: 14px; }

/* Icon only. The word is still there for anyone who cannot see the glyph, in
   aria-label, and shows as a tooltip on hover. */
.btn--icon { width: var(--ctl-h); padding: 0; }
.btn--sm.btn--icon { width: var(--ctl-h-sm); }

.btn--in  { background: var(--in);  border-color: var(--in);  color: #fff; }
.btn--in:hover  { background: #047857; border-color: #047857; color: #fff; }
.btn--out { background: var(--out); border-color: var(--out); color: #fff; }
.btn--out:hover { background: #B91C1C; border-color: #B91C1C; color: #fff; }

/* Paying somebody is the consequential action on a card, but it is not the one
   done every day. Outlined in the accent rather than filled: a tint at this
   size read as a disabled button, and a fill would have put a second green
   slab next to the clock. */
.btn--accent {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
.btn--accent:hover {
  background: var(--accent-soft);
  border-color: var(--accent-hover);
  color: var(--accent-hover);
}

/* Reads as an ordinary button until you are about to press it. */
.btn--peril:hover {
  background: var(--out-soft);
  border-color: var(--out);
  color: var(--out);
}

.btn--ghost { border-color: transparent; background: transparent; }
.btn--ghost:hover { background: var(--surface-2); }

.btn--lg { height: var(--ctl-h-lg); padding: 0 var(--s4); font-size: 14px; }
.btn--block { display: flex; width: 100%; }

.btn-row { display: flex; gap: var(--s2); }
.btn-row--fill > .btn { flex: 1; }

/* Two fixed buttons at the bottom of a khata, always reachable with a thumb. */
.actionbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  gap: var(--s2);
  padding: var(--s3) var(--s4) calc(var(--s3) + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.actionbar > .btn { flex: 1; }
.has-actionbar .content { padding-bottom: 84px; }

/* With the tab bar on screen as well, the two buttons sit on top of it, not over it. */
.has-mobilenav.has-actionbar ~ .actionbar {
  bottom: calc(var(--mobilenav-h) + env(safe-area-inset-bottom));
  padding-bottom: var(--s3);
}
.has-mobilenav.has-actionbar .content {
  padding-bottom: calc(var(--mobilenav-h) + 84px + env(safe-area-inset-bottom));
}
/* The same two buttons are in the page for a desktop; a phone has them in the bar. */
@media (max-width: 959px) {
  .has-actionbar .btn--entry { display: none; }
}

.btn-row--wrap { flex-wrap: wrap; }

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

.field { margin-bottom: var(--s4); }
.field:last-child { margin-bottom: 0; }

.field__label {
  display: block;
  margin-bottom: 5px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
}

.input, .select, .textarea {
  display: block;
  width: 100%;
  height: var(--ctl-h-lg);
  padding: 0 var(--s3);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  transition: border-color .12s ease, box-shadow .12s ease;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { height: auto; min-height: 76px; padding: var(--s2) var(--s3); resize: vertical; }

/* The amount is the point of every entry screen, so it gets to be big. */
.input--amount {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  height: 56px;
}

.input::placeholder, .textarea::placeholder { color: var(--faint); }

.field__error { display: block; margin-top: 5px; font-size: 12.5px; color: var(--out); }
.punchrow .input { flex: 1; min-width: 0; }

/* The grid owns the spacing between its own fields, so a .field inside it drops
   the margin it carries when it stands alone. Without this the last field in a
   grid sits flush against whatever follows the grid. */
.form-grid { display: grid; grid-template-columns: 1fr; gap: var(--s4); margin-bottom: var(--s4); }
.form-grid:last-child { margin-bottom: 0; }
.form-grid > .field { margin-bottom: 0; }

/* --- Alerts ------------------------------------------------------------- */

.alert {
  padding: var(--s2) var(--s3);
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: var(--s4);
}
.alert:empty { display: none; }
.alert--error   { background: var(--out-soft);  color: #991B1B; border-color: #FECACA; }
.alert--warn    { background: var(--warn-soft); color: #92400E; border-color: #FDE68A; }
.alert--success { background: var(--in-soft);   color: #065F46; border-color: var(--accent-line); }
.alert--info    { background: var(--surface-2); color: var(--muted); border-color: var(--line); }

/* --- Badges ------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.badge--in   { background: var(--in-soft);   color: #047857; }
.badge--out  { background: var(--out-soft);  color: #B91C1C; }
.badge--warn { background: var(--warn-soft); color: #92400E; }

/* Seven controls have to share one line for the toolbar to read as one thing,
   and the widths that survive that are tighter than a button standing on its
   own. Trimmed by the padding rather than by dropping a label, because the
   labels are the whole reason the row is legible. */
.card__do .btn { padding: 0 10px; }
.card__do .btn--icon { padding: 0; }
.card__clock > .btn { min-width: 120px; }

/* On a phone the clock takes a line of its own and everything else flows under it. */
@media (max-width: 559px) {
  .card__clock { flex: 1 1 100%; }
  .card__clock > .btn { width: 100%; }
}

/* A phone is not wide enough for a name and a four-figure sum side by side -
   holding that shape chopped people down to "Muhamma...". The name keeps the
   full width and the balance drops under it, label on the left and figure on
   the right, which is how a receipt would set it anyway. */
@media (max-width: 559px) {
  .card__top { flex-wrap: wrap; }
  .card__person { flex: 1 1 100%; }

  .card__balance {
    flex: 1 1 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 2px var(--s3);
    margin-top: var(--s3);
  }
  .card__balance .card__label,
  .card__balance-value { margin-top: 0; }
  .card__derivation {
    flex: 1 1 100%;
    margin-top: 0;
    text-align: right;
    white-space: normal;
  }
}

/* A figure with nothing in it. Deliberately not .table__void, whose strike-through
   means "this was cancelled" - here it only means there is nothing to show. */
.card__none { color: var(--faint); }

/* --- The employee khata page ------------------------------------------------
   Who they are, three figures of arithmetic, then one of two tabs: a month of
   the khata, or the days worked across a range. */

/* The person picker is the heading of the page, so it reads like one, with what
   can be done to that person right after it rather than across the page. */
.picker { display: flex; align-items: center; gap: var(--s2); min-width: 0; max-width: 100%; }
.picker__label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  flex: none;
}
.panel__head:has(> .picker) { flex-wrap: wrap; }
.picker .select {
  width: auto;
  max-width: 100%;
  height: var(--ctl-h);
  font-size: 15px;
  font-weight: 600;
}

/* Label over value, as many to a row as fit. */
.facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--s3) var(--s5);
  margin: 0;
}
.facts dt {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
}
.facts dd { margin: 2px 0 0; }

.tabs {
  display: flex;
  gap: var(--s1);
  margin-bottom: var(--s3);
  border-bottom: 1px solid var(--line);
}
.tabs__tab {
  padding: var(--s2) var(--s3);
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
}
.tabs__tab:hover { color: var(--text); }
.tabs__tab.is-active { color: var(--text); border-bottom-color: var(--accent); }

/* The month as a sum: what came in from before, what happened, where it ended. */
.sums {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.sums > div { display: flex; flex-direction: column; gap: 2px; }
.sums span { font-size: 11.5px; color: var(--muted); }
.sums strong { font-variant-numeric: tabular-nums; }
@media (min-width: 640px) {
  .sums { grid-template-columns: repeat(4, 1fr); }
}

/* A button that has to sit in running text and read as a link, because the
   action behind it changes data and so cannot be a plain anchor. */
.linklike {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 12px;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
}
.linklike:hover { color: var(--accent); }

.chart-days__bar--normal.has-extra { border-radius: 0; }

/* --- Density ------------------------------------------------------------
   Each step buys the cell another line of truth rather than more whitespace.
   ------------------------------------------------------------------------ */

@container (min-width: 620px) {
  .cal__grid { grid-auto-rows: minmax(88px, auto); }
  .cal__lines { display: block; }
  .cal__net { display: flex; }
  .cal__tag--tight { display: none; }
}

/* Narrower than this and the date, a pip and "8h 30m" will not sit on one line, so
   the hours drop underneath rather than being cut off halfway through. */
@container (max-width: 460px) {
  .cal__grid:not(.cal__grid--week) .cal__top { flex-wrap: wrap; }
  .cal__grid:not(.cal__grid--week) .cal__hours {
    flex-basis: 100%;
    margin-left: 0;
    font-size: 10px;
  }
}

/* --- The week, on a phone ------------------------------------------------
   Seven columns of a hundred pixels cannot hold a day's arithmetic, so the week
   view stops being a grid and becomes a list - one row per day, with the whole
   breakdown on it. One set of markup, laid out twice; rendering both and hiding
   one would double the dialogs with it.
   ------------------------------------------------------------------------ */

@container (max-width: 559px) {
  .cal__grid--week { grid-template-columns: 1fr; }

  .cal__grid--week .cal__day {
    flex-direction: row;
    align-items: center;
    gap: var(--s3);
    min-height: 56px;
    padding: var(--s3);
  }

  .cal__grid--week .cal__top { flex: none; width: 74px; }
  .cal__grid--week .cal__hours { margin-left: 0; }

  .cal__grid--week .cal__lines {
    display: block;
    flex: 1;
    min-width: 0;
  }

  /* The week has a whole row per day, so it keeps the total the month cell drops. */
  .cal__grid--week .cal__net {
    display: flex;
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
    flex: none;
  }

  .cal__grid--week .cal__tag { align-self: center; }
  .cal__grid--week .cal__tag--tight { display: none; }
}

/* The weekday strip is the grid's header; once the week is a list it is
   labelling columns that are no longer there. */
@container (max-width: 559px) {
  .cal--week .cal__head { display: none; }
}

/* A thumb needs more than a mouse does, and the compact cell is the one most
   likely to be tapped. */
@media (pointer: coarse) {
  .cal__grid { grid-auto-rows: minmax(64px, auto); }
}

/* --- Empty state -------------------------------------------------------- */

.empty { text-align: center; padding: var(--s10) var(--s5); color: var(--muted); }
.empty__title { font-weight: 600; color: var(--text); margin-bottom: var(--s1); font-size: 15px; }
.empty__text { font-size: 13px; }

/* --- Auth screen -------------------------------------------------------
   Split shell: a brand panel that only appears when there is width to spare,
   and the form itself. A small card marooned in the middle of a 1920px screen
   reads unfinished, so on desktop the page fills.
   ----------------------------------------------------------------------- */

.auth {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1fr;
  background: var(--surface);
}

.auth__panel {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  padding: var(--s8);
  background: var(--accent);
  color: #fff;
  /* Login carries no money figures, so the brand is free to use the accent
     at full strength here without competing with the in/out colours. */
  background-image:
    radial-gradient(120% 90% at 100% 0%, rgba(255,255,255,.10) 0%, transparent 55%),
    radial-gradient(90% 80% at 0% 100%, rgba(0,0,0,.16) 0%, transparent 60%);
}

.auth__panelbrand { display: flex; align-items: center; gap: var(--s3); }

.auth__panelmark {
  width: 30px;
  height: 30px;
  border-radius: var(--radius);
  background: rgba(255,255,255,.16);
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 700;
  flex: none;
}

.auth__panelname { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }

.auth__headline {
  font-size: 30px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.025em;
  max-width: 15ch;
}

.auth__points { display: flex; flex-direction: column; gap: var(--s3); margin-top: var(--s6); }

.auth__point {
  display: flex;
  align-items: center;
  gap: var(--s3);
  font-size: 14px;
  color: rgba(255,255,255,.88);
}
.auth__point svg { width: 16px; height: 16px; flex: none; stroke-width: 2.25; }

.auth__foot { font-size: 12.5px; color: rgba(255,255,255,.62); }

.auth__main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s6) var(--s5);
}

.auth__inner { width: 100%; max-width: 340px; }

.auth__brand { margin-bottom: var(--s6); }

.auth__mark {
  width: 36px;
  height: 36px;
  margin-bottom: var(--s4);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 17px;
  font-weight: 700;
}

.auth__title { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
.auth__sub { color: var(--muted); font-size: 13.5px; margin-top: 3px; }

@media (min-width: 960px) {
  .auth { grid-template-columns: 1.05fr 1fr; }
  .auth__panel { display: flex; }
  .auth__main { padding: var(--s8); }
  /* The brand already fills the left panel; repeating the mark beside the form
     would say the same thing twice. */
  .auth__mark { display: none; }
}

/* --- Dialog ---------------------------------------------------------------
   The box a form opens in over the page. Head and foot stay put and only the
   fields scroll, so Save is always in reach however short the screen. */

.dialog {
  width: min(560px, calc(100vw - 2 * var(--s4)));
  max-height: calc(100dvh - 2 * var(--s4));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 16px 48px rgba(28, 25, 23, .18);
}
.dialog[open] { display: flex; flex-direction: column; }
.dialog::backdrop { background: rgba(28, 25, 23, .45); }
body:has(.dialog[open]) { overflow: hidden; }

.dialog > form { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.dialog__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding: var(--s2) var(--s2) var(--s2) var(--s4);
  border-bottom: 1px solid var(--line);
}
.dialog__title { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }

.dialog__body { padding: var(--s4); overflow-y: auto; min-height: 0; }
.dialog__foot { padding: var(--s3) var(--s4); border-top: 1px solid var(--line); }

.dialog__section {
  margin: var(--s5) 0 var(--s3);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
}
.dialog__section:first-child,
.dialog__body > .alert + .dialog__section { margin-top: 0; }

/* The PIN as one box per digit, built by pin-boxes.js from the plain PIN field. */
.pinboxes { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--s2); }
.pinbox {
  height: 52px;
  padding: 0;
  text-align: center;
  font-size: 22px;
  font-weight: 600;
}
.pinbox.is-filled { border-color: var(--accent-line); background: var(--accent-soft); }

.input.input-validation-error { border-color: var(--out); }

/* --- Utilities ---------------------------------------------------------- */

.u-muted  { color: var(--muted); }
.u-small  { font-size: 12.5px; }
.u-center { text-align: center; }
.u-right  { text-align: right; }
.u-mt-2   { margin-top: var(--s2); }
.u-mt-3   { margin-top: var(--s3); }
.u-mt-4   { margin-top: var(--s4); }
.u-mt-6   { margin-top: var(--s6); }
.u-nums   { font-variant-numeric: tabular-nums; }
.u-block  { display: block; }
.u-push   { margin-left: auto; }
.u-inline { display: inline; }
.u-grow   { flex: 1; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Shown only on the desktop shell, or only on the mobile one. */
.only-desktop { display: none; }

/* ==========================================================================
   Touch: a mouse can hit a 34px control, a thumb cannot. Raised by input
   type rather than by screen width, so a touchscreen laptop gets it too.
   ========================================================================== */

@media (pointer: coarse) {
  :root { --ctl-h-sm: 38px; --ctl-h: 42px; --ctl-h-lg: 48px; }
  .row { min-height: 56px; }
  .mobilenav__item { font-size: 11px; }
}

/* ==========================================================================
   Small screens
   ========================================================================== */

@media (max-width: 959px) {
  .content { padding: var(--s3); }
  .table th, .table td { padding-left: var(--s3); padding-right: var(--s3); }
  .panel__head, .panel__body, .panel__foot,
  .card__top, .card__head, .card__tags, .card__metrics, .card__do, .card__actions {
    padding-left: var(--s3);
    padding-right: var(--s3);
  }
  .row { padding-left: var(--s3); padding-right: var(--s3); }
}

/* ==========================================================================
   Desktop: sidebar shell
   ========================================================================== */

@media (min-width: 960px) {
  body { font-size: 13.5px; }

  .shell { grid-template-columns: var(--sidebar-w) 1fr; }

  .sidebar { display: flex; }
  .mobilenav { display: none; }
  .actionbar { display: none; }

  .topbar__brand { display: none; }

  .only-desktop { display: initial; }
  .only-mobile { display: none !important; }

  .content { padding: var(--s5) var(--s6); }

  .has-mobilenav .content,
  .has-actionbar .content { padding-bottom: var(--s6); }

  /* Three headline figures side by side, which is the whole point of having
     the width - the owner sees the state of the business without scrolling. */
  .stat-grid { grid-template-columns: repeat(3, 1fr); gap: var(--s4); }

  .stat { padding: var(--s4) var(--s5); }
  .stat__value { font-size: 26px; }

  .form-grid--2 { grid-template-columns: repeat(2, 1fr); }

  .cards { grid-template-columns: repeat(2, 1fr); gap: var(--s4); }

  /* Forms are read left to right, not stretched across a 1400px screen. */
  .form-narrow { max-width: 560px; }
}

@media (min-width: 1280px) {
  .content { padding: var(--s6) var(--s8); }
}

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

/* --- Dashboard ------------------------------------------------------------
   Staff first: four figures, two weeks of hours, then who is in and who is
   owed side by side. The customer and cash figures follow under a heading. */

.stat__of { font-size: .6em; font-weight: 500; color: var(--faint); }

/* Four figures sit two by two on a phone rather than as one long column, and in
   one row on the desktop. Stated here, after the general stat-grid rules, so the
   desktop count is not undone by the phone one. */
.stat-grid--4 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 960px) {
  .stat-grid--4 { grid-template-columns: repeat(4, 1fr); }
}

.dash-cols { display: grid; grid-template-columns: 1fr; gap: var(--s4); margin-top: var(--s4); }
.dash-cols > .panel + .panel { margin-top: 0; }
@media (min-width: 960px) {
  .dash-cols { grid-template-columns: repeat(2, 1fr); }
}

.section-title {
  margin: var(--s8) 0 var(--s3);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}

.row__end--inline { display: flex; align-items: center; gap: var(--s3); }

/* The two chart colours are the only colours here that are not money. Checked with
   the dataviz palette validator against the panel surface: both clear the lightness,
   chroma, colour-blind separation and contrast checks. Extra time keeps the amber
   its "+1h" badges already wear, so it reads as the same thing everywhere. */
:root {
  --chart-normal: #2F6FB3;
  --chart-extra:  #D97706;
}

.legend { display: flex; gap: var(--s4); margin-bottom: var(--s3); font-size: 12px; color: var(--muted); }
.legend__item { display: inline-flex; align-items: center; gap: 6px; }
.legend__swatch { width: 10px; height: 10px; border-radius: 2px; }
.legend__swatch--normal { background: var(--chart-normal); }
.legend__swatch--extra  { background: var(--chart-extra); }

/* Bars drawn in plain HTML so they stretch to any width with no script. Room is
   left on the left for the axis figures and underneath for the day numbers. */
.hourschart {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 4px;
  height: 180px;
  padding: 0 0 22px 34px;
}

/* Recessive guides: a faint line at the top, the middle and zero. */
.hourschart__grid { position: absolute; inset: 0 0 22px 34px; pointer-events: none; }
.hourschart__grid span {
  position: absolute;
  left: -34px;
  right: 0;
  border-bottom: 1px solid var(--line);
  transform: translateY(50%);
  font-size: 10.5px;
  line-height: 0;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.hourschart__day {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  min-width: 0;
  text-decoration: none;
}
/* The whole column is the target, not only the bar, so a short day is still easy to hit. */
.hourschart__day:hover,
.hourschart__day:focus-visible { background: var(--surface-2); border-radius: var(--radius-sm); outline: none; }

.hourschart__bar {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: min(28px, 70%);
}
.hourschart__normal,
.hourschart__extra { flex-basis: 0; min-height: 2px; }
.hourschart__normal { background: var(--chart-normal); }
.hourschart__extra  { background: var(--chart-extra); }
/* Rounded only at the free end, square on the baseline. */
.hourschart__bar > :first-child { border-radius: 4px 4px 0 0; }

.hourschart__label {
  position: absolute;
  bottom: -20px;
  font-size: 10.5px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.hourschart__day.is-today .hourschart__label { color: var(--text); font-weight: 600; }

/* The figure for a day, on hover or keyboard focus. */
.hourschart__day::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% - 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--surface);
  font-size: 11.5px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .1s ease;
  z-index: 2;
}
.hourschart__day:first-of-type::after { left: 0; transform: none; }
.hourschart__day:last-of-type::after { left: auto; right: 0; transform: none; }
.hourschart__day:hover::after,
.hourschart__day:focus-visible::after { opacity: 1; }

@media (max-width: 639px) {
  /* Fourteen day numbers do not fit a phone; every other one does. */
  .hourschart__day:nth-last-child(2n) .hourschart__label { display: none; }
  .hourschart { gap: 2px; }
}

/* --- Time in and out, in the day box -----------------------------------------
   One line per stretch on the clock: in, out, and what it came to. The two time
   boxes share the width, so the line fits a phone without wrapping. */

.spell {
  display: flex;
  gap: var(--s2);
  align-items: center;
  padding: 3px 0;
}
.spell .input { flex: 1; min-width: 0; }
.spell__to { font-size: 12px; color: var(--faint); flex: none; }
.spell__hours {
  width: 84px;
  flex: none;
  text-align: right;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* --- The attendance day bar -------------------------------------------------
   The date is what the whole sheet is about, so it reads as the heading rather
   than as a small caps label, with the way to another day beside it. */

.daybar { flex-wrap: wrap; }
.daybar .panel__title {
  font-size: 15px;
  letter-spacing: -0.01em;
  text-transform: none;
  color: var(--text);
}
.daybar__pick { display: flex; align-items: center; gap: var(--s1); }
.daybar__pick .input { width: auto; height: var(--ctl-h); }

/* A day's spells in the Time column, one "from - to" per line. */
.spelllist { display: flex; flex-direction: column; gap: 2px; }
.spelllist__line { white-space: nowrap; font-variant-numeric: tabular-nums; }
.spelllist__hours { margin-left: var(--s2); font-size: 12px; color: var(--faint); }

.daybar__total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-variant-numeric: tabular-nums;
}

/* Each button on a day row is its own form, so they need laying out as a set. */
.dayactions {
  display: flex;
  gap: var(--s1);
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}
/* inline-flex, never display:contents - a form with display:contents stops Chrome
   submitting it when its own button is clicked, which is the one thing it must do. */
.dayactions form { display: inline-flex; }

/* --- The customer and vendor khata -------------------------------------------- */

/* A radio with a sentence beside it, big enough to hit with a thumb. */
.choice {
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-height: var(--ctl-h);
  cursor: pointer;
}
.choice input { flex: none; width: 18px; height: 18px; accent-color: var(--accent); }

/* --- Customer and vendor cards ---------------------------------------------
   One card each: who they are, the balance in words, and the two entry buttons.
   As many across as fit, one to a row on a phone. */

.pcards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: var(--s3);
  margin-top: var(--s3);
}

.pcard {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.pcard--closed { opacity: .65; }

.pcard__head {
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
}

.pcard__avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.pcard__who { flex: 1; min-width: 0; }
.pcard__name { display: block; font-size: 15px; font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.pcard__name:hover { color: var(--accent); }
.pcard__sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; overflow-wrap: anywhere; }
.pcard__sub a { color: inherit; }

/* The balance is the point of the card, so it is the biggest thing on it. */
.pcard__balance {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 0 var(--s3);
  margin-top: auto;
  padding: var(--s3) var(--s4);
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
}
.pcard__balance:hover { color: var(--text); }
.pcard__label {
  grid-column: 1 / -1;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
}
.pcard__amount {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.pcard--in  .pcard__amount { color: var(--in); }
.pcard--out .pcard__amount { color: var(--out); }
.pcard--none .pcard__amount { color: var(--faint); }
.pcard__open { font-size: 12px; color: var(--muted); }
.pcard__balance:hover .pcard__open { color: var(--accent); }

.pcard__do { padding: var(--s3) var(--s4); border-top: 1px solid var(--line); }

/* A set of choices as pills: one tap, no typing, no dropdown to open. */
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); border: 0; padding: 0; margin-inline: 0; }
.chips > legend { padding: 0; margin-bottom: 5px; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-flex;
  align-items: center;
  height: var(--ctl-h);
  padding: 0 var(--s3);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  font-weight: 500;
}
.chip input:checked + span { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-soft); }

/* A file picker draws its own button, so it only needs room around it. */
.input--file { height: auto; padding: var(--s2) var(--s3); }

/* What can be done to a line: see its bill, cancel it. */
.khata__do { display: inline-flex; gap: var(--s3); align-items: baseline; }

/* inline-block, so the line through a cancelled row does not run through the reason. */
.khata__cancelled { display: inline-block; text-decoration: none; }

/* --- Print: a khata as a statement --------------------------------------------
   Only the page itself goes on paper - no navigation, no buttons, nothing to press. */

.only-print { display: none; }

.printhead { margin-bottom: var(--s4); }
.printhead__name { font-size: 20px; font-weight: 700; }

@media print {
  .sidebar, .mobilenav, .actionbar, .topbar, .dialog, .alert, .no-print { display: none !important; }
  .only-print { display: block; }

  body { background: #fff; }
  .shell { display: block; min-height: 0; }
  .content { padding: 0 !important; }
  .panel, .stat { box-shadow: none; break-inside: auto; }
  .stat { break-inside: avoid; }
  .table-wrap { overflow: visible; }
  .table tr { break-inside: avoid; }
  .table a { color: inherit; text-decoration: none; }
}
