/* Original foundation; Tailored ledger design tokens and components below. */
:root {
  --ink: #272331;
  --muted: #686474;
  --line: #e5e1e8;
  --plum: #714b67;
  --plum-dark: #624058;
  --paper: #fff;
  --green: #246b54;
  --red: #a44347;
  font-family: Inter, system-ui, sans-serif;
  color: var(--ink);
  background: #f8f7f9;
  font-size: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--plum); outline-offset: 2px; }
i[data-icon] { display: inline-flex; flex: none; vertical-align: middle; }
svg { width: 17px; height: 17px; }
.topbar { height: 59px; background: var(--plum); color: #fff; display: flex; align-items: center; gap: 22px; padding: 0 25px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.brand-text { font-size: 17px; line-height: 1.05; }
.brand-text small { display: block; margin-top: 3px; color: #f8eef6; font-size: 10px; font-weight: 500; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; background: #ffffff24; border-radius: 7px; }
.theme-toggle { margin-left: auto; min-height: 38px; display: inline-flex; align-items: center; gap: 7px; padding: 0 10px; border: 1px solid #ffffff60; border-radius: 5px; color: white; background: transparent; font-size: 12px; font-weight: 600; white-space: nowrap; }
.theme-toggle:hover, .theme-toggle[aria-pressed="true"] { background: #ffffff24; }
.theme-toggle:focus-visible { outline-color: white; }
.theme-toggle .sun, .theme-toggle[aria-pressed="true"] .moon { display: none; }
.theme-toggle[aria-pressed="true"] .sun { display: inline-flex; }
.workspace { display: grid; grid-template-columns: 218px minmax(0, 1fr); min-height: calc(100vh - 59px); }
.sidebar { display: flex; flex-direction: column; justify-content: space-between; gap: 24px; background: var(--paper); border-right: 1px solid var(--line); padding: 30px 15px 20px; }
.sidebar nav { display: grid; gap: 4px; }
.module-link { display: flex; gap: 10px; align-items: center; width: 100%; padding: 12px; border: 0; border-radius: 6px; background: transparent; color: var(--ink); text-align: left; font-weight: 600; }
.module-link:hover, .module-link[aria-current] { background: #f1e8ef; color: #67435e; }
.module-link:focus-visible { outline: 2px solid var(--plum); outline-offset: 2px; }
.account-card { display: grid; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 7px; }
.account-summary { display: flex; align-items: center; gap: 9px; min-width: 0; margin-bottom: 4px; }
.account-summary strong, #account-role { display: block; overflow-wrap: anywhere; }
#account-role { color: var(--muted); font-size: 11px; margin-top: 3px; }
.account-avatar { display: grid; place-items: center; width: 33px; height: 33px; flex: none; background: #f1e8ef; color: #67435e; border-radius: 7px; font-size: 11px; font-weight: 700; }
.account-card .button { min-height: 34px; }
.sign-in { min-height: calc(100vh - 59px); display: grid; place-items: start center; padding: clamp(34px, 12vh, 110px) 16px 36px; }
.sign-in-card { width: min(100%, 415px); background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: clamp(20px, 5vw, 30px); }
.sign-in-card h1 { font-size: 28px; }
.sign-in-card p, .access-content p { color: var(--muted); line-height: 1.5; }
.sign-in-card h1 + p { margin: 9px 0 19px; }
.sign-in-card form { display: grid; gap: 12px; }
.sign-in-card label { font-size: 12px; font-weight: 600; }
.sign-in-card input { display: block; width: 100%; min-height: 39px; margin-top: 6px; border-radius: 5px; border: 1px solid var(--line); background: var(--paper); padding: 8px 10px; color: var(--ink); }
.sign-in-card .button[type="submit"] { margin-top: 5px; }
.sign-in-card .form-error, .access-content .form-error { color: var(--red); margin-top: 10px; }
.issued-actions { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px; margin-top: 8px; color: var(--muted); font-size: 12px; }
#code-value { font-family: ui-monospace, monospace; }
#copy-status:empty { display: none; }
main { padding: 28px clamp(20px, 3.5vw, 52px) 45px; width: 100%; max-width: 1570px; }
.crumb { color: var(--muted); display: flex; align-items: center; gap: 7px; font-size: 12px; }
.crumb span:last-child { color: var(--plum-dark); font-weight: 600; }
.crumb svg, th svg { width: 12px; height: 12px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin: 16px 0 27px; }
h1, h2, p { margin: 0; }
h1 { font-size: 34px; line-height: 1.17; letter-spacing: -.045em; }
#dashboard-greeting { overflow-wrap: anywhere; }
.page-head p { margin-top: 8px; color: var(--muted); line-height: 1.5; }
.actions { display: flex; gap: 9px; flex-wrap: wrap; }
.button { min-height: 39px; padding: 0 13px; border-radius: 5px; border: 1px solid transparent; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; font-weight: 600; font-size: 13px; }
.primary { background: var(--plum); color: white; }
.primary:hover { background: var(--plum-dark); }
.secondary { background: white; color: #4c3d4b; border-color: #ded8e0; }
.secondary:hover { background: #f7f3f7; }
.button:disabled { cursor: default; opacity: .6; }
.metrics { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 15px; margin-bottom: 25px; }
.metric { padding: 19px 17px; display: flex; gap: 13px; align-items: center; min-width: 0; border: 1px solid var(--line); border-radius: 8px; background: white; }
.metric.balance { background: #f4edf3; border-color: #e7d9e5; }
.metric-icon { display: grid; place-items: center; width: 39px; height: 39px; border-radius: 8px; flex: none; }
.balance .metric-icon { color: var(--plum-dark); background: #e8d9e6; }
.inflow .metric-icon { color: var(--green); background: #e6f3ed; }
.outflow .metric-icon { color: var(--red); background: #faecec; }
.metric-label { font-size: 12px; color: #61596a; font-weight: 600; }
.metric strong { display: block; font-size: clamp(17px, 2vw, 25px); margin-top: 5px; letter-spacing: -.04em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.ledger { background: white; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.ledger-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 17px; }
h2 { font-size: 16px; letter-spacing: -.015em; }
.search { width: 246px; max-width: 100%; display: flex; align-items: center; gap: 8px; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 0 10px; }
.search:focus-within { border-color: var(--plum); }
.search input { outline: none; border: 0; height: 34px; width: 100%; min-width: 0; background: transparent; color: var(--ink); font-size: 12px; }
.search input:focus-visible { outline: none; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; font-size: 13px; }
th, td { padding: 0 15px; text-align: left; }
th:first-child, td:first-child { padding-left: 18px; }
th { height: 38px; background: #f8f6f9; color: #61596a; font-weight: 600; font-size: 11px; white-space: nowrap; border-block: 1px solid #eeeaf0; }
th small { margin-left: 3px; font-size: 9px; color: #696173; font-weight: 500; }
td { height: 61px; border-bottom: 1px solid #eeeaf0; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fcfafc; }
.date, .category { color: #5f5868; }
.date { white-space: nowrap; }
.transaction-title { display: block; font-weight: 600; margin-bottom: 4px; overflow-wrap: anywhere; }
.reference { font-size: 11px; color: var(--muted); }
.pill { padding: 4px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.pill.deposit { background: #e8f5ee; }
.pill.expense { background: #fbeeee; }
.deposit { color: var(--green); }
.expense { color: var(--red); }
.amount { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 600; }
.row-end { width: 44px; padding-inline: 3px 12px; }
.icon-button { color: var(--muted); background: transparent; border: 0; border-radius: 5px; display: inline-grid; place-items: center; width: 31px; height: 31px; }
.icon-button:hover { background: #f2edf2; color: var(--plum); }
.empty { text-align: center; color: var(--muted); height: 110px; }
.ledger-footer { display: flex; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); padding: 13px 17px; color: var(--muted); font-size: 11px; }
dialog { padding: 0; width: min(530px, calc(100% - 24px)); max-height: calc(100dvh - 24px); border: 1px solid var(--line); border-radius: 10px; color: var(--ink); box-shadow: 0 18px 60px #22122433; }
dialog::backdrop { background: #241b2b72; }
.dialog-head, .dialog-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 18px; }
.dialog-head { border-bottom: 1px solid var(--line); }
.dialog-head h2 { font-size: 18px; }
.dialog-foot { justify-content: flex-end; border-top: 1px solid var(--line); background: #faf8fb; }
.dialog-content { display: grid; gap: 14px; padding: 18px; }
.dialog-content label { font-weight: 600; font-size: 12px; min-width: 0; display: block; }
.dialog-content input, .dialog-content select, textarea { height: 38px; margin-top: 6px; padding: 8px 10px; background: white; border: 1px solid #dad4de; border-radius: 5px; color: var(--ink); width: 100%; font-weight: 400; font-size: 13px; }
textarea { height: auto; resize: vertical; }
.optional { font-size: 10px; color: var(--muted); font-weight: 400; margin-left: 4px; }
.required, #entry-error { color: var(--red); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.money-field { position: relative; }
.money-field span { position: absolute; left: 11px; top: 18px; color: var(--muted); }
.money-field input { padding-left: 34px; }
.proof-drop { position: relative; display: grid; place-items: center; margin-top: 6px; min-height: 70px; border: 1px dashed var(--plum); border-radius: 6px; color: var(--plum-dark); padding: 10px; font-size: 13px; }
.proof-drop:hover, .proof-drop:focus-within, .proof-drop.dragging { background: color-mix(in srgb, var(--plum) 10%, transparent); }
.proof-drop:focus-within { outline: 2px solid var(--plum); outline-offset: 2px; }
.proof-drop svg { margin-right: 6px; }
.proof-drop input[type="file"] { position: absolute; inset: 0; opacity: 0; margin: 0; width: 100%; height: 100%; cursor: pointer; }
#proof-hint { margin-top: 6px; color: var(--muted); font-size: 11px; }
.proof-selected { display: flex; justify-content: space-between; align-items: center; gap: 9px; margin-top: 7px; font-size: 12px; overflow-wrap: anywhere; }
.proof-selected .button { min-height: 28px; }
.proof-download { color: var(--plum-dark); font-weight: 600; }
.proof-attachment { display: grid; justify-items: start; gap: 4px; padding-block: 4px; overflow-wrap: anywhere; }
.proof-thumb { display: block; background: var(--raised); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 4px; }
.proof-thumb img { display: block; width: 112px; height: 76px; object-fit: contain; }
.attachment-preview:not(:empty) { margin-top: 8px; }
.attachment-preview[data-staff-preview] img { width: min(210px, 100%); height: 124px; }
.proof-viewer { width: min(1120px, calc(100vw - 24px)); }
.proof-viewer img { display: block; margin-inline: auto; max-width: 100%; max-height: 75vh; object-fit: contain; }
.proof-viewer .dialog-head h2 { overflow-wrap: anywhere; }
#database-table td { overflow-wrap: anywhere; }
@media (hover: none) { .drop-instruction { display: none; } }
#details h3 { font-size: 20px; margin: 0; overflow-wrap: anywhere; }
#details dl { margin: 0; display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 11px 21px; }
#details dt { color: var(--muted); }
#details dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.toast { position: fixed; right: 20px; bottom: 20px; background: #294b40; color: white; padding: 12px 16px; border-radius: 6px; box-shadow: 0 4px 15px #20202022; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.crm-filters { display: flex; flex-wrap: wrap; gap: 4px; }
.crm-filters .button { min-height: 34px; background: transparent; color: var(--muted); }
.crm-filters .button:hover, .crm-filters .button[aria-pressed="true"] { background: var(--line); color: var(--ink); }
.crm-toolbar .search { flex-shrink: 0; }
#crm-table td { overflow-wrap: anywhere; }
#crm-view .ledger-footer { align-items: center; }
.crm-dialog { width: min(730px, calc(100% - 24px)); }
.crm-client-pick, .crm-items-head, .crm-total { display: flex; align-items: end; justify-content: space-between; gap: 10px; }
.crm-client-pick label { flex: 1; }
.crm-items-head h3, .crm-dialog h3, #crm-profile h3 { margin: 0; font-size: 14px; }
.crm-items-head { align-items: center; }
.crm-order-line { display: grid; grid-template-columns: 2fr 1fr .8fr .8fr 1.2fr auto; align-items: end; gap: 7px; padding: 8px 0; border-top: 1px solid var(--line); }
.crm-remove-line { margin-bottom: 3px; }
.crm-remove-line:disabled { visibility: hidden; }
.crm-total { padding-top: 11px; border-top: 1px solid var(--line); }
.crm-payment { padding: 10px; border: 1px solid var(--line); border-radius: 6px; }
.dialog-content .crm-payment-toggle { display: flex; align-items: center; gap: 8px; min-height: 26px; cursor: pointer; }
.dialog-content .crm-payment-toggle input { width: 17px; height: 17px; margin: 0; accent-color: var(--plum); }
#crm-payment-terms { margin-top: 9px; }
#crm-payment-terms p { grid-column: 1 / -1; margin: 0; }
.crm-summary { display: block; margin-top: 4px; color: var(--muted); overflow-wrap: anywhere; white-space: pre-wrap; }
.crm-fulfillment-line { display: grid; grid-template-columns: minmax(0, 1fr) 110px; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.crm-contact { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 12px; margin: 0; }
.crm-contact dt { color: var(--muted); }
.crm-contact dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.crm-dialog .form-error, #crm-client-form .form-error, #crm-sku-form .form-error { color: var(--red); }
.pill.crm-pending, .pill.crm-progress { background: var(--line); color: var(--ink); }
.pill.crm-progress { color: var(--plum-dark); }
.crm-clickable { cursor: pointer; }
.crm-clickable:focus-within { background: color-mix(in srgb, var(--plum) 10%, var(--paper)); }
.crm-filter-panel { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; padding: 12px 17px; border-top: 1px solid var(--line); }
.crm-filter-panel label { min-width: 105px; flex: 1 1 105px; font-size: 11px; font-weight: 600; }
.crm-filter-panel input, .crm-filter-panel select { display: block; margin-top: 5px; width: 100%; min-height: 39px; padding: 6px; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 5px; }
#crm-insights { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; padding: 24px; border-top: 1px solid var(--line); }
.metric-caption { color: var(--muted); font-size: 11px; margin-top: 5px; }
.insight-metrics { grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); }
.insight-chart .ledger-bar { border-bottom: 1px solid var(--line); }
.monthly-bars { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; padding: 16px; }
.chart-column { display: grid; gap: 5px; text-align: center; min-width: 0; }
.chart-value { font-size: 11px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.chart-track { display: flex; align-items: end; justify-content: center; height: 135px; border-bottom: 1px solid var(--line); }
.chart-bar { width: min(42px, 80%); background: var(--plum); border-radius: 4px 4px 0 0; }
.client-overview { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 8px; }
.client-overview .metric { padding: 11px; }
.client-overview .metric strong { font-size: 16px; }
.client-monthly .ledger-bar { border-bottom: 1px solid var(--line); }
.client-monthly .chart-track { height: 82px; }
.client-history { display: grid; gap: 6px; }
.client-order { display: grid; grid-template-columns: minmax(65px, 1fr) minmax(84px, 1fr) auto minmax(95px, 1fr) auto; justify-items: start; text-align: left; padding-block: 8px; }
.client-order strong:nth-of-type(2) { justify-self: end; }

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f1eaf2;
  --muted: #bfb3c5;
  --line: #403745;
  --paper: #242029;
  --plum: #bf92b4;
  --plum-dark: #e0b3d5;
  --green: #8fdbba;
  --red: #ffabab;
  background: #1b171e;
}
[data-theme="dark"] .topbar { background: #52364b; }
[data-theme="dark"] .date,
[data-theme="dark"] .category,
[data-theme="dark"] .metric-label,
[data-theme="dark"] th,
[data-theme="dark"] th small { color: var(--muted); }
[data-theme="dark"] .icon-button:hover { background: #39303e; }
[data-theme="dark"] .module-link:hover,
[data-theme="dark"] .module-link[aria-current],
[data-theme="dark"] .account-avatar { background: #442f42; color: var(--plum-dark); }
[data-theme="dark"] th,
[data-theme="dark"] .dialog-foot { background: #2d2632; }
[data-theme="dark"] .primary { color: #211620; }
[data-theme="dark"] .secondary,
[data-theme="dark"] .metric,
[data-theme="dark"] .ledger,
[data-theme="dark"] dialog,
[data-theme="dark"] .dialog-content input,
[data-theme="dark"] .dialog-content select,
[data-theme="dark"] textarea { background: var(--paper); border-color: var(--line); }
[data-theme="dark"] .secondary { color: var(--ink); }
[data-theme="dark"] .secondary:hover { background: #39303e; }
[data-theme="dark"] .metric.balance { background: #382a39; border-color: #584259; }
[data-theme="dark"] .balance .metric-icon { background: #563d54; }
[data-theme="dark"] .inflow .metric-icon,
[data-theme="dark"] .pill.deposit { background: #243e35; }
[data-theme="dark"] .outflow .metric-icon,
[data-theme="dark"] .pill.expense { background: #462d36; }
[data-theme="dark"] th,
[data-theme="dark"] td { border-color: var(--line); }
[data-theme="dark"] tbody tr:hover { background: #302836; }
[data-theme="dark"] dialog::backdrop { background: #0e0b11b3; }
[data-theme="dark"] .toast { background: #25473a; }

@media (max-width: 1020px) { .workspace { grid-template-columns: 170px minmax(0, 1fr); } .metric { padding: 13px; gap: 8px; } }
@media (max-width: 820px) {
  .workspace { display: block; }
  .sidebar { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px; padding: 8px 13px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar nav { display: flex; }
  .module-link { padding: 8px; font-size: 12px; }
  .account-card { display: flex; align-items: center; flex-wrap: wrap; padding: 5px; }
  .account-summary { margin-bottom: 0; margin-right: 4px; }
}
@media (max-width: 540px) {
  .monthly-bars { gap: 4px; padding: 12px 6px; }
  .client-order { grid-template-columns: 1fr auto auto; white-space: normal; }
  .client-order i { display: none; }
  .client-order strong:nth-of-type(2) { justify-self: start; }
  .crm-order-line { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .crm-order-line label:first-child { grid-column: span 3; }
  .crm-order-line label:nth-child(5) { grid-column: span 2; }
  .crm-client-pick { flex-wrap: wrap; }
  .sidebar nav { flex-wrap: wrap; }
  main.sign-in { padding: 34px 13px; }
  .topbar { padding: 0 14px; gap: 13px; }
  .theme-toggle { min-width: 38px; justify-content: center; padding: 0 8px; }
  .theme-toggle span { display: none; }
  main { padding: 19px 13px 28px; }
  .page-head, .ledger-bar { align-items: flex-start; flex-direction: column; }
  .page-head { margin-bottom: 16px; }
  h1 { font-size: 29px; }
  .metrics { gap: 6px; margin-bottom: 16px; }
  .metric { display: block; padding: 9px 7px; }
  .metric-icon { width: 25px; height: 25px; margin-bottom: 7px; }
  .metric-icon svg { width: 14px; height: 14px; }
  .metric-label { font-size: 10px; }
  .metric strong { font-size: 14px; }
}

/* Tailored ledger — Varisha. Design pass using unslop by Damir Sokolovsky
   (https://heydamir.design/unslop), CC BY 4.0. */
:root {
  --ink: #29252a; --muted: #605b63; --line: #dedbe0;
  --paper: #fffdf7; --canvas: #f7efde; --raised: #f7f6f3;
  --plum: #643b56; --plum-dark: #4a2a3e; --chart-neutral: #c7c3ca;
  --green: #25664e; --red: #a13c40;
  background: var(--canvas); color: var(--ink); line-height: 1.5;
}
:root[data-theme="dark"] {
  --ink: #eeece9; --muted: #aaa7a3; --line: #343435;
  --paper: #202021; --canvas: #181819; --raised: #2a2a2b;
  --plum: #c6a0b7; --plum-dark: #e0bfd2; --chart-neutral: #575054;
  --green: #97cfb4; --red: #e8a0a3;
  background: var(--canvas);
}
:root[data-theme="light"] .brand-text {
  color: var(--plum);
}

:root[data-theme="light"] :is(th, .module-link[aria-current]) {
  background: var(--raised);
}

:root[data-theme="light"] .crm-filters .button[aria-pressed="true"] {
  background: var(--raised);
  color: var(--plum-dark);
}
button, input, select, textarea { line-height: 1.4; }
button { transition: background-color 140ms ease-out, border-color 140ms ease-out, color 140ms ease-out; }
svg { width: 18px; height: 18px; stroke-width: 1.5; }
strong, b, h1, h2, h3 { font-weight: 500; }
.topbar, [data-theme="dark"] .topbar {
  height: 80px; padding: 0 32px; gap: 24px; background: var(--paper);
  color: var(--ink); border-bottom: 1px solid var(--line);
}
.brand { gap: 12px; font-weight: 500; }
.brand-text { font-family: Georgia, 'Times New Roman', serif; font-size: 32px; line-height: 1; letter-spacing: -.02em; }
.brand-text small { display: inline-block; font-family: Inter, system-ui, sans-serif; margin: 0 0 0 16px; padding-left: 16px; border-left: 1px solid var(--line); font-size: 12px; letter-spacing: 0; color: var(--muted); font-weight: 400; vertical-align: middle; }
.theme-toggle { height: 36px; min-height: 36px; padding: 0 12px; gap: 8px; border-color: var(--line); border-radius: 8px; color: var(--muted); font-weight: 400; }
.theme-toggle:hover, .theme-toggle[aria-pressed="true"] { background: var(--raised); }
.theme-toggle:focus-visible { outline-color: var(--plum); }
.workspace { grid-template-columns: 248px minmax(0, 1fr); min-height: calc(100dvh - 80px); }
.sidebar { padding: 32px 20px 24px; background: var(--canvas); gap: 32px; }
@media (min-width: 821px) {
  .sidebar {
    position: sticky;
    top: 0;
    align-self: start;
    height: calc(100dvh - 80px);
    overflow-y: auto;
  }
}
.sidebar nav { gap: 4px; }
.module-link { height: 36px; padding: 8px 12px; gap: 12px; border-radius: 8px; font-weight: 500; color: var(--muted); }
.module-link:hover, [data-theme="dark"] .module-link:hover { background: var(--raised); color: var(--ink); }
.module-link[aria-current], [data-theme="dark"] .module-link[aria-current] { background: var(--paper); color: var(--plum); box-shadow: inset 2px 0 var(--plum); }
.account-card { border: 0; border-top: 1px solid var(--line); border-radius: 0; padding: 20px 0 0; gap: 8px; }
.account-summary { gap: 12px; margin-bottom: 12px; }
.account-avatar, [data-theme="dark"] .account-avatar { width: 36px; height: 36px; border-radius: 8px; background: var(--raised); color: var(--muted); font-weight: 500; }
#account-role { font-size: 12px; margin-top: 4px; }
.account-card .button { min-height: 36px; }
main { padding: 32px clamp(24px, 3vw, 48px) 48px; max-width: 1600px; }
.crumb { gap: 8px; font-size: 12px; color: var(--muted); }
.crumb span:last-child { color: var(--muted); font-weight: 400; }
.page-head { margin: 16px 0 32px; gap: 24px; flex-wrap: wrap; }
h1 { font-size: 36px; line-height: 1.2; font-weight: 400; letter-spacing: -.025em; }
h2 { font-size: 16px; letter-spacing: 0; font-weight: 500; }
.page-head p { margin-top: 12px; color: var(--muted); }
.actions { gap: 8px; }
.button { min-height: 40px; padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 500; }
.primary { background: var(--plum); }
[data-theme="dark"] .primary { background: var(--ink); color: var(--canvas); }
[data-theme="dark"] .primary:hover { background: #d7d4d0; }
.secondary, [data-theme="dark"] .secondary { background: var(--paper); color: var(--ink); border-color: var(--line); }
.secondary:hover, [data-theme="dark"] .secondary:hover { background: var(--raised); }
.metrics { gap: 0; margin-bottom: 32px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.metric, .metric.balance, [data-theme="dark"] .metric, [data-theme="dark"] .metric.balance { background: var(--paper); border: 0; border-radius: 0; padding: 24px; gap: 12px; align-items: flex-start; }
.metrics > .metric + .metric { border-left: 1px solid var(--line); }
.metric-label, [data-theme="dark"] .metric-label { color: var(--muted); font-size: 12px; font-weight: 400; }
.metric strong { margin-top: 12px; font-size: clamp(22px, 2.1vw, 30px); line-height: 1.2; letter-spacing: -.025em; font-weight: 500; font-variant-numeric: tabular-nums; }
.metric-caption { color: var(--muted); font-size: 12px; line-height: 1.5; margin-top: 8px; }
.insight-metrics { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1.35fr) repeat(2, minmax(0, 1fr)); margin-bottom: 24px; }
.dashboard-notes { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.ledger, [data-theme="dark"] .ledger { background: var(--paper); border-color: var(--line); border-radius: 12px; }
.ledger-bar { padding: 20px 24px; gap: 16px; flex-wrap: wrap; }
.search { width: 240px; border-radius: 8px; padding: 0 12px; background: var(--paper); }
.search input { height: 36px; font-size: 13px; }
table { font-size: 13px; }
th, td { padding: 12px 16px; }
th:first-child, td:first-child { padding-left: 24px; }
th, [data-theme="dark"] th { height: 40px; padding-block: 8px; font-size: 12px; font-weight: 400; background: var(--canvas); color: var(--muted); border-color: var(--line); }
th small { font-size: 11px; color: var(--muted); }
td { height: 64px; border-color: var(--line); }
tbody tr:hover, [data-theme="dark"] tbody tr:hover { background: var(--canvas); }
.date, .category { color: var(--muted); }
.transaction-title { font-weight: 500; }
.reference { font-size: 12px; }
.amount { font-weight: 500; }
.pill { border-radius: 4px; padding: 4px 8px; font-size: 12px; font-weight: 400; }
.pill.crm-pending, .pill.crm-progress { background: var(--raised); color: var(--muted); }
.pill.crm-progress { color: var(--plum); }
.crm-status-select { max-width: 100%; border: 1px solid var(--line); font-family: inherit; cursor: pointer; }
.crm-status-select:hover { border-color: var(--muted); }
.icon-button { width: 36px; height: 36px; border-radius: 8px; }
.icon-button:hover, [data-theme="dark"] .icon-button:hover { background: var(--raised); }
.ledger-footer { padding: 16px 24px; font-size: 12px; align-items: center; flex-wrap: wrap; }
.crm-toolbar { gap: 16px; }
.crm-filters { gap: 4px; }
.crm-filters .button { min-height: 36px; padding: 8px 12px; }
.crm-filters .button:hover, .crm-filters .button[aria-pressed="true"] { background: var(--raised); }
#crm-table { min-width: 920px; }
#crm-table td { overflow-wrap: normal; }
#crm-table td:first-child { white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 500; }
#crm-table td:not(:nth-child(2)) { white-space: nowrap; }
#crm-table td:nth-child(2) { min-width: 180px; max-width: 320px; overflow-wrap: break-word; }
#crm-table th:nth-last-child(2), #crm-table td:nth-last-child(2), #crm-table[data-view="orders"] th:nth-last-child(3), #crm-table[data-view="orders"] td:nth-last-child(3) { text-align: right; font-variant-numeric: tabular-nums; }
#crm-table[data-view="clients"] { min-width: 720px; }
#crm-table[data-view="clients"] td:first-child, #crm-table[data-view="clients"] td:nth-child(3) { white-space: normal; overflow-wrap: anywhere; }
.crm-filter-panel { gap: 12px; padding: 20px 24px; background: var(--canvas); }
.crm-filter-panel label { font-size: 12px; font-weight: 500; }
.crm-filter-panel input, .crm-filter-panel select { min-height: 40px; margin-top: 8px; padding: 8px; border-radius: 8px; }
#crm-insights .metric {
  display: grid;
  grid-template-rows: subgrid;
  grid-row: span 2;
  row-gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
#crm-insights .metric > div { display: contents; }
#crm-insights .metric-label { line-height: 1.4; }
#crm-insights .metric strong {
  margin: 0;
  font-size: clamp(18px, 2vw, 24px);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0;
  font-variant-numeric: lining-nums tabular-nums;
}
@media (max-width: 1050px) {
  #crm-insights { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 540px) {
  #crm-insights { gap: 8px; padding: 12px; }
  #crm-insights .metric { padding: 12px; }
}
.insight-chart .ledger-bar { min-height: 64px; }
.monthly-bars { gap: 16px; padding: 32px 24px 24px; }
.chart-column { gap: 12px; }
.chart-value { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart-track { height: 240px; border-color: var(--line); background: repeating-linear-gradient(to top, transparent 0, transparent calc(25% - 1px), var(--line) calc(25% - 1px), var(--line) 25%); }
.chart-bar { width: min(64px, 70%); background: var(--chart-neutral); border-radius: 4px 4px 0 0; }
.current-period .chart-bar { background: var(--plum); }
.current-period .chart-value { color: var(--ink); font-weight: 500; }
.chart-column .metric-caption { margin-top: 0; }
#dash-chart { position: relative; grid-template-rows: auto clamp(152px, 20vh, 216px) auto; gap: 8px 16px; padding: 24px; }
#dash-chart:has(.chart-column)::before {
  content: "";
  position: absolute;
  inset: 0;
  grid-area: 2 / 1 / 3 / -1;
  border-block: 1px solid var(--line);
  background: repeating-linear-gradient(to top, transparent 0, transparent calc(25% - 1px), var(--line) calc(25% - 1px), var(--line) 25%);
}
#dash-chart .chart-column { grid-row: 1 / 4; grid-template-rows: subgrid; position: relative; align-items: end; }
#dash-chart .chart-track { height: 100%; background: none; border: 0; }
.client-monthly .chart-track { height: 120px; }
.client-overview .metric { padding: 16px; border: 1px solid var(--line); border-radius: 8px; }
.client-overview .metric strong { font-size: 20px; }
.client-order { gap: 12px; padding: 12px; white-space: normal; }
dialog { background: var(--paper); border-radius: 16px; box-shadow: 0 16px 48px #00000026; }
dialog::backdrop, [data-theme="dark"] dialog::backdrop { background: #11111180; }
.dialog-head, .dialog-foot { padding: 20px 24px; gap: 12px; }
.dialog-foot, [data-theme="dark"] .dialog-foot { background: var(--canvas); }
.dialog-content { padding: 24px; gap: 20px; }
.dialog-content label { font-size: 12px; font-weight: 500; }
.dialog-content input, .dialog-content select, textarea, .sign-in-card input { height: 40px; margin-top: 8px; padding: 8px 12px; border-color: var(--line); border-radius: 8px; background: var(--paper); }
textarea { height: auto; min-height: 88px; }
.optional, #proof-hint { font-size: 12px; }
.proof-drop { min-height: 88px; margin-top: 8px; padding: 16px; border-color: var(--line); border-radius: 8px; color: var(--muted); }
.proof-selected { gap: 8px; margin-top: 8px; }
.money-field span { left: 12px; top: 20px; }
.money-field input { padding-left: 36px; }
.crm-order-line { gap: 8px; padding: 12px 0; }
.crm-payment { padding: 16px; border-radius: 8px; }
.crm-total { padding-top: 16px; }
.crm-client-pick, .crm-items-head, .crm-total { gap: 12px; }
#details dl { gap: 12px 24px; }
.sign-in { min-height: calc(100dvh - 80px); padding: 80px 24px; max-width: none; }
.sign-in-card { width: min(100%, 440px); padding: 32px; border-radius: 16px; border-top: 3px solid var(--plum); }
.sign-in-card h1 { font-size: 32px; }
.sign-in-card h1 + p { margin: 12px 0 24px; }
.sign-in-card form { gap: 20px; }
.sign-in-card label { font-weight: 500; }
.sign-in-card .button[type="submit"] { margin-top: 4px; }
@media (max-width: 1200px) {
  .insight-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .insight-metrics > .metric:nth-child(3) { border-left: 0; }
  .insight-metrics > .metric:nth-child(n+3) { border-top: 1px solid var(--line); }
}
@media (max-width: 820px) {
  .workspace { display: block; }
  .topbar { padding: 0 24px; height: 72px; }
  .sidebar { padding: 16px 24px; gap: 16px; background: var(--paper); }
  .sidebar nav { min-width: 0; flex-wrap: wrap; }
  .account-card { border: 0; padding: 0; gap: 8px; }
  .account-summary { margin: 0 8px 0 0; }
  .module-link { height: 40px; }
  main { padding: 24px 24px 40px; }
}
@media (max-width: 540px) {
  .topbar { padding: 0 16px; gap: 16px; }
  .brand-text { font-size: 28px; }
  .brand-text small { margin-left: 12px; padding-left: 12px; }
  .sidebar { padding: 12px 16px; }
  .sidebar nav { width: 100%; gap: 4px; flex-wrap: nowrap; }
  .module-link { justify-content: center; padding: 8px; gap: 8px; font-size: 12px; }
  .account-card { width: 100%; padding-top: 12px; border-top: 1px solid var(--line); }
  .account-summary { margin-right: auto; }
  .account-card .button { padding: 8px; font-size: 12px; }
  .account-avatar { display: none; }
  main { padding: 24px 16px 32px; }
  h1 { font-size: 28px; }
  .page-head { gap: 20px; margin: 12px 0 24px; }
  .page-head p { font-size: 13px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 24px; gap: 0; }
  .metric, .metric.balance, [data-theme="dark"] .metric, [data-theme="dark"] .metric.balance { padding: 16px; }
  .metrics > .metric:nth-child(3) { border-left: 0; border-top: 1px solid var(--line); }
  #petty-cash-view .metrics > .metric:first-child { grid-column: 1 / -1; }
  #petty-cash-view .metrics > .metric:nth-child(2) { border-left: 0; border-top: 1px solid var(--line); }
  #petty-cash-view .metrics > .metric:nth-child(3) { border-left: 1px solid var(--line); }
  .metric strong { font-size: 22px; margin-top: 8px; }
  .metric-label, .metric-caption { font-size: 12px; }
  .ledger-bar { padding: 16px; gap: 16px; }
  .ledger-bar > .search, .crm-toolbar > .actions, .crm-toolbar .search { width: 100%; }
  .crm-toolbar .search { flex: 1; min-width: 0; }
  .crm-filters { width: 100%; }
  .crm-filters .button { padding-inline: 8px; font-size: 12px; }
  .ledger-footer { padding: 16px; }
  .monthly-bars { gap: 4px; padding: 20px 8px 16px; }
  #dash-chart { gap: 8px 4px; padding: 16px 8px; }
  .chart-value { font-size: 11px; overflow-wrap: anywhere; }
  .chart-column .metric-caption { font-size: 11px; }
  .chart-track { height: 180px; }
  .chart-column { gap: 8px; }
  .dialog-content, .dialog-head, .dialog-foot { padding: 20px; }
  .crm-order-line { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sign-in, main.sign-in { padding: 40px 16px; }
  .sign-in-card { padding: 24px; }
}
@media (prefers-reduced-motion: reduce) { button { transition: none; } }
.account-summary { border: 0; background: transparent; color: var(--ink); text-align: left; padding: 8px; border-radius: 8px; }
.account-summary:hover { background: var(--raised); }
.account-meta { flex: 1; min-width: 0; }
.account-summary > i { color: var(--muted); }
.warehouse-toolbar { justify-content: flex-start; align-items: end; }
.warehouse-toolbar label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.warehouse-toolbar select, .warehouse-toolbar input { min-height: 40px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); max-width: 100%; }
.container-line { display: grid; grid-template-columns: minmax(100px, 2fr) repeat(3, minmax(0, 1fr)) auto; gap: 8px; align-items: end; border-top: 1px solid var(--line); padding: 8px 0; }
#container-dialog { width: min(960px, calc(100% - 24px)); }
.container-entry { display: grid; grid-template-columns: 1.5fr minmax(130px, 1fr) .7fr 1fr 1.4fr auto; gap: 8px; align-items: end; border-top: 1px solid var(--line); padding: 8px 0; }
.container-entry input { min-width: 0; width: 100%; }
.container-totals { display: flex; flex-wrap: wrap; gap: 8px 24px; margin: 0; padding: 10px 0; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.container-totals dt { font-size: 13px; color: var(--muted); }
.container-totals dd { margin: 2px 0 0; font-weight: 600; }
#container-shipment { border-top: 1px solid var(--line); padding-top: 8px; }
#container-shipment summary { cursor: pointer; font-weight: 600; }
#container-shipment > :not(summary) { margin-top: 10px; }
#container-dialog .dialog-foot { flex-wrap: wrap; }
@media (max-width: 720px) {
  .container-entry { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .container-entry button { justify-self: end; }
}
#profile-error, #movement-form .form-error, #warehouse-form .form-error, #report-error { color: var(--red); }
#inventory-table :is(th, td) { font-size: 13px; line-height: 1.4; }
#inventory-table .inventory-group th { height: 36px; font-weight: 600; color: var(--ink); }
#inventory-table .inventory-quantity { text-align: right; font-weight: 500; font-variant-numeric: lining-nums tabular-nums; white-space: nowrap; }
.date-sort { background: transparent; color: inherit; border: 0; font: inherit; padding: 4px 0; }
.date-sort:hover { color: var(--ink); }
.topbar .language-toggle { margin-left: 0; }
#crm-payment-summary { border-top: 1px solid var(--line); }
.payment-totals { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; }
.payment-totals button { margin-left: auto; }
.payment-history { margin: 0; padding-inline-start: 20px; line-height: 1.6; overflow-wrap: anywhere; }
.crm-order-line { grid-template-columns: minmax(105px, 1.6fr) repeat(4,minmax(0,1fr)) minmax(90px,1.2fr) auto; }
@media (max-width: 600px) {
  .crm-order-line { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .crm-order-line label:first-child { grid-column: span 3; }
  .crm-order-line label:nth-child(5) { grid-column: auto; }
}
th[aria-sort="ascending"] .date-sort svg { transform: rotate(180deg); }
@media (max-width: 540px) {
  .sidebar nav { flex-wrap: wrap; }
  .sidebar .module-link { flex: 1 1 88px; width: auto; }
  .container-line { grid-template-columns: repeat(3, minmax(0, 1fr)) auto; }
  .container-line > label:first-child { grid-column: 1 / -1; }
}
/* Table readability and recovery */
.table-wrap { max-height: 65vh; scrollbar-gutter: stable; border-radius: 8px; }
.table-wrap:focus-visible { outline: 2px solid var(--plum); outline-offset: 3px; }
.table-wrap th { position: sticky; top: 0; z-index: 1; font-weight: 500; color: var(--ink); }
table { font-variant-numeric: tabular-nums; }
td { line-height: 1.5; }
.table-stack { display: grid; gap: 4px; }
.table-stack strong { font-weight: 500; }
[data-theme="dark"] .reference, [data-theme="dark"] .date, [data-theme="dark"] .category { color: #bdbab6; }
#crm-table { min-width: 680px; }
#crm-table :is(th, td) { padding: 12px 10px; }
#crm-table :is(th, td):first-child { padding-left: 16px; }
#crm-table td:nth-child(2) { min-width: 130px; max-width: 240px; }
#crm-table[data-view="orders"] :is(th, td):nth-last-child(3) { text-align: left; }
#crm-table .row-end { width: 42px; }
#crm-table[data-view="clients"] { min-width: 600px; }
#crm-table[data-view="clients"] :is(th, td):nth-last-child(2) { text-align: right; }
#crm-table th { white-space: normal; }
#crm-table td.empty { white-space: normal; }
.recovery-banner { padding: 16px 24px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; border-bottom: 1px solid var(--line); background: var(--paper); }
.recovery-banner p { flex: 1; min-width: 200px; line-height: 1.5; }
.log-content { padding: 24px; }
.log-content p { margin: 12px 0; color: var(--muted); line-height: 1.6; }
#error-log-dialog { width: min(700px, calc(100vw - 32px)); }
#error-log-list { max-height: 50vh; overflow: auto; padding: 0 0 0 24px; margin: 20px 0; }
#error-log-list li { padding: 10px 0; line-height: 1.6; border-bottom: 1px solid var(--line); font-size: 13px; }
#retry-account { margin-top: 16px; }
@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; gap: 8px; height: auto; padding-block: 12px; }
  .topbar .brand { flex-basis: 100%; }
  #crm-table :is(th, td) { padding: 10px 8px; }
  .table-wrap { max-height: 70vh; }
}

.topbar #open-error-log { margin-left: 0; }
.record-activity { margin: 16px 0; padding: 12px 16px; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; line-height: 1.6; color: var(--muted); }
.record-activity strong { color: var(--ink); font-weight: 500; }
.record-activity .activity-line { margin: 3px 0; }
.record-activity small { display: block; margin-top: 4px; }
.record-activity details { margin-top: 8px; }
.record-activity summary { cursor: pointer; color: var(--ink); }
.record-activity ol { margin: 10px 0; padding-left: 20px; max-height: 240px; overflow: auto; }
.record-activity li { padding: 5px 0; }
.activity-dialog { padding: 24px; width: min(620px, calc(100vw - 32px)); }
.activity-dialog > p { margin-top: 8px; overflow-wrap: anywhere; }
#profile-dialog > .record-activity { margin: 16px 24px; }
.record-filter-panel { display: flex; gap: 16px; flex-wrap: wrap; padding: 16px 24px; border-bottom: 1px solid var(--line); align-items: end; }
.date-selector { max-width: 620px; padding: 28px; }
.date-selector p { color: var(--muted); line-height: 1.6; margin: 12px 0 24px; }
.date-selector label { display: grid; gap: 8px; max-width: 260px; margin-bottom: 20px; }
#container-table select { min-width: 120px; }

/* Daily visits and finance share the existing ledger's restrained controls. */
.daily-tasks, .finance-panel { padding: 24px; }
.daily-toolbar, .section-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; margin-bottom: 24px; }
.daily-toolbar h2, .section-toolbar h2, .finance-note h2 { margin: 0 0 8px; font-size: 18px; }
.daily-toolbar p, .section-toolbar p, .finance-note p { margin: 0; color: var(--muted); line-height: 1.6; }
.daily-toolbar label, .section-toolbar label, .inline-date { display: grid; gap: 8px; font-size: 12px; font-weight: 500; color: var(--muted); }
.daily-toolbar input, .daily-toolbar select, .section-toolbar input, .section-toolbar select, .inline-date input { min-height: 40px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: var(--paper); max-width: 100%; }
.daily-toolbar:nth-child(2) { justify-content: flex-start; padding: 16px 0; margin-bottom: 8px; border-block: 1px solid var(--line); align-items: end; }
.daily-toolbar:nth-child(2) > button { margin-left: auto; }
.daily-progress { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin: 16px 0 24px; }
.daily-progress-card { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: 8px; font-variant-numeric: tabular-nums; }
.daily-progress-card span { color: var(--muted); font-size: 12px; }
.daily-progress-card progress { grid-column: 1 / -1; width: 100%; height: 6px; border: 0; border-radius: 4px; overflow: hidden; accent-color: var(--plum); }
.daily-progress-card progress::-webkit-progress-bar { background: var(--line); }
.daily-progress-card progress::-webkit-progress-value { background: var(--plum); }
#daily-message { color: var(--muted); line-height: 1.6; }
#daily-rows td { white-space: normal; min-width: 140px; max-width: 300px; overflow-wrap: anywhere; }
#daily-rows small, .cell-stack small { display: block; color: var(--muted); margin-top: 8px; line-height: 1.5; font-size: 12px; }
#daily-dialog { width: min(680px, calc(100% - 32px)); }
#daily-form .dialog-content, .form-columns { grid-template-columns: repeat(2,minmax(0,1fr)); }
#daily-form .photo-field, #daily-form .dialog-content > label:last-of-type, #daily-error, .full-width { grid-column: 1 / -1; }
#daily-form textarea, #finance-payroll-form textarea { height: auto; min-height: 88px; resize: vertical; }
.form-error { color: var(--red); }
.field-label { display: block; font-size: 12px; margin-bottom: 8px; }
#daily-drop { position: relative; display: flex; align-items: center; justify-content: center; gap: 16px; min-height: 136px; padding: 24px; border: 1px dashed var(--muted); border-radius: 8px; cursor: pointer; text-align: center; background: var(--paper); }
#daily-drop:hover, #daily-drop.dragging { border-color: var(--plum); background: color-mix(in srgb, var(--plum) 8%, var(--paper)); }
#daily-drop:focus-within { outline: 2px solid var(--plum); outline-offset: 3px; }
#daily-drop input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
#daily-drop img { width: 100px; height: 90px; object-fit: cover; border-radius: 6px; }
#daily-drop span { min-width: 0; }
#daily-drop strong { display: block; font-size: 14px; overflow-wrap: anywhere; }
#daily-drop small { display: block; margin-top: 8px; color: var(--muted); font-size: 12px; line-height: 1.6; }
#daily-photo-remove { margin-top: 12px; }
#daily-photo-error:empty, .panel-message:empty { display: none; }
.panel-message { margin: 0; padding: 16px 24px; color: var(--muted); line-height: 1.6; }
#finance-view > .ledger > .ledger-bar { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
#finance-refresh { margin-inline-start: auto; }
#finance-overview { container: finance-overview / inline-size; }
#finance-overview-title { margin: 0 0 16px; font-size: 18px; }
.finance-stats {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.finance-stats > .metric {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: clamp(12px, 3cqi, 24px);
}
.finance-stats .metric strong { margin: 0; font-size: clamp(18px, 3.4cqi, 26px); }
@container finance-overview (min-width: 18rem) {
  .finance-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container finance-overview (min-width: 38rem) {
  .finance-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.finance-note { margin: 16px 0 0; color: var(--muted); }
.commission-placeholder { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.commission-placeholder p { margin: 0; }
#potential-client-details { overflow-wrap: anywhere; }
#potential-client-details small { display: block; color: var(--muted); margin-bottom: 4px; }
#daily-rows td:first-child .button { white-space: normal; text-align: left; }
.daily-toolbar .crm-filters { align-self: end; }
.payroll-totals { margin-bottom: 20px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.payroll-preview { display: grid; gap: 8px; align-content: center; font-size: 12px; color: var(--muted); }
.payroll-preview strong { color: var(--ink); font-size: 22px; font-variant-numeric: tabular-nums; }
.finance-money { display: block; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
#finance-view th.amount { text-align: right; }
#finance-view td { vertical-align: top; white-space: normal; min-width: 110px; max-width: 320px; overflow-wrap: anywhere; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
#finance-view .row-actions { min-width: 160px; }
#finance-view .cell-stack strong { font-weight: 500; }
#finance-view .section-toolbar:has(#finance-search) { justify-content: flex-start; align-items: end; }
#finance-view .section-toolbar:has(#finance-search) label:last-child { flex: 1; }
@media (max-width: 600px) {
 .daily-tasks, .finance-panel { padding: 16px; }
 #daily-form .dialog-content, .form-columns { grid-template-columns: 1fr; }
 .daily-progress-card { grid-template-columns: 1fr; }
 .daily-toolbar > div { width: 100%; }
 .daily-toolbar:first-child > button { width: 100%; }
 .section-toolbar > label { width: 100%; }
 #finance-view .page-head { align-items: start; }
 .inline-date { min-width: 150px; }
}
.payroll-staff-card { justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; padding: 12px 16px; white-space: normal; text-align: left; }
.payroll-staff-card span { color: var(--muted); font-variant-numeric: tabular-nums; }

.payroll-table { min-width: 980px; }
#finance-view .payroll-table td { min-width: 0; padding-inline: 12px; }
#finance-view .payroll-table .payroll-actions { min-width: 225px; }
.payroll-buttons { display: flex; align-items: flex-start; gap: 8px; }
.payroll-buttons .button { min-height: 36px; padding-inline: 10px; }
.payroll-status { display: grid; justify-items: start; gap: 8px; }
.payroll-records-title { margin: 24px 0 12px; }
#finance-view .payroll-table tr[data-review="approved"] td { background: color-mix(in srgb, #308260 16%, var(--paper)); }
#finance-view .payroll-table tr[data-review="denied"] td { background: color-mix(in srgb, #a44347 16%, var(--paper)); }

.hrd-staff-row { cursor: pointer; }
.hrd-staff-name {
  appearance: none;
  border: 0;
  background: none;
  color: inherit;
  padding: 0;
  font: inherit;
  text-align: left;
}
.hrd-staff-name:focus-visible { outline: 2px solid var(--plum); outline-offset: 3px; }

.stock-movement-line {
  display: grid;
  grid-template-columns: minmax(155px, 2fr) minmax(86px, 1fr) minmax(70px, .7fr) minmax(78px, .75fr) auto;
  gap: 12px;
  align-items: end;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.movement-toolbar { margin-bottom: 0; }
.movement-toolbar h3, .pdf-picker-status { margin: 0; }
.pdf-picker-status { color: var(--muted); overflow-wrap: anywhere; }
.access-module-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; padding: 4px 0; }
.access-module-options label { display: flex; gap: 8px; align-items: center; min-height: 28px; }
.access-module-options input[type="checkbox"] { flex: none; width: 16px; height: 16px; margin: 0; padding: 0; accent-color: var(--plum); }
:root[data-access-role="observer"] :is([data-entry], #cash-edit-categories, #finance-edit-categories, [data-stock-view="warehouses"], #generate-report, #crm-add-order, #crm-add-sku,
  #crm-add-client, #daily-add, #add-container, #add-movement, #add-warehouse, #inventory-import-excel,
  #finance-add-entry, #finance-add-payroll, #finance-import-payroll, #finance-export-payroll, #hrd-add,
  #profile-form button[type="submit"], #crm-details-form button[type="submit"]) { display: none; }
.dialog-head-actions { flex: none; align-items: center; }
.pdf-picker-button { background: #202021; white-space: nowrap; }
.pdf-picker-button:hover { background: #383839; }
[data-theme="dark"] .pdf-picker-button { background: #fff; }
[data-theme="dark"] .pdf-picker-button:hover { background: #e5e5e5; }
@media (max-width: 630px) {
  .stock-movement-line { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stock-movement-line > label:first-child { grid-column: 1 / -1; }
}

.report-warehouse-picker { margin: 0; padding: 0; border: 0; min-inline-size: 0; }
.report-warehouse-picker legend { font-weight: 600; }
.report-warehouse-picker p { margin: 6px 0 12px; color: var(--muted); }
.report-warehouse-bubbles { display: flex; flex-wrap: wrap; gap: 8px; max-height: 35vh; overflow: auto; padding: 4px; }
.report-warehouse-bubbles .report-warehouse-bubble { min-height: 32px; padding: 4px 12px; white-space: normal; }
.report-warehouse-bubbles .report-warehouse-bubble[aria-pressed="true"] {
  border-color: var(--plum);
  box-shadow: inset 0 0 0 1px var(--plum);
  background: var(--raised);
}
#report-selection-status { margin: 0; }

.cash-delivery-fields { min-inline-size: 0; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 8px; }
.cash-delivery-fields legend { padding-inline: 4px; font-size: 12px; font-weight: 600; }
.cash-delivery-fields > :not(legend) + :not([hidden]) { margin-top: 12px; }
.cash-delivery-preview { display: grid; gap: 4px; margin: 0; overflow-wrap: anywhere; }
.cash-delivery-preview span { color: var(--muted); font-size: 12px; }
