/* Rental invoicing: emerald (from the old app's diamond mark and the Emarald name), cool paper, quiet ledger rules */
:root {
  color-scheme: light;
  --paper: #F3F6F4;
  --surface: #FFFFFF;
  --ink: #15201B;
  --muted: #56665F;
  --rule: #D3DDD8;
  --emerald: #0B6E4F;
  --emerald-deep: #084F39;
  --emerald-wash: #E2EFE8;
  --danger: #A3362B;
  --danger-wash: #FBEAE7;
  --info: #2C4A73;
  --info-wash: #E7EDF5;
  --font: "Segoe UI Variable Text", "Segoe UI", "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --radius: 6px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #0F1513;
    --surface: #16201C;
    --ink: #E5EDE9;
    --muted: #9AABA3;
    --rule: #2A3732;
    --emerald: #3DB485;
    --emerald-deep: #5CC99D;
    --emerald-wash: #143528;
    --danger: #E58373;
    --danger-wash: #3A1F1B;
    --info: #9DB8E0;
    --info-wash: #1A2536;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; font-weight: 600; }
h1 { font-size: 1.75rem; letter-spacing: -.01em; }
h2 { font-size: 1.125rem; }
p { margin: 0 0 1rem; max-width: 68ch; }
a { color: var(--emerald); text-underline-offset: .15em; }
a:hover { color: var(--emerald-deep); }
:focus-visible { outline: 3px solid var(--emerald); outline-offset: 2px; border-radius: 2px; }
.muted { color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Forms */
.field { margin-bottom: 1.1rem; }
.field label { display: block; font-weight: 600; margin-bottom: .3rem; }
.field .hint { display: block; color: var(--muted); font-size: .875rem; margin: -.15rem 0 .35rem; }
input[type="text"], input[type="email"], input[type="password"] {
  width: 100%;
  height: 2.75rem;
  padding: 0 .75rem;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-bottom-color: var(--muted);
  border-radius: var(--radius);
}
input:focus-visible { outline: 3px solid var(--emerald); outline-offset: 0; border-color: var(--emerald); }
input.code { letter-spacing: .35em; font-size: 1.25rem; max-width: 12rem; }

.button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 2.75rem; padding: 0 1.25rem;
  font: inherit; font-weight: 600;
  color: #fff; background: var(--emerald);
  border: 0; border-radius: var(--radius);
  cursor: pointer; text-decoration: none;
}
@media (prefers-color-scheme: dark) { .button { color: #07130E; } }
.button:hover { background: var(--emerald-deep); color: #fff; }
@media (prefers-color-scheme: dark) { .button:hover { color: #07130E; } }
.button.wide { width: 100%; }
.link-button {
  font: inherit; color: var(--emerald); background: none; border: 0; padding: 0;
  text-decoration: underline; text-underline-offset: .15em; cursor: pointer;
}
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.5rem; margin-top: 1.5rem; }

/* Messages */
.flash { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1.25rem; border-left: 4px solid; }
.flash.error { background: var(--danger-wash); border-color: var(--danger); }
.flash.info { background: var(--info-wash); border-color: var(--info); }
.flash.success { background: var(--emerald-wash); border-color: var(--emerald); }

/* Sign-in pages */
.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}
.gate-panel { width: 100%; max-width: 24rem; }
.gate-brand { display: flex; align-items: center; gap: .9rem; margin-bottom: 2rem; }
.gate-brand img { width: 2.6rem; height: auto; }
.gate-brand span { font-size: 1.35rem; font-weight: 600; letter-spacing: -.01em; }
.gate h1 { font-size: 1.4rem; margin-bottom: .35rem; }
.gate .lead { color: var(--muted); margin-bottom: 1.5rem; }
.gate-form {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-top: 3px solid var(--emerald);
  border-radius: var(--radius);
  padding: 1.5rem;
}

/* Signed-in layout */
.shell { display: grid; grid-template-columns: 16rem minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--rule);
  padding: 1.25rem 1rem;
  display: flex; flex-direction: column; gap: 1.5rem;
}
.brand { display: flex; align-items: center; gap: .65rem; color: var(--ink); text-decoration: none; font-weight: 600; padding: 0 .5rem; }
.brand img { width: 1.6rem; height: auto; }
.nav-group + .nav-group { margin-top: 1.1rem; }
.nav-group h2 { font-size: .8125rem; color: var(--muted); font-weight: 600; margin: 0 .5rem .25rem; }
.nav-group ul { list-style: none; margin: 0; padding: 0; }
.nav-group a {
  display: block; padding: .4rem .5rem; border-radius: var(--radius);
  color: var(--ink); text-decoration: none;
}
.nav-group a:hover { background: var(--emerald-wash); color: var(--ink); }
.nav-group a[aria-current="page"] { background: var(--emerald-wash); box-shadow: inset 3px 0 0 var(--emerald); }
.account { margin-top: auto; padding: 1rem .5rem 0; border-top: 1px solid var(--rule); font-size: .9375rem; }
.account p { margin-bottom: .5rem; }
.account .row { display: flex; gap: 1.25rem; flex-wrap: wrap; }

.content { padding: 2.5rem clamp(1rem, 4vw, 3rem); max-width: 60rem; }
.page-head { margin-bottom: 2rem; }
.page-head p { color: var(--muted); margin: 0; }

.note { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 2rem; }
.note p:last-child { margin-bottom: 0; }

/* Section list: rows, ruled like a ledger */
.section-group { margin-bottom: 2rem; }
.section-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.section-list li {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .25rem 1.5rem; align-items: baseline;
  padding: .85rem 0; border-bottom: 1px solid var(--rule);
}
.section-list a { font-weight: 600; }
.section-list .desc { grid-column: 1; color: var(--muted); font-size: .9375rem; }
.status { grid-column: 2; grid-row: 1 / span 2; font-size: .875rem; white-space: nowrap; color: var(--muted); }
.status.ready { color: var(--emerald); font-weight: 600; }

.narrow { max-width: 26rem; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--rule); }
  .account { margin-top: 0; }
  .content { padding-top: 1.5rem; }
  .section-list li { grid-template-columns: 1fr; }
  .status { grid-column: 1; grid-row: auto; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Records: tables, search, details */
.small { font-size: .875rem; }
.crumb { margin: 0 0 .5rem; font-size: .9375rem; }
.table-wrap { overflow-x: auto; margin-bottom: 2rem; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.table th, .table td { text-align: left; padding: .55rem .8rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
.table thead th { font-weight: 600; color: var(--muted); background: var(--paper); white-space: nowrap; position: sticky; top: 0; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--emerald-wash); }
.table .num { text-align: right; white-space: nowrap; }
.table .code, .facts .code { font-variant-numeric: tabular-nums; letter-spacing: .01em; white-space: nowrap; }
.facts .code { white-space: normal; overflow-wrap: anywhere; }
.table .wrap { word-break: break-all; }
.table tr.cancelled td { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--danger); }
.table tr.cancelled td:last-child { text-decoration: none; color: var(--danger); }

.search { margin-bottom: 1.25rem; max-width: 40rem; }
.search label { display: block; font-weight: 600; margin-bottom: .3rem; }
.search-row { display: flex; gap: .75rem; align-items: center; }
.search-row input { flex: 1; }

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1.5rem 2rem; margin-bottom: 1rem; }
.detail-grid section { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1rem 1.25rem; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.lines { margin: 0; }
.content:has(.table-wrap), .content:has(.detail-grid) { max-width: 76rem; }
.action-bar { margin: 0 0 1.5rem; }
.email-box { max-width: 40rem; margin: 1rem 0 2rem; }
.email-box form { margin-top: .5rem; }
.facts.amounts dd { text-align: right; font-variant-numeric: tabular-nums; }
