/* Design system. Colours come from the logo (legal red and black); every text pairing below
   meets WCAG AA (tests/test_design.py checks them). Change the brand only through :root. */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/InterVariable.woff2") format("woff2");
}

/* Headings and large figures only, to match the marketing site. */
@font-face {
  font-family: "Poppins";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/Poppins-SemiBold-latin.woff2") format("woff2");
}

:root {
  --brand: #9e0b0f; /* logo red: 8.4:1 on white */
  --brand-hover: #7f090c;
  --brand-tint: #faf4f4; /* marketing site footer tint */
  --brand-tint-strong: #f3e3e3;
  --brand-on-dark: #e05a5e; /* active marker in the dark sidebar: 5.1:1 */

  --sidebar: #141414; /* logo black */
  --sidebar-hover: #231f1e;
  --sidebar-active: #2a2422;
  --sidebar-text: #f5f5f4;
  --sidebar-muted: #a8a29e; /* 7.3:1 on the sidebar */

  --ink: #141414;
  --muted: #57534e; /* 7.1:1 on the page background */
  --subtle: #6b645e; /* 5.8:1 on white; small print only */
  --bg: #f7f6f5;
  --surface: #ffffff;
  --surface-alt: #fafaf9;
  --border: #e7e5e4;
  --input-border: #8a817a; /* 3.8:1: form fields must stand out */

  --success: #047857;
  --success-text: #065f46;
  --success-tint: #ecfdf5;
  --warning: #b45309;
  --warning-text: #92400e;
  --warning-tint: #fef3c7;
  --danger: #b91c1c;
  --danger-text: #991b1b;
  --danger-tint: #fef2f2;

  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Poppins", var(--font-sans);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgb(20 20 20 / 6%), 0 1px 3px rgb(20 20 20 / 10%);
  --shadow-lg: 0 10px 24px rgb(20 20 20 / 12%);

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 1rem;
  --space-4: 2rem;
  --space-5: 4rem;
  --gap: 1.5rem;
  --gutter: 2rem;
  --content-width: 75rem;
  --sidebar-width: 15.5rem;
  --tabbar-height: 4rem;
  --control-height: 2.75rem; /* 44 px touch target */
}

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

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  font-variant-numeric: tabular-nums;
}

h1,
h2,
h3 {
  line-height: 1.3;
  margin: var(--space-4) 0 var(--space-2);
}

h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.5rem;
  margin-top: 0;
}

h2 {
  font-size: 1.125rem;
  font-weight: 600;
}

h3 {
  font-size: 1rem;
  font-weight: 600;
}

a {
  color: var(--brand);
  text-underline-offset: 2px;
}

a:hover {
  color: var(--brand-hover);
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

img {
  max-width: 100%;
  height: auto;
}

.icon {
  width: 1.25rem;
  height: 1.25rem;
  flex: none;
  fill: none;
  stroke: currentcolor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.skip-link {
  position: absolute;
  left: var(--space-3);
  top: var(--space-3);
  transform: translateY(-200%);
  z-index: 100;
  padding: var(--space-2) var(--space-3);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

.skip-link:focus {
  transform: none;
}

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

.muted {
  color: var(--muted);
}

.container {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* App shell: dark sidebar (desktop), icon rail (tablet), top bar + tab bar (phone) ---------- */
.shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: var(--space-3);
  background: var(--sidebar);
  color: var(--sidebar-text);
  overflow-y: auto;
  z-index: 20;
}

.sidebar-brand,
.topbar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: inherit;
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 600;
  min-width: 0;
}

.sidebar-brand {
  padding: var(--space-1) var(--space-1) var(--space-2);
  font-size: 1.0625rem;
}

.sidebar-brand:hover {
  color: inherit;
}

.sidebar-brand img,
.topbar-brand img {
  border-radius: var(--radius-sm);
  background: #ffffff;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-group {
  margin: 0.75rem var(--space-2) 0.125rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
}

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  min-height: 2.25rem;
  padding: 0.375rem 0.75rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--sidebar-text);
  font: inherit;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.sidebar .nav-link:hover {
  color: var(--sidebar-text);
  background: var(--sidebar-hover);
}

.sidebar .nav-link[aria-current="page"] {
  background: var(--sidebar-active);
}

.sidebar .nav-link[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.5rem;
  bottom: 0.5rem;
  width: 3px;
  border-radius: 3px;
  background: var(--brand-on-dark);
}

.sidebar :focus-visible {
  outline-color: #ffffff;
}

.count {
  margin-left: auto;
  min-width: 1.5rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--brand);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.5rem;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--sidebar-active);
}

.sidebar-footer form {
  margin: 0;
}

.who {
  display: flex;
  flex-direction: column;
  margin: 0 var(--space-2) var(--space-1);
  line-height: 1.4;
}

.who-name {
  font-weight: 600;
}

.who-org {
  color: var(--sidebar-muted);
  font-size: 0.8125rem;
}

.main {
  margin-left: var(--sidebar-width);
  min-width: 0;
}

.content {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.topbar,
.tabbar {
  display: none;
}

/* Tablet: the sidebar becomes an icon rail. */
@media (max-width: 1023px) {
  :root {
    --sidebar-width: 4.5rem;
  }

  .sidebar {
    align-items: center;
    padding: var(--space-3) var(--space-2);
  }

  .sidebar .nav-label,
  .sidebar-brand span,
  .nav-group,
  .who {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .sidebar .nav-link {
    justify-content: center;
    width: 3rem;
    height: 3rem;
    padding: 0;
  }

  .sidebar .button-block {
    width: 3rem;
    padding: 0;
  }

  .sidebar-nav {
    gap: var(--space-1);
  }

  .sidebar .count {
    position: absolute;
    top: 0.125rem;
    right: 0.125rem;
    min-width: 1.125rem;
    padding: 0 0.25rem;
    line-height: 1.125rem;
    font-size: 0.6875rem;
  }
}

/* Phone: top bar + bottom tab bar; "More" opens a sheet with the full menu. */
@media (max-width: 767px) {
  :root {
    --gutter: 1rem;
    --gap: 1rem;
  }

  .sidebar {
    display: none;
  }

  .main {
    margin-left: 0;
    padding-bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom) + var(--space-3));
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    height: 3.5rem;
    padding: 0 var(--gutter);
    background: var(--sidebar);
    color: var(--sidebar-text);
  }

  .topbar-brand span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .tabbar {
    position: fixed;
    inset: auto 0 0;
    z-index: 30;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    align-items: center;
    height: calc(var(--tabbar-height) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 8px rgb(20 20 20 / 6%);
  }

  .tabbar > .nav-link,
  .more > summary {
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    height: var(--tabbar-height);
    min-height: 3rem;
    padding: 0;
    border-radius: 0;
    color: var(--muted);
    font-size: 0.6875rem;
    font-weight: 600;
    text-align: center;
  }

  .tabbar > .nav-link[aria-current="page"] {
    color: var(--brand);
  }

  .tabbar .count {
    position: absolute;
    top: 0.375rem;
    left: calc(50% + 0.375rem);
    min-width: 1.125rem;
    margin: 0;
    padding: 0 0.25rem;
    line-height: 1.125rem;
    font-size: 0.6875rem;
  }

  .tab-new {
    justify-self: center;
    display: grid;
    place-items: center;
    width: 3.25rem;
    height: 3.25rem;
    margin-top: -1.25rem;
    border-radius: 999px;
    background: var(--brand);
    color: #ffffff;
    box-shadow: var(--shadow-lg);
  }

  .tab-new:hover {
    color: #ffffff;
    background: var(--brand-hover);
  }

  .tab-new .icon {
    width: 1.5rem;
    height: 1.5rem;
  }

  .more > summary {
    display: flex;
    align-items: center;
    list-style: none;
    cursor: pointer;
  }

  .more > summary::-webkit-details-marker {
    display: none;
  }

  .more[open] > summary {
    color: var(--brand);
  }

  .more-sheet {
    position: fixed;
    inset: auto 0 calc(var(--tabbar-height) + env(safe-area-inset-bottom));
    max-height: 75vh;
    overflow-y: auto;
    padding: var(--space-2) var(--space-3) var(--space-3);
    background: var(--sidebar);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: var(--shadow-lg);
  }

  .more-sheet .nav-link {
    min-height: var(--control-height);
  }

  .more-sheet .nav-link:hover,
  .more-sheet .nav-link[aria-current="page"] {
    color: var(--sidebar-text);
    background: var(--sidebar-active);
  }

  .more-sheet form {
    margin: 0;
  }
}

.trial-banner {
  margin: 0;
  padding: 0.625rem var(--gutter);
  background: var(--brand);
  color: #ffffff;
  text-align: center;
}

/* Public pages (landing, sign-in, links) ------------------------------------------------- */
.is-public {
  background: var(--brand-tint);
}

.public-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 4rem;
}

/* A signed-in customer's name and sign-out button. */
.header-row .nav {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.header-row .nav .button {
  white-space: nowrap;
}

/* On phones the page heading already shows the customer's name. */
@media (max-width: 767px) {
  .header-row .customer-name {
    display: none;
  }
}

.brand {
  display: inline-flex;
}

.nav .button {
  margin: 0;
}

.public-main {
  padding-bottom: var(--space-4);
}

.is-public .page.narrow {
  margin: var(--space-4) auto 0;
  padding: var(--space-4);
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.hero {
  padding: var(--space-5) 0;
}

.hero h1 {
  margin: 0 0 var(--space-2);
  font-size: 2.5rem;
  line-height: 1.2;
}

.lead {
  margin: 0;
  font-size: 1.25rem;
  color: var(--muted);
}

.site-footer {
  padding: var(--space-4) 0;
  color: var(--muted);
  font-size: 0.875rem;
}

/* Page layout ----------------------------------------------------------------------------- */
.page {
  padding: var(--space-4) 0;
}

.narrow {
  max-width: 28rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--gap);
  margin-bottom: var(--gap);
}

/* Buttons --------------------------------------------------------------------------------- */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--control-height);
  margin-top: var(--space-3);
  padding: 0 1.125rem;
  border: 1px solid var(--brand);
  border-radius: var(--radius);
  background: var(--brand);
  color: #ffffff;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  color: #ffffff;
  background: var(--brand-hover);
  border-color: var(--brand-hover);
}

.button-secondary {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--input-border);
}

.button-secondary:hover {
  color: var(--ink);
  background: var(--brand-tint);
  border-color: var(--brand);
}

.button-block {
  width: 100%;
  margin-top: 0;
}

.link-button {
  font: inherit;
  color: var(--brand);
  background: none;
  border: 0;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.inline-form {
  display: inline;
  margin: 0;
}

/* Forms ----------------------------------------------------------------------------------- */
.form label {
  display: block;
  font-weight: 600;
  margin: var(--space-3) 0 var(--space-1);
}

.form input:not([type="checkbox"], [type="radio"], [type="hidden"]),
.form select,
.form textarea,
.toolbar input:not([type="checkbox"], [type="radio"], [type="hidden"]),
.toolbar select {
  width: 100%;
  min-height: var(--control-height);
  padding: var(--space-2) 0.75rem;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 1rem; /* 16 px: phones don't zoom into the field */
}

.form textarea {
  min-height: 6rem;
}

.form input:focus-visible,
.form select:focus-visible,
.form textarea:focus-visible,
.toolbar input:focus-visible,
.toolbar select:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 0;
  border-color: var(--brand);
}

.form input[readonly] {
  background: var(--surface-alt);
}

.form label.check {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  font-weight: 400;
}

.form label.option {
  margin: var(--space-2) 0 0;
}

.form input[type="checkbox"],
.form input[type="radio"] {
  width: 1.125rem;
  height: 1.125rem;
  accent-color: var(--brand);
}

.form fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: var(--space-3) 0 0;
  padding: 0 var(--space-3) var(--space-3);
}

.field-error {
  color: var(--danger-text);
  margin: var(--space-1) 0 0;
  font-size: 0.875rem;
  font-weight: 500;
}

.toolbar {
  display: flex;
  gap: var(--space-2) var(--space-3);
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: var(--gap);
}

.toolbar label {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
}

.toolbar input,
.toolbar select {
  width: auto;
}

.toolbar input[type="search"] {
  min-width: 18rem;
}

.toolbar .button {
  margin-top: 0;
}

/* Messages -------------------------------------------------------------------------------- */
.notice,
.error {
  margin: var(--space-3) 0;
  padding: 0.75rem var(--space-3);
  border: 1px solid;
  border-left-width: 4px;
  border-radius: var(--radius-sm);
}

.notice {
  color: var(--success-text);
  background: var(--success-tint);
  border-color: var(--success);
}

.notice a {
  color: inherit;
  font-weight: 600;
}

.error {
  color: var(--danger-text);
  background: var(--danger-tint);
  border-color: var(--danger);
}

.error::before {
  content: "⚠ ";
  font-weight: 700;
}

/* Tables ---------------------------------------------------------------------------------- */
table.list {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

table.list th,
table.list td {
  text-align: left;
  padding: 0.75rem var(--space-3);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table.list thead th {
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
}

table.list tbody tr:last-child > *,
table.list tfoot tr:last-child > * {
  border-bottom: 0;
}

table.list tbody tr:hover {
  background: var(--brand-tint);
}

table.list tfoot th,
table.list tfoot td {
  background: var(--surface-alt);
  border-top: 1px solid var(--border);
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Amount columns: must outrank the generic table.list cell rule above. */
table.list .num {
  text-align: right;
}

tr.inactive td {
  color: var(--muted);
}

table.statement tr.opening td,
table.statement tfoot th {
  font-weight: 700;
}

/* Wide tables scroll sideways inside their own box, never the whole page. */
.table-wrap {
  max-width: 100%;
  margin-bottom: var(--gap);
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  background: var(--surface);
}

.table-wrap > table.list {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

@media (max-width: 767px) {
  table.list th,
  table.list td {
    padding: 0.625rem 0.75rem;
  }

  .toolbar input[type="search"] {
    min-width: 0;
    width: 100%;
  }
}

/* Navigation inside pages ----------------------------------------------------------------- */
.tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--gap);
  overflow-x: auto;
}

.tabs a {
  padding: 0.625rem 0.75rem;
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}

.tabs a:hover {
  color: var(--ink);
}

.tabs a[aria-current="page"] {
  color: var(--brand);
  font-weight: 600;
  border-bottom-color: var(--brand);
}

.entry-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--gap);
}

.entry-buttons .button {
  margin-top: 0;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: var(--space-3);
  margin-top: var(--gap);
}

.tile {
  display: flex;
  align-items: center;
  min-height: 4.5rem;
  padding: var(--space-3) 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}

.tile:hover {
  color: var(--brand);
  border-color: var(--brand);
  background: var(--brand-tint);
}

/* Figures --------------------------------------------------------------------------------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: var(--gap);
  margin: var(--space-3) 0 var(--gap);
}

.stats .card {
  margin: 0;
}

.stats p {
  margin: 0;
}

.stat {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}

.bar-cell {
  width: 40%;
}

.bar-cell meter {
  width: 100%;
  height: 0.9rem;
  accent-color: var(--brand);
}

.codes {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  columns: 2;
}

/* Page headers, badges, small buttons -------------------------------------------------- */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--gap);
}

.page-header h1,
.page-header p {
  margin: 0;
}

.page-header .page-action {
  margin-top: 0;
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin: var(--space-4) 0 0.75rem;
}

.section-header h2 {
  margin: 0;
}

.dashboard-main > .section-header:first-child {
  margin-top: 0;
}

.badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-success {
  color: var(--success-text);
  background: var(--success-tint);
  border-color: transparent;
}

.badge-warning {
  color: var(--warning-text);
  background: var(--warning-tint);
  border-color: transparent;
}

.badge-danger {
  color: var(--danger-text);
  background: var(--danger-tint);
  border-color: transparent;
}

.button-small {
  min-height: 2.25rem;
  margin-top: 0;
  padding: 0 0.875rem;
  font-size: 0.875rem;
}

td.empty {
  padding: var(--space-4) var(--space-3);
  color: var(--muted);
  text-align: center;
}

kbd {
  padding: 0 0.3rem;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface);
  font-family: inherit;
  font-size: 0.75rem;
}

/* Dashboard ------------------------------------------------------------------------------- */
.stat-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  color: var(--ink);
  text-decoration: none;
}

.stat-card:hover {
  color: var(--ink);
  border-color: var(--brand);
}

.stat-card-alert {
  background: var(--brand-tint);
  border-color: var(--brand-tint-strong);
}

.stat-label {
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
}

.stat-note {
  color: var(--muted);
  font-size: 0.8125rem;
}

.stat-card-alert .stat-note {
  color: var(--brand);
  font-weight: 600;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(16rem, 1fr);
  gap: var(--gap);
  align-items: start;
}

.dashboard-side h2 {
  margin-top: 0;
}

.attention-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.attention-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.attention-list li div {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.attention-list form {
  margin: 0;
}

.attention-item {
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--warning-tint);
  color: var(--warning-text);
}

.attention-item a {
  color: inherit;
  font-weight: 600;
}

.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}

.quick-actions .button {
  margin: 0;
  padding: 0 0.5rem;
  font-size: 0.875rem;
}

@media (max-width: 1023px) {
  .stats {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 899px) {
  .dashboard-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  /* On a phone the owner's first job is what needs attention. */
  .dashboard-side {
    order: -1;
  }
}

@media (max-width: 767px) {
  .stats {
    grid-template-columns: 1fr 1fr;
  }

  .stat {
    font-size: 1.25rem;
  }

  .page-header .page-action,
  .entry-buttons {
    display: none; /* the tab bar's + button does this on phones */
  }
}

/* Entry form ------------------------------------------------------------------------------ */
.entry-layout {
  display: grid;
  grid-template-columns: minmax(0, 40rem) minmax(16rem, 20rem);
  gap: var(--gap);
  align-items: start;
}

.entry-form > :first-child,
.entry-form > input[type="hidden"] + * {
  margin-top: 0;
}

.entry-aside {
  position: sticky;
  top: var(--space-4);
}

.summary-card h2 {
  margin-top: 0;
}

.summary-list {
  margin: 0 0 var(--space-3);
}

.summary-list div {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 0.375rem 0;
}

.summary-list dt {
  color: var(--muted);
}

.summary-list dd {
  margin: 0;
  font-weight: 600;
}

.summary-total {
  margin-top: var(--space-2);
  padding-top: 0.75rem !important;
  border-top: 1px solid var(--border);
}

.summary-total dd {
  font-family: var(--font-display);
  font-size: 1.5rem;
}

.summary-note,
.hint {
  font-size: 0.8125rem;
}

.hint {
  margin: 0.75rem 0 0;
  text-align: center;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 var(--space-3);
}

.money-field {
  display: flex;
  align-items: center;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.money-field:focus-within {
  outline: 2px solid var(--brand);
  border-color: var(--brand);
}

.money-field span {
  padding-left: 0.75rem;
  color: var(--muted);
  font-weight: 600;
}

.form .money-field input {
  border: 0;
  outline: 0;
  padding-left: 0.375rem;
}

.money-field-large span,
.form .money-field-large input {
  min-height: 3.5rem;
  font-family: var(--font-display);
  font-size: 1.5rem;
  line-height: 3.5rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  border: 0 !important;
  padding: 0 !important;
}

.chips legend {
  margin: var(--space-3) 0 var(--space-1);
  padding: 0;
  font-weight: 600;
}

.form label.chip {
  margin: 0;
  font-weight: 500;
}

.chip input {
  position: absolute;
  opacity: 0;
}

.chip span {
  display: inline-flex;
  align-items: center;
  min-height: var(--control-height);
  padding: 0 var(--space-3);
  border: 1px solid var(--input-border);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
}

.chip input:checked + span {
  color: #ffffff;
  background: var(--brand);
  border-color: var(--brand);
}

.chip input:focus-visible + span {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

@media (max-width: 899px) {
  .entry-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .entry-aside {
    position: static;
  }
}

@media (max-width: 479px) {
  .field-row {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Lists as cards on phones (opt in with table.list.stack; label cells with data-label) ---- */
@media (max-width: 767px) {
  table.list.stack,
  table.list.stack tbody,
  table.list.stack tr,
  table.list.stack td {
    display: block;
  }

  table.list.stack thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  table.list.stack tr {
    padding: 0.75rem var(--space-3);
    border-bottom: 1px solid var(--border);
  }

  table.list.stack tbody tr:last-child {
    border-bottom: 0;
  }

  table.list.stack td {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
    padding: 0.125rem 0;
    border: 0;
    text-align: right;
  }

  table.list.stack td:first-child {
    justify-content: flex-start;
    padding-bottom: 0.25rem;
    font-weight: 600;
    text-align: left;
  }

  table.list.stack td[data-label]::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 500;
    text-align: left;
  }

  table.list.stack td:empty {
    display: none;
  }

  table.list.stack td.empty,
  table.list.stack td[colspan] {
    justify-content: center;
    text-align: center;
    font-weight: 400;
  }
}

/* Settings: section list on the left on desktop --------------------------------------------- */
@media (min-width: 900px) {
  .settings-page {
    display: grid;
    grid-template-columns: 13rem minmax(0, 1fr);
    column-gap: var(--space-4);
    align-items: start;
  }

  .settings-page > * {
    grid-column: 2;
  }

  .settings-page > h1 {
    grid-column: 1 / -1;
  }

  .settings-page > .tabs {
    grid-column: 1;
    grid-row: 2 / span 20;
    flex-direction: column;
    gap: 2px;
    border-bottom: 0;
    overflow: visible;
  }

  .settings-page > .tabs a {
    border-bottom: 0;
    border-radius: var(--radius-sm);
  }

  .settings-page > .tabs a:hover {
    background: var(--surface);
  }

  .settings-page > .tabs a[aria-current="page"] {
    background: var(--brand-tint);
    box-shadow: inset 3px 0 0 var(--brand);
  }

  .settings-page > :nth-child(3) {
    margin-top: 0;
  }
}

/* Detail pages ---------------------------------------------------------------------------- */
.detail-headline {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}

.detail-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: var(--space-3) var(--gap);
  margin: 0;
}

.detail-list dt {
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
}

.detail-list dd {
  margin: 0;
}

.danger-zone {
  margin: var(--space-4) 0;
  padding: var(--space-3) var(--gap);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.danger-zone > summary {
  color: var(--danger-text);
  font-weight: 600;
  cursor: pointer;
}

.button-danger {
  color: var(--danger-text);
  background: var(--surface);
  border-color: var(--danger);
}

.button-danger:hover {
  color: #ffffff;
  background: var(--danger);
  border-color: var(--danger);
}

.share-link {
  display: flex;
  gap: var(--space-2);
}

.share-link .button {
  margin: 0;
  flex: none;
}

/* Motion and print ------------------------------------------------------------------------ */
@media (prefers-reduced-motion: no-preference) {
  .nav-link,
  .button,
  .tile,
  table.list tbody tr {
    transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
  }
}

@media print {
  .no-print {
    display: none !important;
  }

  body {
    background: #ffffff;
  }

  .main {
    margin: 0;
    padding: 0;
  }

  .container,
  .content {
    max-width: none;
    padding: 0;
  }

  table.list,
  .card {
    box-shadow: none;
  }
}
