.btn {
  display: inline-block;
  padding: 0.6rem 1.25rem;
  border: none;
  border-radius: var(--radius-full);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: var(--weight-semibold);
  cursor: pointer;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--color-accent);
  color: #ffffff;
}

/* tk_193: there was no disabled rule at all, so a disabled Charge button
   kept its full accent fill and invited a tap that did nothing. Opacity plus
   a flat surface reads as inert in both themes. */
.btn:disabled,
.btn[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.45;
  box-shadow: none;
}

.btn:disabled:hover,
.btn[aria-disabled="true"]:hover {
  background-color: inherit;
}

.btn-primary:disabled:hover {
  background-color: var(--color-accent);
}

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

.btn-secondary {
  background-color: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border-strong);
}

.btn-secondary:hover {
  background-color: var(--color-surface-muted);
}

.btn-sm {
  padding: 0.3rem 0.85rem;
  font-size: 0.85rem;
}

.inline-form {
  display: inline;
}

.form-group {
  margin-bottom: 1rem;
  text-align: left;
}

.form-group label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: var(--weight-medium);
  font-size: 0.9rem;
  color: var(--color-text);
}

/* tk_131: shared styling for native selects/date inputs, wherever a form
   mixes them with already-styled text inputs (modals, POS panels, PO/voucher
   forms). Matches the .form-group input pill above. */
.form-group input:not([type="checkbox"]):not([type="radio"]),
.form-group select,
.pos-customer select,
.pos-customer input[type="date"],
.pos-customer input[type="datetime-local"] {
  width: 100%;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-full);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  background-color: var(--color-surface);
  color: var(--color-text);
}

.form-group input:focus,
.form-group select:focus,
.pos-customer select:focus,
.pos-customer input[type="date"]:focus,
.pos-customer input[type="datetime-local"]:focus {
  outline: 2px solid var(--color-accent-subtle);
  border-color: var(--color-accent);
}

.data-table select,
.data-table input[type="number"] {
  width: 100%;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  background-color: var(--color-surface);
  color: var(--color-text);
}

.data-table select:focus,
.data-table input[type="number"]:focus {
  outline: 2px solid var(--color-accent-subtle);
  border-color: var(--color-accent);
}

/* Side-by-side field pairs (e.g. voucher Type + Date) instead of squeezing
   two label-above-control fields onto one visually cramped line. */
.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  align-items: flex-start;
}

/* tk_164: a flex-basis rather than a media query, so a pair stacks as soon
   as it stops fitting -- correct inside a narrow panel as well as at 320px,
   which a viewport breakpoint cannot see. */
.form-row > .pos-customer,
.form-row > .form-group {
  flex: 1 1 220px;
  min-width: 0;
}

.field-errors {
  margin: 0.35rem 0 0;
  padding: 0;
  list-style: none;
  color: var(--color-danger);
  font-size: 0.85rem;
}

.stat-card {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 1rem 1.25rem;
}

.stat-card-label {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
}

.stat-card-value {
  font-size: 1.6rem;
  font-weight: var(--weight-semibold);
}

.stat-card-sublabel {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* tk_149: contain an oversized table with its own horizontal scroll so it
   never pushes the whole page wide. Wraps every data_table() macro call. */
/* tk_149 gave the macro's tables a scroll container. tk_166 found the
   *searchable* variant never got one: .data-table-wrap left overflow-x
   visible, so at 320px a 611px Visits table was clipped by the shell's
   containment with no way to scroll to the hidden columns. Page-overflow
   checks cannot see this -- the page is fine, the data is just gone. */
.data-table-scroll,
.data-table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
}

/* tk_168: the header row read as just another row. Micro-caps on a tinted
   band separates the labels from the data without adding a heavy rule. */
.data-table th {
  color: var(--color-text-secondary);
  font-weight: var(--weight-semibold);
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background-color: var(--color-surface-subtle);
  border-bottom: 1px solid var(--color-border-strong);
}

.data-table th:first-child {
  border-top-left-radius: var(--radius-sm);
}

.data-table th:last-child {
  border-top-right-radius: var(--radius-sm);
}

/* Last row shouldn't draw a rule into the card's own padding. */
.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover td {
  background-color: var(--color-surface-subtle);
}

/* tk_070: shared filter bar */
.filter-bar {
  display: flex;
  align-items: end;
  gap: 0.75rem;
  padding: 0.5rem 0;
  /* tk_159: wrap fields to new rows instead of overflowing at narrow
     widths (used on every filtered page: statements, procurement, MIS). */
  flex-wrap: wrap;
}

.filter-bar-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.filter-bar-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.filter-bar select,
.filter-bar input {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm, 6px);
  background: var(--color-surface);
  color: inherit;
  font: inherit;
}

/* tk_069: data-table framework toolbar + pagination */
.data-table-toolbar,
.data-table-pagination {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
}

.data-table-toolbar {
  justify-content: space-between;
}

.data-table-search,
.data-table-page-size {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm, 6px);
  background: var(--color-surface, transparent);
  color: inherit;
  font: inherit;
}

.data-table-search {
  flex: 0 1 16rem;
}

.data-table-empty,
.data-table-page-label {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.data-table-empty {
  padding: 0.75rem 0;
}

/* tk_174: plain-English help. The `?` sits next to a label or button and
   explains, in everyday words, what the control does and what happens after
   it. Native title= carries the text, so hover and keyboard focus both work
   with no JS. */
.hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.05rem;
  height: 1.05rem;
  margin-left: 0.35rem;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-full);
  background-color: var(--color-surface-subtle);
  color: var(--color-text-muted);
  font-size: 0.68rem;
  font-weight: var(--weight-semibold);
  line-height: 1;
  cursor: help;
  vertical-align: middle;
  user-select: none;
}

.hint:hover,
.hint:focus-visible {
  border-color: var(--color-accent);
  background-color: var(--color-accent-subtle);
  color: var(--color-accent);
  outline: none;
}

/* tk_174: help text under a single field, for explanations too long to sit
   in a tooltip. */
.field-help {
  margin: -0.35rem 0 var(--space-4);
  max-width: 68ch;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  line-height: 1.45;
}

/* tk_174: the "what is this page for" line under a page title. */
.page-intro {
  margin: -0.35rem 0 var(--space-4);
  max-width: 68ch;
  color: var(--color-text-secondary);
  font-size: var(--text-base);
  line-height: 1.5;
}

/* tk_172: the Chart of Accounts' account-head lists.
   Owned by the CoA on purpose. tk_134 styled these via `.report-catalog`, a
   rule shared with the MIS catalog; tk_157 redesigned that catalog, deleted
   the rule, and the CoA silently fell back to default browser bullets. A
   page's list styling should not be one unrelated redesign away from
   breaking. */
.coa-account-list {
  list-style: none;
  margin: 0 0 var(--space-4) var(--space-4);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.coa-account-list li {
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
  color: var(--color-text);
}

/* tk_173: the Edit affordance stays quiet until the row is hovered, so the
   chart still reads as a reference tree rather than a wall of links. */
.coa-sub-heading {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.coa-edit-link {
  color: var(--color-accent);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: var(--weight-medium);
  opacity: 0;
  transition: opacity 0.12s ease-in-out;
}

.coa-account-list li:hover .coa-edit-link,
.coa-sub-heading:hover .coa-edit-link,
.coa-edit-link:focus-visible {
  opacity: 1;
}

.coa-edit-link:hover {
  text-decoration: underline;
}

/* Native <dialog> modal (moved from portal.css; shared app-wide for the
   portal and Business modals). */
.modal {
  width: min(520px, 90vw);
  padding: 0;
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--color-border);
}

.modal-title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}

.modal-close {
  background: none;
  border: none;
  padding: 0 var(--space-1);
  font-size: 22px;
  line-height: 1;
  color: var(--color-text-muted);
  cursor: pointer;
}

.modal-close:hover {
  color: var(--color-text);
}

.modal-body {
  padding: var(--space-6);
}

/* tk_134/tk_133: shared token-styled list rows for the CoA account-head
   lists and the MIS catalog (replaces default browser bullets). */
/* tk_157: MIS catalog — grouped list cards. */
.report-search {
  display: flex;
  gap: var(--space-2);
  max-width: 420px;
  margin-bottom: var(--space-6);
}

.report-search input {
  flex: 1;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-full);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  font-size: 0.9rem;
}

.report-group-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0 0 var(--space-3);
  padding: 0 2px;
}

.report-group-name {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.report-group-count {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  background: var(--color-surface-subtle);
  border-radius: var(--radius-full);
  padding: 1px 8px;
}

.report-rows {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.report-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 0.9rem 1rem;
  text-decoration: none;
  color: inherit;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.report-row:hover {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-sm);
}

.report-ico {
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--color-accent-subtle);
  color: var(--color-accent);
}

.report-ico svg {
  width: 19px;
  height: 19px;
}

.report-row-body {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.report-row-title {
  font-weight: var(--weight-semibold);
  font-size: 0.92rem;
}

.report-row-desc {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  margin-top: 2px;
}

.report-row-meta {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  text-align: right;
}

.report-chev {
  color: var(--color-text-muted);
  flex: none;
  display: flex;
}

.report-chev svg {
  width: 16px;
  height: 16px;
}

@media (max-width: 560px) {
  .report-row-meta { display: none; }
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-4);
  margin-top: var(--space-6);
}

/* tk_207: Django messages. The app collected them from day one and rendered
   none of them, so every confirmation and every refusal was swallowed. */
.flash-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.flash {
  padding: 0.7rem 1rem;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-base);
}

/* A refusal that looks like a confirmation is worse than no message at all,
   so the two are told apart by fill as well as by wording. */
.flash-success {
  border-color: var(--color-accent);
  background: var(--color-accent-subtle);
}

.flash-error {
  border-color: var(--color-danger);
  background: var(--color-surface);
  color: var(--color-danger);
}

/* ---------------------------------------------------------------------------
 * Browser surfaces
 *
 * The parts of the UI the app never draws -- the focus ring, the caret, the
 * text selection, the scrollbars -- were shipping as browser defaults, which
 * belong to no palette and go bright blue on a warm-paper page. Themed here so
 * they read as part of SaloonSoft in both light and dark.
 * ------------------------------------------------------------------------ */

/* One visible keyboard ring for everything focusable. --color-accent-subtle is
   a background tint, far too faint to ring with, so this uses the accent
   itself with an offset so the ring never sits on the control's own edge. */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Pointer focus on a mouse-driven control should not leave a ring behind. */
:focus:not(:focus-visible) {
  outline: none;
}

::selection {
  background: var(--color-accent-soft);
  color: var(--color-text);
}

:root {
  accent-color: var(--color-accent);
  caret-color: var(--color-accent);
  scrollbar-color: var(--color-border-strong) transparent;
  scrollbar-width: thin;
}

/* WebKit does not read scrollbar-color; the long horizontal scrollers on the
   wide report tables are where this shows most. */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: var(--radius-full);
  background-clip: content-box;
  background-color: var(--color-border-strong);
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--color-text-muted);
}
