/* First Robe Finance — one stylesheet, no frameworks, no outside requests. */

:root {
  --brand: #1f5f64;
  --brand-dark: #102c30;
  --brand-soft: #e6efef;
  --brand-bright: #5fb2ae;
  --sand: #c9a46a;
  --ink: #14161a;
  --body: #4a5059;
  --muted: #838b96;
  --line: #e6e8ec;
  --line-soft: #f1f2f5;
  --bg: #f6f7f9;
  --card: #ffffff;
  --green: #12805c;
  --green-soft: #e6f5ef;
  --amber: #a9660a;
  --amber-soft: #fdf1e0;
  --red: #c0392b;
  --red-soft: #fdecea;
  --blue: #2563c9;
  --blue-soft: #e9f0fd;
  --purple: #6b4fc9;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(20, 22, 26, .05), 0 8px 24px rgba(20, 22, 26, .05);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

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

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

h1, h2, h3, h4 { color: var(--ink); margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.3rem; }
h2 { font-size: 1.02rem; }
p { margin: 0 0 .7rem; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
small { font-size: .82rem; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mt { margin-top: 1.6rem; }
.up { color: var(--green); }
.down { color: var(--red); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

.skip {
  position: absolute; left: -9999px; top: 0; background: var(--ink); color: #fff;
  padding: .6rem 1rem; z-index: 100; border-radius: 0 0 var(--radius-sm) 0;
}
.skip:focus { left: 0; }

/* ----------------------------------------------------------------- shell */

.shell { display: flex; min-height: 100vh; }

.side {
  width: 232px;
  flex: 0 0 232px;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.side__brand { display: flex; align-items: center; justify-content: center; padding: 1.1rem .9rem .8rem; }
.side__logo { width: 100%; max-width: 168px; height: auto; color: var(--ink); }
.auth__logo { width: 230px; max-width: 100%; height: auto; margin: 0 auto .4rem; display: block; color: var(--ink); }
.side__mark {
  width: 34px; height: 34px; border-radius: 10px; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 1.05rem;
}
.side__name { display: flex; flex-direction: column; color: var(--ink); font-weight: 650; line-height: 1.15; }
.side__name small { color: var(--muted); font-weight: 500; }

.side__nav { padding: .4rem .6rem; overflow-y: auto; flex: 1; }
.side__section { margin: 1rem .5rem .3rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.side__link {
  display: flex; align-items: center; gap: .65rem; padding: .55rem .6rem; border-radius: var(--radius-sm);
  color: var(--body); font-weight: 500;
}
.side__link:hover { background: var(--line-soft); text-decoration: none; color: var(--ink); }
.side__link.is-active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.side__link svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 18px; }
.side__count {
  margin-left: auto; background: var(--red); color: #fff; font-size: .72rem; font-weight: 700;
  min-width: 20px; text-align: center; border-radius: 20px; padding: .05rem .35rem;
}

.side__foot { border-top: 1px solid var(--line); padding: .8rem 1rem; }
.side__user { display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: #fff;
  display: grid; place-items: center; font-size: .85rem; font-weight: 600;
}
.side__user-text { display: flex; flex-direction: column; line-height: 1.2; }
.side__user-text strong { color: var(--ink); font-size: .9rem; }
.side__user-text small { color: var(--muted); }
.side__signout { font-size: .85rem; color: var(--muted); }

.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 1rem; padding: 1rem 1.6rem;
  background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.topbar__title p { margin: .1rem 0 0; color: var(--muted); font-size: .88rem; }
.topbar__actions { margin-left: auto; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

.main { padding: 1.4rem 1.6rem 2.5rem; display: flex; flex-direction: column; gap: 1.2rem; max-width: 1500px; width: 100%; }

.foot {
  margin-top: auto; padding: 1rem 1.6rem; border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; color: var(--muted); font-size: .82rem;
}

.flashes { padding: 1rem 1.6rem 0; display: flex; flex-direction: column; gap: .5rem; }
.flash { padding: .7rem .9rem; border-radius: var(--radius-sm); font-size: .92rem; border: 1px solid transparent; }
.flash--ok { background: var(--green-soft); color: var(--green); border-color: #c7e8da; }
.flash--error { background: var(--red-soft); color: var(--red); border-color: #f5cfca; }
.flash--info { background: var(--blue-soft); color: var(--blue); border-color: #cfdefa; }

.notice { background: var(--amber-soft); border: 1px solid #f3dcbb; color: var(--amber); padding: .8rem 1rem; border-radius: var(--radius); }
.notice p { margin: .15rem 0; }

/* ------------------------------------------------------------------ cards */

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .9rem; flex-wrap: wrap; }
.card--intro { border-left: 3px solid var(--brand); }
.card--calm { border-left: 3px solid var(--green); }

.grid { display: grid; gap: 1.2rem; }
.grid--2 { grid-template-columns: 1fr 1fr; }
.grid--3 { grid-template-columns: repeat(3, 1fr); }

.steps { margin: .6rem 0 0; padding-left: 1.2rem; }
.steps li { margin-bottom: .5rem; }

/* --------------------------------------------------------------- headline */

.headline { display: grid; grid-template-columns: minmax(300px, 1fr) minmax(420px, 1.25fr); gap: 1.2rem; }
.headline__main {
  background: linear-gradient(140deg, #0c2226 0%, #17363b 100%);
  color: #fff; border-radius: var(--radius); padding: 1.4rem 1.5rem; display: flex; flex-direction: column; justify-content: center;
}
.headline__label { color: rgba(255,255,255,.72); margin: 0 0 .2rem; font-size: .9rem; }
.headline__value { font-size: 2.6rem; font-weight: 700; margin: 0; color: #fff; letter-spacing: -.02em; line-height: 1.1; }
.headline__note { color: rgba(255,255,255,.6); font-size: .85rem; margin: .6rem 0 1rem; max-width: 42ch; }

.stack { display: flex; height: 8px; border-radius: 8px; overflow: hidden; background: rgba(255,255,255,.15); }
.stack-seg { display: block; height: 100%; }
.stack-seg--brand { background: var(--brand-bright); }
.stack-seg--sand { background: var(--sand); }
.stack-seg--blue { background: #5b8def; }
.stack-seg--grey { background: #9aa2ae; }
.stack-seg--green { background: #35c48f; }

.headline__side { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }

.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem .95rem; display: flex; flex-direction: column; gap: .15rem; }
.stat--link:hover { border-color: var(--brand); text-decoration: none; }
.stat__label { color: var(--muted); font-size: .84rem; }
.stat__value { font-size: 1.35rem; font-weight: 680; color: var(--ink); letter-spacing: -.01em; }
.stat__note { font-size: .8rem; color: var(--muted); }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; margin-bottom: 1rem; }
.stat-row .stat { border: 0; padding: 0; }

.quick-add { border-left: 3px solid var(--brand); }
.quick-add form { margin: 0; }
.quick-add__row { display: flex; align-items: center; gap: .6rem; }
.quick-add__icon {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 10px;
  background: var(--brand-soft); color: var(--brand); display: grid; place-items: center;
}
.quick-add__icon svg { width: 20px; height: 20px; fill: currentColor; }
.quick-add__field { flex: 1; margin: 0; display: block; }
.quick-add__field input { width: 100%; }
.quick-add__hint { margin: .55rem 0 0; }

.explain-bar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .2rem; }

/* ----------------------------------------------------------------- issues */

.issues { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .55rem; }
.issue { border: 1px solid var(--line); border-left-width: 3px; border-radius: var(--radius-sm); padding: .6rem .8rem; }
.issue p { margin: .15rem 0 0; color: var(--ink); font-size: .92rem; }
.issue__type { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; color: var(--muted); }
.issue__action { color: var(--muted) !important; font-size: .85rem !important; }
.issue--high { border-left-color: var(--red); }
.issue--high .issue__type { color: var(--red); }
.issue--medium { border-left-color: var(--amber); }
.issue--medium .issue__type { color: var(--amber); }
.issue--low { border-left-color: var(--muted); }

/* ----------------------------------------------------------------- charts */

.chart { width: 100%; height: 190px; display: block; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-area { fill: rgba(212, 41, 115, .1); }
.chart-line { fill: none; stroke: var(--brand); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.chart-dot { fill: transparent; }
.chart-dot:hover { fill: rgba(212, 41, 115, .18); }
.chart-label { fill: var(--muted); font-size: 10px; font-family: var(--sans); }

.bars { display: flex; flex-direction: column; gap: .5rem; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 1.1fr) minmax(60px, 2fr) auto; gap: .7rem; align-items: center; font-size: .89rem; }
.bar-label { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--line-soft); border-radius: 6px; height: 9px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--brand); border-radius: 6px; }
.bar-value { color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }

.donut-wrap { display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap; }
.donut { width: 170px; height: 170px; transform: rotate(-90deg); flex: 0 0 auto; }
.donut-slice { fill: none; stroke-width: 22; }
.donut-slice--brand { stroke: var(--brand); }
.donut-slice--sand { stroke: var(--sand); }
.donut-slice--blue { stroke: #5b8def; }
.donut-slice--green { stroke: #35c48f; }
.donut-slice--amber { stroke: #e9a13b; }
.donut-slice--purple { stroke: var(--purple); }
.donut-slice--grey { stroke: #b6bcc6; }
.donut-value, .donut-label { transform: rotate(90deg); transform-origin: 90px 90px; fill: var(--ink); font-family: var(--sans); }
.donut-value { font-size: 15px; font-weight: 700; }
.donut-label { font-size: 10px; fill: var(--muted); }

.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .45rem; min-width: 190px; flex: 1; }
.legend li { display: flex; align-items: center; gap: .5rem; font-size: .88rem; }
.legend-label { color: var(--body); }
.legend-value { margin-left: auto; color: var(--ink); font-variant-numeric: tabular-nums; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.dot--brand { background: var(--brand); }
.dot--sand { background: var(--sand); }
.dot--blue { background: #5b8def; }
.dot--green { background: #35c48f; }
.dot--amber { background: #e9a13b; }
.dot--purple { background: var(--purple); }
.dot--grey { background: #b6bcc6; }

/* ----------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; margin: 0 -.3rem; }
.table { width: 100%; border-collapse: collapse; font-size: .89rem; }
.table th {
  text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 650; padding: .45rem .6rem; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: .6rem; border-bottom: 1px solid var(--line-soft); color: var(--ink); vertical-align: middle; }
.table tbody tr:hover { background: var(--line-soft); }
.table--plain tbody tr:hover { background: transparent; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .mono { font-family: var(--mono); font-size: .84rem; }
.table tfoot td { font-weight: 650; border-top: 2px solid var(--line); border-bottom: 0; }

.pill { display: inline-block; padding: .1rem .5rem; border-radius: 20px; font-size: .76rem; font-weight: 600; white-space: nowrap; }
.pill--green { background: var(--green-soft); color: var(--green); }
.pill--amber { background: var(--amber-soft); color: var(--amber); }
.pill--red { background: var(--red-soft); color: var(--red); }
.pill--blue { background: var(--blue-soft); color: var(--blue); }
.pill--grey { background: var(--line-soft); color: var(--muted); }
.pill--brand { background: var(--brand-soft); color: var(--brand-dark); }
.pill--sand { background: #f5efe4; color: #7a5a24; }

.sync-chip {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .8rem; color: var(--muted); white-space: nowrap;
}
.sync-chip__dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex: 0 0 7px;
}
.sync-chip.is-busy { color: var(--brand-dark); }
.sync-chip.is-busy .sync-chip__dot { background: var(--brand); animation: sync-pulse 1.2s ease-in-out infinite; }
@keyframes sync-pulse { 50% { opacity: .25; transform: scale(.7); } }
@media (prefers-reduced-motion: reduce) { .sync-chip.is-busy .sync-chip__dot { animation: none; } }

/* ------------------------------------------------------------ forms, tabs */

.button {
  display: inline-flex; align-items: center; gap: .4rem; padding: .48rem .85rem; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: #fff; color: var(--ink); font-size: .88rem; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.button:hover { border-color: var(--muted); text-decoration: none; }
.button--primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.button--primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.button--ghost { background: transparent; border-color: transparent; color: var(--body); }
.button--danger { color: var(--red); border-color: #f0cdc8; }
.button--block { width: 100%; justify-content: center; }
.button--small { padding: .3rem .6rem; font-size: .82rem; }
.button[disabled] { opacity: .5; cursor: not-allowed; }

.icon-button { border: 0; background: transparent; padding: .4rem; border-radius: var(--radius-sm); cursor: pointer; color: var(--body); display: none; }
.icon-button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

.inline-form { display: inline; }

.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .9rem; }
.field > span { font-size: .86rem; font-weight: 600; color: var(--ink); }
.field small { color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  font-family: inherit; font-size: .92rem; padding: .5rem .65rem; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: #fff; color: var(--ink); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
textarea { min-height: 90px; resize: vertical; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.2rem; }
.form-row { display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; }
.checkbox { display: flex; align-items: center; gap: .5rem; margin-bottom: .8rem; font-size: .9rem; }
.checkbox input { width: auto; }

.tabs { display: flex; gap: .3rem; flex-wrap: wrap; }
.tab { padding: .38rem .75rem; border-radius: 20px; font-size: .87rem; color: var(--body); font-weight: 550; }
.tab:hover { background: var(--line-soft); text-decoration: none; }
.tab.is-active { background: var(--ink); color: #fff; }
.tabs--small .tab { padding: .25rem .6rem; font-size: .82rem; }

.filters { display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1rem; }
.filters .field { margin-bottom: 0; }

.prose p { color: var(--ink); }
.prose ul { margin: .4rem 0 .8rem; padding-left: 1.2rem; }
.prose li { margin-bottom: .3rem; color: var(--ink); }

.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }

.checks { display: flex; flex-direction: column; gap: .3rem; margin-bottom: 1rem; font-size: .87rem; }
.check::before { content: "•"; margin-right: .4rem; }
.check--ok { color: var(--green); }
.check--warn { color: var(--amber); }
.check--bad { color: var(--red); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------- auth */

.auth-body { background: var(--bg); display: grid; place-items: center; min-height: 100vh; padding: 1.5rem; }
.auth { width: 100%; max-width: 380px; }
.auth--wide { max-width: 480px; }
.auth__brand { text-align: center; margin-bottom: 1.2rem; }
.auth__brand .side__mark { margin: 0 auto .6rem; }
.auth__brand h1 { font-size: 1.25rem; }
.auth__brand p { color: var(--muted); font-size: .9rem; }
.auth__card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1.3rem; box-shadow: var(--shadow); }

/* ------------------------------------------------------------- responsive */

@media (max-width: 1100px) {
  .headline { grid-template-columns: 1fr; }
  .grid--2, .grid--3 { grid-template-columns: 1fr; }
}

.plain-list { margin: .4rem 0 0; padding-left: 1.1rem; }
.plain-list li { margin-bottom: .35rem; color: var(--ink); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.examples { border-top: 1px solid var(--line-soft); padding-top: .8rem; }

.flash--cheer {
  background: linear-gradient(120deg, #e6efef, #f5efe4);
  border-color: #cfe0df; color: var(--ink);
}

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 90; overflow: hidden; }
.confetti i {
  position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  to { transform: translateY(102vh) rotate(540deg); opacity: 0; }
}

.foot__quip { color: var(--muted); font-style: italic; }
@media (max-width: 860px) { .foot__quip { display: none; } }

/* ------------------------------------------------------------------- phone */

/* Pull down at the top of a page to reload. */
.pull-refresh {
  position: fixed; top: 6px; left: 50%; z-index: 70;
  transform: translate(-50%, 0);
  display: flex; align-items: center; gap: .45rem;
  padding: .4rem .85rem; border-radius: 30px;
  background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow);
  font-size: .82rem; color: var(--body); white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .15s ease;
}
.pull-refresh.is-visible { opacity: 1; }
.pull-refresh__spinner {
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--brand);
}
.pull-refresh.is-spinning .pull-refresh__spinner { animation: pull-spin .7s linear infinite; }
@keyframes pull-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .pull-refresh.is-spinning .pull-refresh__spinner { animation: none; }
}

.scrim { display: none; position: fixed; inset: 0; background: rgba(15, 17, 21, .45); z-index: 55; }
.scrim[hidden] { display: none !important; }

.mobile-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  grid-template-columns: repeat(5, 1fr);
  background: #fff; border-top: 1px solid var(--line);
  padding: .3rem .2rem calc(.3rem + env(safe-area-inset-bottom, 0px));
}
.mobile-nav a, .mobile-nav button {
  display: flex; flex-direction: column; align-items: center; gap: .15rem;
  padding: .35rem .2rem; font-size: .68rem; color: var(--muted);
  border: 0; background: none; font-family: inherit; cursor: pointer; min-height: 46px;
}
.mobile-nav a:hover, .mobile-nav a:focus { text-decoration: none; }
.mobile-nav svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.mobile-nav .is-active { color: var(--brand); font-weight: 600; }

@media (max-width: 860px) {
  .icon-button { display: inline-flex; }
  .side {
    position: fixed; z-index: 60; left: 0; top: 0; transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: var(--shadow);
  }
  .side.is-open { transform: translateX(0); }
  .scrim { display: block; }
  .main { padding: 1rem 1rem 5.5rem; }
  .topbar { padding: .75rem 1rem; gap: .6rem; }
  .topbar h1 { font-size: 1.1rem; }
  .topbar__title p { display: none; }
  .topbar__actions .button { padding: .45rem .7rem; }
  .sync-chip { font-size: .72rem; }
  .sync-chip span:not(.sync-chip__dot) { max-width: 11ch; overflow: hidden; text-overflow: ellipsis; }
  .flashes { padding: .8rem 1rem 0; }
  .headline__side { grid-template-columns: 1fr 1fr; gap: .6rem; }
  .headline__main { padding: 1.1rem 1.15rem; }
  .headline__value { font-size: 2.1rem; }
  .stat-row { grid-template-columns: 1fr 1fr; gap: .6rem; }
  .form-grid { grid-template-columns: 1fr; }
  .card { padding: .95rem 1rem; }
  .grid { gap: .9rem; }
  .foot { display: none; }
  .mobile-nav { display: grid; }
}

@media (max-width: 700px) {
  /* Wide tables become a stack of cards — no sideways scrolling to read a row. */
  .cards-on-mobile { display: block; }
  .cards-on-mobile thead { display: none; }
  .cards-on-mobile tbody, .cards-on-mobile tfoot { display: block; }
  .cards-on-mobile tr {
    display: block; border: 1px solid var(--line); border-radius: var(--radius-sm);
    padding: .6rem .75rem; margin-bottom: .55rem; background: #fff;
  }
  .cards-on-mobile tbody tr:hover { background: #fff; }
  .cards-on-mobile td {
    display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
    border: 0; padding: .22rem 0; text-align: right;
  }
  .cards-on-mobile td::before {
    content: attr(data-label);
    color: var(--muted); font-size: .78rem; text-align: left; flex: 0 0 auto;
  }
  .cards-on-mobile td:first-child {
    border-bottom: 1px solid var(--line-soft); padding-bottom: .4rem; margin-bottom: .3rem;
  }
  .cards-on-mobile td:first-child::before { font-weight: 600; }
  .cards-on-mobile .num { justify-content: space-between; }
  .cards-on-mobile td:empty { display: none; }

  /* 16px stops iPhones zooming in when a field is tapped. */
  input[type=text], input[type=email], input[type=password], input[type=number],
  input[type=date], input[type=search], select, textarea { font-size: 16px; padding: .6rem .7rem; }
  .button { padding: .58rem .9rem; }
  .button--small { padding: .4rem .7rem; }
  .filters { flex-direction: column; align-items: stretch; }
  .filters .field, .filters .button { width: 100%; }
  .tabs { overflow-x: auto; flex-wrap: nowrap; padding-bottom: .2rem; -webkit-overflow-scrolling: touch; }
  .tab { white-space: nowrap; }
  .donut-wrap { flex-direction: column; align-items: flex-start; }
  .bar-row { grid-template-columns: minmax(70px, 1fr) minmax(40px, 1.4fr) auto; font-size: .84rem; }
  .quick-add__row { flex-wrap: wrap; }
  .quick-add__field { flex: 1 1 100%; order: 2; }
  .quick-add__row .button { order: 3; width: 100%; justify-content: center; }
  .headline__value { font-size: 1.9rem; }
  .stat__value { font-size: 1.2rem; }
  .card__head { gap: .5rem; }
  .form-row { gap: .5rem; }
  .kv { font-size: .86rem; }
}

@media (max-width: 420px) {
  .headline__side, .stat-row { grid-template-columns: 1fr; }
}

@media print {
  .side, .topbar__actions, .icon-button, .foot, .tabs { display: none !important; }
  body { background: #fff; }
  .card { break-inside: avoid; box-shadow: none; }
}

/* The sales-to-cash walk: the last row is the answer, so it carries the weight. */
.bridge td { padding-block: .55rem; }
.bridge__minus { color: var(--muted); }
.bridge__lost .bridge__minus { color: var(--amber-ink, #8a5a00); }
.bridge__end { border-top: 2px solid var(--line); }
.bridge__end td { font-weight: 600; padding-block: .8rem; }
.bridge__end .num { font-size: 1.15rem; }

/* Typing stock straight into the table. The box has to look like a number in
   a table until it is touched, or the page turns into a wall of form fields. */
input.stock-cell__input {
  width: 4.5rem; padding: .3rem .4rem; text-align: right;
  font: inherit; font-variant-numeric: tabular-nums;
  color: inherit; background: transparent;
  border: 1px solid transparent; border-radius: 6px;
  -moz-appearance: textfield;
}
input.stock-cell__input::-webkit-outer-spin-button,
input.stock-cell__input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input.stock-cell__input:hover { border-color: var(--line); }
input.stock-cell__input:focus { border-color: var(--brand); background: var(--card, #fff); outline: none; }
input.stock-cell__input.is-empty { color: var(--muted); }
input.stock-cell__input.is-low { color: #8a5a00; font-weight: 600; }
input.stock-cell__input.is-out,
input.stock-cell__input.is-bad { color: #b3261e; font-weight: 600; }
/* An edited box stays obvious until it is saved. */
input.stock-cell__input.is-dirty {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 8%, transparent);
  font-weight: 600;
}

/* The bar only appears once something has been changed, and follows the
   bottom of the screen so a long shelf count never scrolls away from Save. */
.save-bar {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  margin: 1rem -1rem -1rem; padding: .75rem 1rem;
  background: var(--card, #fff);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 18px rgba(0, 0, 0, .06);
}
.save-bar__count { flex: 1 1 auto; font-weight: 600; }
/* The bar is display:flex, which would otherwise beat the hidden attribute. */
.save-bar[hidden] { display: none; }
@media (max-width: 520px) {
  .save-bar { gap: .5rem; }
  .save-bar__count { flex-basis: 100%; }
  .save-bar .button { flex: 1 1 auto; }
}

/* On a phone the bottom nav is fixed over the page, so the save bar has to sit
   clear of it — otherwise the buttons end up underneath and cannot be pressed.
   The nav is roughly 3.4rem tall plus whatever the handset reserves below. */
@media (max-width: 960px) {
  .save-bar { bottom: calc(3.4rem + env(safe-area-inset-bottom, 0px)); }
}

/* ------------------------------------------------------ styles and sizes */

/* A style's size run, read left to right like a rail: each chip is a size
   and how many are left. Red has run out, amber is nearly gone, faded is a
   size no longer offered. */
.size-run { display: flex; flex-wrap: wrap; gap: .25rem; min-width: 11.5rem; }
.size-chip {
  display: inline-flex; align-items: baseline; gap: .3rem;
  padding: .12rem .45rem; border-radius: 6px; font-size: .78rem;
  font-variant-numeric: tabular-nums; white-space: nowrap;
  background: var(--brand-soft); color: var(--brand-dark);
}
.size-chip b { font-weight: 700; }
.size-chip--low { background: var(--amber-soft); color: var(--amber); }
.size-chip--out { background: var(--red-soft); color: var(--red); }
.size-chip--off { background: var(--line-soft); color: var(--muted); opacity: .7; }
.size-chip--shop { background: #fff; color: var(--amber); box-shadow: inset 0 0 0 1px var(--amber); }

.subcard { border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: .9rem 1rem; }
.subcard h2 { margin-bottom: .6rem; }
.mt-s { margin-top: .8rem; }
.table--compact td, .table--compact th { padding: .4rem .5rem; }
.stat-row--4 { grid-template-columns: repeat(4, 1fr); }
.notice--soft { background: var(--brand-soft); border-color: #cfe0df; color: var(--ink); margin-bottom: 1rem; }
.plain-list { margin: .4rem 0 0; padding-left: 1.1rem; }
.plain-list li { margin-bottom: .25rem; }

/* The size grid on the Stock page: styles down, sizes across. */
.size-grid td.cell { text-align: center; font-variant-numeric: tabular-nums; min-width: 2.6rem; }
.size-grid th.cell { text-align: center; }
.size-grid .cell--out { background: var(--red-soft); color: var(--red); font-weight: 650; }
.size-grid .cell--low { background: var(--amber-soft); color: var(--amber); font-weight: 650; }
.size-grid .cell--none { color: var(--line); }
.size-grid .cell small { display: block; color: var(--muted); font-size: .7rem; font-weight: 400; }

@media (max-width: 860px) {
  .stat-row--4 { grid-template-columns: 1fr 1fr; }
}
