/*
  Shared styles for the Squared Away and Dosewise web apps. Each app sets its own --brand colors.
  Design follows Apple's interface guidelines, translated for the web:
  - Type: the system font, with tracking and leading tuned per size (tight on large, open on small).
  - Response: buttons react on press (:active), instantly; never only on release.
  - Materials: chrome is translucent so content reads underneath; dialogs dim what's behind them.
  - Motion: things grow from what opened them and leave the same way, on a critically damped curve.
  - Respects reduce motion, reduce transparency, and increase contrast.
*/
:root {
  --brand: #1f7a5a;
  --brand-soft: #ddefe6;
  --bg: #f4f6f5;
  --card: #ffffff;
  --text: #15201b;
  --muted: #5b6863;
  --line: rgba(20, 40, 30, 0.1);
  --good: #1b873f;
  --bad: #d12c1f;
  --warn: #b85a00;
  --radius: 14px;
  --radius-lg: 20px;
  --chrome: rgba(244, 246, 245, 0.72);
  --shadow: 0 0.5px 0 rgba(16, 32, 24, 0.04), 0 1px 3px rgba(16, 32, 24, 0.05), 0 8px 24px -12px rgba(16, 32, 24, 0.12);
  --shadow-lift: 0 1px 2px rgba(0, 0, 0, 0.06), 0 24px 64px -16px rgba(0, 0, 0, 0.32);
  /* A critically damped feel (no overshoot) for UI, and its mirror for leaving along the same path. */
  --ease-in: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-out: cubic-bezier(1, 0, 0.68, 0.28);
  --enter: 360ms;
  --exit: 200ms;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand: #7fd8b0; --brand-soft: rgba(127, 216, 176, 0.14); --bg: #0d1210; --card: #161c19; --text: #e7ede9;
    --muted: #9aa8a1; --line: rgba(255, 255, 255, 0.09); --good: #7ddc95; --bad: #ff8a80; --warn: #ffb45c;
    --chrome: rgba(13, 18, 16, 0.72); --shadow: 0 0 0 0.5px rgba(255, 255, 255, 0.06);
    --shadow-lift: 0 0 0 0.5px rgba(255, 255, 255, 0.08), 0 24px 64px -16px rgba(0, 0, 0, 0.7);
    color-scheme: dark;
  }
  .btn { color: #00391f; }
}

/* MARK: Type */

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
html { font-size: 100%; } /* respect the user's text size; everything below is in rem/em */
body {
  font: 1rem/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-optical-sizing: auto;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
h1 { font-size: 1.875rem; line-height: 1.12; letter-spacing: -0.024em; font-weight: 700; margin: 0; }
h2 { font-size: 0.75rem; line-height: 1.3; letter-spacing: 0.06em; font-weight: 600; text-transform: uppercase; color: var(--muted); margin: 1.75rem 0.25rem 0.5rem; }
h2:first-child { margin-top: 0.25rem; }
.num, .big, .big-status { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.good { color: var(--good); } .bad { color: var(--bad); } .warn { color: var(--warn); }
.small { font-size: 0.8125rem; line-height: 1.4; letter-spacing: 0.002em; }

/* MARK: Layout. Translucent sidebar on wide screens, a sticky translucent bar on narrow ones. */

.shell { display: grid; grid-template-columns: 15rem 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 0.125rem;
  padding: 1.5rem 0.875rem; border-right: 0.5px solid var(--line);
  background: var(--chrome); -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%);
}
.brand { display: flex; align-items: center; gap: 0.625rem; font-weight: 700; font-size: 1.0625rem; letter-spacing: -0.012em; padding: 0 0.5rem 1.125rem; }
.brand img { width: 1.75rem; height: 1.75rem; border-radius: 0.4375rem; }
.household-name { font-size: 0.8125rem; color: var(--muted); padding: 0 0.5rem 0.75rem; }
.nav {
  display: flex; align-items: center; gap: 0.625rem; width: 100%; padding: 0.5625rem 0.75rem; border: 0; border-radius: 0.625rem;
  background: none; color: var(--text); text-align: left; cursor: pointer; font-weight: 500;
  transition: background-color 120ms ease-out, transform 100ms ease-out;
}
.nav:hover { background: var(--brand-soft); }
.nav:active { transform: scale(0.98); }
.nav[aria-current="page"] { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.side .spacer { flex: 1; }
.sync { font-size: 0.75rem; color: var(--muted); padding: 0.5rem 0.75rem; }
main { padding: 2.25rem clamp(1rem, 4vw, 3rem) 4rem; max-width: 70rem; width: 100%; }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    height: auto; z-index: 10; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 0.25rem;
    padding: 0.625rem 0.75rem; border-right: 0; border-bottom: 0.5px solid var(--line);
  }
  .brand { padding: 0 0.5rem 0 0; }
  .household-name, .side .spacer { display: none; }
  .nav { width: auto; padding: 0.4375rem 0.625rem; }
  .sync { padding: 0.25rem 0.5rem; }
  main { padding-top: 1.25rem; }
}

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.page-head > div { display: flex; gap: 0.5rem; }
.grid2 { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 1.75rem; align-items: start; }
@media (max-width: 960px) { .grid2 { grid-template-columns: 1fr; } }

/* MARK: Surfaces */

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1rem; min-height: 3.5rem; position: relative; }
/* Inset separators, like grouped lists: they start where the text starts. */
.row + .row::before { content: ""; position: absolute; top: 0; left: 1rem; right: 0; border-top: 0.5px solid var(--line); }
.row .grow { flex: 1; min-width: 7.5rem; }
.row .title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.right { text-align: right; }
.empty { padding: 1.25rem 1rem; color: var(--muted); }
.footer-note { font-size: 0.8125rem; line-height: 1.4; color: var(--muted); margin: 0.5rem 0.25rem 0; }

.status { padding: 1.375rem 1.5rem; }
.status .label { color: var(--muted); font-size: 0.9375rem; }
.status .big { font-size: 2.5rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1.08; margin-top: 0.125rem; }
.big-status { font-size: 1.875rem; font-weight: 700; letter-spacing: -0.022em; line-height: 1.15; margin-top: 0.125rem; }

.avatar { width: 2rem; height: 2rem; border-radius: 50%; color: #fff; font-weight: 600; font-size: 0.875rem; display: grid; place-items: center; flex: none; }
.c-blue { background: #007aff; } .c-green { background: #34c759; } .c-orange { background: #ff9500; } .c-pink { background: #ff2d55; }
.c-purple { background: #af52de; } .c-teal { background: #30b0c7; } .c-yellow { background: #e6b800; } .c-red { background: #ff3b30; }
.icon { width: 2rem; height: 2rem; border-radius: 0.5625rem; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); flex: none; font-size: 0.9375rem; }

/* MARK: Controls. Feedback happens on press, not release. */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.375rem; min-height: 2.25rem;
  border: 0; border-radius: 0.625rem; padding: 0.5rem 0.9375rem; background: var(--brand); color: #fff;
  font-weight: 600; font-size: 0.9375rem; letter-spacing: -0.008em; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: transform 100ms ease-out, filter 120ms ease-out, background-color 120ms ease-out;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(0.97); filter: brightness(0.94); }
.btn:disabled { opacity: 0.4; cursor: default; transform: none; }
.btn.secondary { background: var(--brand-soft); color: var(--brand); }
.btn.ghost { background: none; color: var(--brand); padding: 0.375rem 0.5rem; min-height: 2rem; }
.btn.ghost:hover { background: var(--brand-soft); filter: none; }
.btn.danger { background: none; color: var(--bad); box-shadow: inset 0 0 0 0.5px var(--line); }
.btn.small { min-height: 2rem; padding: 0.3125rem 0.75rem; font-size: 0.875rem; }

.bar { height: 0.5rem; border-radius: 0.25rem; background: var(--line); overflow: hidden; margin-top: 0.375rem; }
.bar > span { display: block; height: 100%; border-radius: 0.25rem; transition: width var(--enter) var(--ease-in); }

label.field { display: grid; gap: 0.3125rem; font-size: 0.8125rem; color: var(--muted); font-weight: 500; }
input[type=text], input[type=search], input[type=date], input[type=time], select, textarea {
  width: 100%; padding: 0.625rem 0.75rem; border-radius: 0.625rem; border: 0.5px solid var(--line);
  background: var(--bg); color: var(--text); font-size: 1rem; transition: box-shadow 120ms ease-out;
}
input:focus, select:focus, textarea:focus { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 35%, transparent); }
button:focus-visible, .nav:focus-visible, a:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.amount-input { font-size: 1.75rem !important; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.seg { display: flex; background: var(--bg); border-radius: 0.6875rem; padding: 0.1875rem; box-shadow: inset 0 0 0 0.5px var(--line); }
.seg button { flex: 1; border: 0; background: none; padding: 0.375rem; border-radius: 0.5rem; cursor: pointer; font-weight: 500; transition: background-color 160ms var(--ease-in), box-shadow 160ms var(--ease-in); }
.seg button[aria-pressed="true"] { background: var(--card); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 0 0 0.5px var(--line); font-weight: 600; }
.split-row { display: flex; align-items: center; gap: 0.625rem; padding: 0.375rem 0; }
.split-row .grow { flex: 1; }
.split-row input[type=text] { width: 7rem; text-align: right; }
.error { color: var(--bad); font-size: 0.875rem; }
.error:empty { display: none; }
.row select { width: auto; flex: none; padding: 0.375rem 0.625rem; font-size: 0.875rem; }
@media (max-width: 560px) { .row select { display: none; } }

/* MARK: Dialogs. Dim to focus; the sheet grows from the button that opened it and returns there. */

dialog {
  border: 0; border-radius: var(--radius-lg); padding: 0; width: min(32rem, calc(100vw - 2rem));
  background: var(--card); color: var(--text); box-shadow: var(--shadow-lift);
}
dialog[open] { animation: sheet-in var(--enter) var(--ease-in) both; }
dialog.closing { animation: sheet-out var(--exit) var(--ease-out) both; }
dialog::backdrop { background: rgba(8, 14, 11, 0.4); animation: fade-in var(--enter) var(--ease-in) both; }
dialog.closing::backdrop { animation: fade-out var(--exit) var(--ease-out) both; }
@keyframes sheet-in { from { opacity: 0; transform: scale(0.94); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes sheet-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: scale(0.94); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 1.125rem 1.25rem 0.375rem; }
.dialog-head h3 { margin: 0; font-size: 1.1875rem; letter-spacing: -0.016em; }
.dialog-body { padding: 0.5rem 1.25rem 0.25rem; display: grid; gap: 0.875rem; max-height: 70vh; overflow: auto; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 0.5rem; padding: 0.875rem 1.25rem 1.25rem; }

/* MARK: Toast. A floating material that rises in and leaves the way it came. */

.toast {
  position: fixed; bottom: 1.5rem; left: 50%; z-index: 20; padding: 0.625rem 1rem; border-radius: 0.75rem;
  font-size: 0.875rem; font-weight: 500; color: #fff; background: rgba(28, 32, 30, 0.82);
  -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%);
  box-shadow: 0 8px 32px -8px rgba(0, 0, 0, 0.35);
  transform: translate(-50%, 0.75rem); opacity: 0;
  transition: transform var(--enter) var(--ease-in), opacity var(--enter) var(--ease-in);
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.hide { transform: translate(-50%, 0.75rem); opacity: 0; transition-duration: var(--exit); transition-timing-function: var(--ease-out); }

/* MARK: Link and welcome pages */

.link-page { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.link-card { display: grid; grid-template-columns: 1fr auto; gap: 2.5rem; align-items: center; max-width: 54rem; padding: 2.5rem; border-radius: var(--radius-lg); }
@media (max-width: 760px) { .link-card { grid-template-columns: 1fr; padding: 1.5rem; } }
.link-card h1 { font-size: 2.125rem; letter-spacing: -0.028em; margin-bottom: 0.5rem; }
.link-card ol { padding-left: 1.25rem; margin: 1.25rem 0; display: grid; gap: 0.625rem; }
.link-card .card { box-shadow: 0 0 0 0.5px var(--line); }
.qr { width: 17.5rem; height: 17.5rem; background: #fff; border-radius: 1rem; padding: 0.875rem; display: grid; place-items: center; box-shadow: 0 0 0 0.5px var(--line), var(--shadow); }
.qr svg { width: 100%; height: 100%; }
.privacy { font-size: 0.8125rem; line-height: 1.45; color: var(--muted); border-top: 0.5px solid var(--line); padding-top: 0.875rem; margin-top: 0.875rem; }
details summary { cursor: pointer; color: var(--brand); font-weight: 500; }
details[open] summary { margin-bottom: 0.625rem; }

/* MARK: Accessibility settings */

@media (prefers-reduced-motion: reduce) {
  /* Gentle cross-fades instead of scaling, sliding, and blurring. */
  dialog[open] { animation: fade-in 180ms ease both; }
  dialog.closing { animation: fade-out 140ms ease both; }
  .toast, .toast.show, .toast.hide { transform: translate(-50%, 0); transition: opacity 180ms ease; }
  .btn:active, .nav:active { transform: none; }
  .bar > span { transition: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .side { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .toast { background: #1c201e; -webkit-backdrop-filter: none; backdrop-filter: none; }
  dialog::backdrop { background: rgba(8, 14, 11, 0.5); }
}
@media (prefers-contrast: more) {
  :root { --line: rgba(0, 0, 0, 0.45); --muted: #3d4743; }
  .card, .btn.danger, .seg { box-shadow: 0 0 0 1px var(--line); }
  .side { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; border-color: var(--line); }
}

.nav-icon { width: 1.25rem; height: 1.25rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon .nav-icon { width: 1.125rem; height: 1.125rem; }

/* Privacy and support pages: one readable column. */
.doc { max-width: 42rem; margin: 0 auto; padding: 2.5rem 1.5rem 4rem; }
.doc-brand { display: inline-flex; align-items: center; gap: 0.625rem; font-weight: 600; color: var(--text); text-decoration: none; margin-bottom: 2rem; }
.doc-brand img { border-radius: 0.4rem; }
.doc h1 { font-size: 2.25rem; letter-spacing: -0.03em; }
.doc h2 { font-size: 1.25rem; line-height: 1.25; letter-spacing: -0.012em; margin: 2.25rem 0 0.5rem; text-transform: none; color: var(--text); font-weight: 650; }
.doc h3 { font-size: 1.0625rem; line-height: 1.3; letter-spacing: -0.006em; margin: 1.5rem 0 0.25rem; font-weight: 600; }
.doc p, .doc li { line-height: 1.6; }
.doc ul { padding-left: 1.25rem; display: grid; gap: 0.5rem; }
.doc a { color: var(--brand); }
.doc-meta { color: var(--muted); font-size: 0.875rem; margin: 0.375rem 0 1.5rem; }
.doc-lead { font-size: 1.125rem; line-height: 1.55; letter-spacing: -0.006em; }
.doc-callout { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.25rem; margin: 1.5rem 0; line-height: 1.55; }
.doc-footer { margin-top: 3rem; padding-top: 1rem; border-top: 0.5px solid var(--line); color: var(--muted); font-size: 0.875rem; }
.doc-footer a { color: var(--muted); }
.doc-links { font-size: 0.8125rem; color: var(--muted); margin: 0.5rem 0 0; }
.doc-links a { color: var(--muted); }
