:root{
  --bg-canvas:#EAE0D0;
  --bg-canvas-2:#E1D4BE;
  --bg:#F7F1E6;
  --surface:#FCF8F1;
  --surface-2:#EFE5D4;
  --border:#DED0B7;
  --border-soft:#E7DAC3;
  --ink:#362C21;
  --ink-soft:#7A6A56;
  --ink-faint:#A6957E;
  --accent:#BD5B37;
  --accent-strong:#9C4527;
  --accent-wash:#F1DDD0;
  --brass:#A07C43;
  --brass-wash:#EEE3CC;
  --ok:#5F7A4C;
  --ok-wash:#E3E9D8;
  --warn:#B4842A;
  --warn-wash:#F2E5C8;
  --due:#A23B32;
  --due-wash:#F3DAD5;
  --shadow-1: 0 1px 2px rgba(54,44,33,.06);
  --shadow-2: 0 8px 24px -8px rgba(54,44,33,.28);
  --font-display:"Iowan Old Style","Palatino Linotype","Book Antiqua",Georgia,serif;
  --font-body:-apple-system,BlinkMacSystemFont,"SF Pro Text","Helvetica Neue",Arial,sans-serif;
  --font-mono:ui-monospace,"SF Mono",Menlo,Consolas,monospace;
}
@media (prefers-color-scheme: dark){
  :root{
    --bg-canvas:#171310; --bg-canvas-2:#0F0C0A; --bg:#1E1812; --surface:#271F17; --surface-2:#33291E;
    --border:#423627; --border-soft:#3A2F22; --ink:#F0E6D6; --ink-soft:#BBA98F; --ink-faint:#8B7A64;
    --accent:#E08155; --accent-strong:#EE9A6E; --accent-wash:#3B2620; --brass:#D4AC6E; --brass-wash:#3A311F;
    --ok:#93AC7E; --ok-wash:#2A3122; --warn:#D9AC55; --warn-wash:#3A2F18; --due:#E08279; --due-wash:#3B211E;
    --shadow-2: 0 12px 30px -8px rgba(0,0,0,.55);
  }
}
:root[data-theme="dark"]{
  --bg-canvas:#171310; --bg-canvas-2:#0F0C0A; --bg:#1E1812; --surface:#271F17; --surface-2:#33291E;
  --border:#423627; --border-soft:#3A2F22; --ink:#F0E6D6; --ink-soft:#BBA98F; --ink-faint:#8B7A64;
  --accent:#E08155; --accent-strong:#EE9A6E; --accent-wash:#3B2620; --brass:#D4AC6E; --brass-wash:#3A311F;
  --ok:#93AC7E; --ok-wash:#2A3122; --warn:#D9AC55; --warn-wash:#3A2F18; --due:#E08279; --due-wash:#3B211E;
  --shadow-2: 0 12px 30px -8px rgba(0,0,0,.55);
}
:root[data-theme="light"]{
  --bg-canvas:#EAE0D0; --bg-canvas-2:#E1D4BE; --bg:#F7F1E6; --surface:#FCF8F1; --surface-2:#EFE5D4;
  --border:#DED0B7; --border-soft:#E7DAC3; --ink:#362C21; --ink-soft:#7A6A56; --ink-faint:#A6957E;
  --accent:#BD5B37; --accent-strong:#9C4527; --accent-wash:#F1DDD0; --brass:#A07C43; --brass-wash:#EEE3CC;
  --ok:#5F7A4C; --ok-wash:#E3E9D8; --warn:#B4842A; --warn-wash:#F2E5C8; --due:#A23B32; --due-wash:#F3DAD5;
  --shadow-2: 0 8px 24px -8px rgba(54,44,33,.28);
}

*{box-sizing:border-box;}
html,body{margin:0;padding:0;height:100%;}
body{
  min-height:100vh;
  background:
    radial-gradient(1200px 800px at 20% -10%, var(--bg-canvas-2), transparent 60%),
    var(--bg-canvas);
  display:flex; justify-content:center;
  font-family:var(--font-body);
  color:var(--ink);
  overflow-x:hidden;
}
@media (prefers-reduced-motion: reduce){
  *{animation-duration:.001ms !important; transition-duration:.001ms !important;}
}
button, input, textarea, select{ font-family: inherit; }

/* ---------- Login ---------- */
.login-wrap{
  width:min(400px, 92vw); background:var(--surface); border:1px solid var(--border-soft);
  border-radius:24px; padding:36px 30px; box-shadow:var(--shadow-2); display:flex; flex-direction:column; gap:18px;
}
.login-logo{ width:88px; height:88px; border-radius:50%; object-fit:cover; align-self:center; box-shadow:var(--shadow-1); }
.login-wrap h1{ font-family:var(--font-display); font-size:24px; margin:0; text-align:center; }
.login-wrap .sub{ text-align:center; color:var(--ink-soft); font-size:13.5px; margin-top:-10px; }
.login-error{ background:var(--due-wash); color:var(--due); font-size:13px; font-weight:600; padding:9px 12px; border-radius:10px; display:none; }
.login-error.show{ display:block; }

/* ---------- App shell (real page, not a device mockup) ---------- */
.rig{
  width:100%; max-width:560px;
  height:100vh; height:100dvh;
  background:var(--bg);
  display:flex; flex-direction:column;
  position:relative; overflow:hidden; isolation:isolate;
}
@media (min-width: 561px){
  body{ padding:28px 16px; }
  .rig{
    height:calc(100vh - 56px); height:calc(100dvh - 56px);
    border-radius:20px;
    box-shadow:var(--shadow-2), 0 0 0 1px var(--border-soft);
  }
}

.app{ flex:1; min-height:0; display:flex; flex-direction:column; position:relative; }
.navbar{ flex:0 0 auto; display:flex; align-items:center; gap:8px; padding:18px 16px 12px; min-height:38px; }
.navbar .nav-title{ font-family:var(--font-display); font-size:20px; font-weight:600; flex:1; text-wrap:balance; }
.navbar .nav-eyebrow{ font-size:11px; letter-spacing:.1em; text-transform:uppercase; color:var(--ink-faint); display:flex; align-items:center; gap:5px; margin-bottom:1px; }
.brand-icon{ width:14px; height:14px; border-radius:50%; object-fit:cover; flex:0 0 auto; }
.navbtn{ width:32px; height:32px; border-radius:50%; border:1px solid var(--border); background:var(--surface); display:flex; align-items:center; justify-content:center; color:var(--ink); cursor:pointer; flex:0 0 auto; }
.navbtn svg{ width:16px; height:16px; }
.icon-slot{ display:inline-flex; }
.icon-slot svg{ display:block; }
.navbtn:active{ transform:scale(.94); }
.navbtn:focus-visible, button:focus-visible, .segbtn:focus-visible, .tabbtn:focus-visible{ outline:2px solid var(--accent); outline-offset:2px; }

.tabbar{ flex:0 0 auto; display:flex; border-top:1px solid var(--border-soft); background:var(--surface); padding:8px 8px 10px; }
.tabbtn{ flex:1; display:flex; flex-direction:column; align-items:center; gap:3px; background:none; border:none; color:var(--ink-faint); font-size:10.5px; font-weight:600; letter-spacing:.02em; cursor:pointer; padding:4px 2px; }
.tabbtn svg{ width:22px; height:22px; }
.tabbtn.active{ color:var(--accent); }

.pane{ position:absolute; inset:0; overflow-y:auto; -webkit-overflow-scrolling:touch; display:none; flex-direction:column; padding-bottom:24px; }
.pane.active{ display:flex; }
.pane::-webkit-scrollbar{ display:none; }
.content{ padding:2px 16px 12px; display:flex; flex-direction:column; gap:14px; }

h1,h2,h3{ margin:0; font-family:var(--font-display); font-weight:600; }
p{ margin:0; }
.section-label{ font-size:11px; font-weight:700; letter-spacing:.12em; text-transform:uppercase; color:var(--ink-faint); margin:2px 2px 0; display:flex; justify-content:space-between; align-items:center; }
.link-btn{ font-size:12.5px; font-weight:700; color:var(--accent); background:none; border:none; cursor:pointer; text-transform:none; letter-spacing:0; padding:0; }

.search{ display:flex; align-items:center; gap:8px; background:var(--surface-2); border:1px solid var(--border-soft); border-radius:12px; padding:9px 12px; color:var(--ink-faint); font-size:14px; }
.search svg{ width:16px; height:16px; flex:0 0 auto; }
.search input{ border:none; background:none; outline:none; font-size:14px; color:var(--ink); flex:1; min-width:0; }
.search input::placeholder{ color:var(--ink-faint); }

.status-group{ display:flex; flex-direction:column; gap:8px; margin-bottom:2px; }
.status-group .section-label{ margin:2px 2px 0; }
.status-row{
  display:flex; align-items:center; gap:10px; background:var(--surface); border:1px solid var(--border-soft);
  border-radius:14px; padding:10px 12px; cursor:pointer; width:100%; text-align:left;
}
.status-row:active{ transform:scale(.99); }
.status-row .sr-name{ font-family:var(--font-display); font-size:15px; font-weight:600; flex:1; min-width:0; }
.status-row .sr-sub{ font-size:11.5px; color:var(--ink-faint); margin-top:1px; }
.status-row .sr-meta{ flex:1; min-width:0; }

.filters{ display:flex; gap:8px; overflow-x:auto; padding:2px; }
.chip{ flex:0 0 auto; font-size:12.5px; font-weight:600; padding:6px 12px; border-radius:999px; border:1px solid var(--border); background:var(--surface); color:var(--ink-soft); cursor:pointer; white-space:nowrap; }
.chip.active{ background:var(--ink); color:var(--bg); border-color:var(--ink); }

.dog-grid{ display:flex; flex-direction:column; gap:10px; }
.dog-card{ display:flex; align-items:center; gap:12px; background:var(--surface); border:1px solid var(--border-soft); border-radius:16px; padding:10px; cursor:pointer; box-shadow:var(--shadow-1); text-align:left; position:relative; width:100%; }
.dog-card:active{ transform:scale(.985); }
.avatar{ width:56px; height:56px; border-radius:14px; flex:0 0 auto; position:relative; display:flex; align-items:center; justify-content:center; font-family:var(--font-display); font-size:22px; font-weight:600; box-shadow:inset 0 0 0 1px rgba(0,0,0,.08); color:#fff; background:linear-gradient(155deg,var(--brass),var(--accent-strong)); }
.avatar.lg{ width:84px; height:84px; border-radius:20px; font-size:32px; }
.avatar .alert-dot{ position:absolute; top:-4px; right:-4px; width:16px; height:16px; border-radius:50%; background:var(--due); border:2px solid var(--surface); display:flex; align-items:center; justify-content:center; }
.avatar .alert-dot svg{ width:9px; height:9px; color:#fff; }

.dog-card .meta{ flex:1; min-width:0; }
.dog-card .name-row{ display:flex; align-items:baseline; gap:6px; }
.dog-card .name{ font-family:var(--font-display); font-size:17px; font-weight:600; }
.dog-card .breed{ font-size:12.5px; color:var(--ink-soft); margin-top:1px; }
.dog-card .tags{ display:flex; gap:6px; margin-top:6px; flex-wrap:wrap; }
.dog-card .chev{ color:var(--ink-faint); flex:0 0 auto; }
.dog-card .chev svg{ width:16px; height:16px; }

.badge{ display:inline-flex; align-items:center; gap:4px; font-size:11px; font-weight:700; padding:3px 8px; border-radius:999px; white-space:nowrap; }
.badge svg{ width:11px; height:11px; }
.badge.ok{ background:var(--ok-wash); color:var(--ok); }
.badge.warn{ background:var(--warn-wash); color:var(--warn); }
.badge.due{ background:var(--due-wash); color:var(--due); }
.badge.brass{ background:var(--brass-wash); color:var(--brass); }
.badge.neutral{ background:var(--surface-2); color:var(--ink-soft); }

.profile-header{ display:flex; gap:14px; align-items:center; padding:6px 16px 4px; }
.profile-header .info h1{ font-size:24px; line-height:1.1; }
.profile-header .info .sub{ font-size:13px; color:var(--ink-soft); margin-top:3px; }
.profile-header .info .tags{ display:flex; gap:6px; margin-top:8px; flex-wrap:wrap; }

.segmented{ position:relative; display:grid; grid-template-columns:repeat(5,1fr); background:var(--surface-2); border:1px solid var(--border-soft); border-radius:12px; padding:3px; margin:14px 16px 4px; gap:2px; }
.seg-highlight{ position:absolute; top:3px; bottom:3px; left:3px; width:calc(20% - 2.4px); background:var(--surface); border-radius:9px; box-shadow:var(--shadow-1); transition:transform .28s cubic-bezier(.4,0,.2,1); z-index:0; }
.segbtn{ position:relative; z-index:1; border:none; background:none; padding:8px 1px; font-size:10px; font-weight:600; color:var(--ink-soft); cursor:pointer; border-radius:9px; line-height:1.15; }
.segbtn.active{ color:var(--accent-strong); }

.panels{ position:relative; }
.panel{ display:none; }
.panel.active{ display:flex; flex-direction:column; gap:14px; }

.card{ background:var(--surface); border:1px solid var(--border-soft); border-radius:16px; padding:14px; box-shadow:var(--shadow-1); display:flex; flex-direction:column; gap:10px; }
.card-title{ display:flex; align-items:center; justify-content:space-between; gap:8px; }
.card-title h3{ font-size:15px; }
.card-title .link-btn{ font-size:12.5px; font-weight:700; color:var(--accent); background:none; border:none; cursor:pointer; }

.field-grid{ display:grid; grid-template-columns:1fr 1fr; gap:10px 14px; }
.field{ display:flex; flex-direction:column; gap:2px; }
.field .k{ font-size:10.5px; text-transform:uppercase; letter-spacing:.08em; color:var(--ink-faint); font-weight:700; }
.field .v{ font-size:14px; font-weight:600; font-variant-numeric:tabular-nums; }
.field .v.mono{ font-family:var(--font-mono); font-size:13px; font-weight:500; }

.test-row{ display:flex; align-items:center; justify-content:space-between; padding:8px 0; border-top:1px solid var(--border-soft); }
.test-row:first-of-type{ border-top:none; }
.test-row .t-name{ font-size:13.5px; font-weight:600; }
.test-row .t-date{ font-size:11.5px; color:var(--ink-faint); margin-top:1px; font-variant-numeric:tabular-nums; }

.visit{ border-top:1px solid var(--border-soft); padding:12px 0; display:flex; flex-direction:column; gap:8px; }
.visit:first-of-type{ border-top:none; padding-top:2px; }
.visit-head{ display:flex; justify-content:space-between; gap:8px; align-items:baseline; }
.visit-clinic{ font-size:14.5px; font-weight:700; }
.visit-date{ font-size:12px; color:var(--ink-faint); font-variant-numeric:tabular-nums; white-space:nowrap; }
.visit-note{ font-size:13.5px; color:var(--ink-soft); line-height:1.45; }
.visit-bill{ display:flex; align-items:center; gap:8px; background:var(--surface-2); border:1px solid var(--border-soft); border-radius:10px; padding:7px 10px; cursor:pointer; align-self:flex-start; }
.visit-bill svg{ width:15px; height:15px; color:var(--accent); }
.visit-bill span{ font-size:12.5px; font-weight:600; }

.breeding-row{ border-top:1px solid var(--border-soft); padding:12px 0; display:flex; flex-direction:column; gap:6px; }
.breeding-row:first-of-type{ border-top:none; padding-top:2px; }
.breeding-head{ display:flex; justify-content:space-between; gap:8px; align-items:baseline; }
.breeding-stud{ font-size:14.5px; font-weight:700; }
.breeding-date{ font-size:12px; color:var(--ink-faint); font-variant-numeric:tabular-nums; white-space:nowrap; }
.breeding-meta{ display:flex; flex-wrap:wrap; gap:10px; font-size:12.5px; color:var(--ink-soft); }
.breeding-meta b{ color:var(--ink); font-variant-numeric:tabular-nums; }
.breeding-tags{ display:flex; gap:6px; flex-wrap:wrap; }

.stud-toggle{ display:flex; gap:8px; }
.stud-toggle-btn{ flex:1; padding:9px; border-radius:10px; border:1px solid var(--border); background:var(--surface); color:var(--ink-soft); font-size:13px; font-weight:600; cursor:pointer; }
.stud-toggle-btn.active{ background:var(--accent-wash); border-color:var(--accent); color:var(--accent-strong); }

.tie-date-row{ display:flex; gap:8px; align-items:center; }
.tie-date-row input{ flex:1; }
.tie-date-remove{ width:32px; height:32px; flex:0 0 auto; border-radius:8px; border:1px solid var(--border); background:var(--surface); color:var(--due); cursor:pointer; }
.add-tie-date{ font-size:12.5px; font-weight:700; color:var(--accent); background:none; border:none; cursor:pointer; align-self:flex-start; padding:2px; }

.fab{ position:absolute; right:16px; bottom:16px; width:50px; height:50px; border-radius:50%; background:var(--accent); color:#fff; border:none; display:flex; align-items:center; justify-content:center; box-shadow:0 10px 20px -6px rgba(157,69,39,.55); cursor:pointer; z-index:20; }
.fab svg{ width:22px; height:22px; }
.fab:active{ transform:scale(.94); }

.photo-grid{ display:grid; grid-template-columns:repeat(3,1fr); gap:6px; }
.photo-tile{ aspect-ratio:1; border-radius:10px; position:relative; overflow:hidden; cursor:pointer; background-size:cover; background-position:center; display:flex; align-items:center; justify-content:center; background:linear-gradient(155deg,var(--brass),var(--accent-strong)); border:none; padding:0; }
.photo-tile.add{ background:var(--surface-2); border:1.5px dashed var(--border); color:var(--ink-faint); }
.photo-tile.add svg{ width:22px; height:22px; }
.photo-tile img{ width:100%; height:100%; object-fit:cover; }

.litter-row{ display:flex; align-items:center; gap:12px; background:var(--surface); border:1px solid var(--border-soft); border-radius:14px; padding:10px; cursor:pointer; width:100%; text-align:left; }
.litter-swatch{ width:46px; height:46px; border-radius:10px; flex:0 0 auto; background:linear-gradient(155deg,var(--accent),var(--brass)); }
.litter-row .lname{ font-family:var(--font-display); font-size:15.5px; font-weight:600; }
.litter-row .ldetail{ font-size:12px; color:var(--ink-soft); margin-top:2px; }

.guardian-card{ display:flex; flex-direction:column; gap:12px; }
.g-row{ display:flex; gap:10px; align-items:flex-start; }
.g-row svg{ width:16px; height:16px; color:var(--accent); flex:0 0 auto; margin-top:2px; }
.g-row .g-k{ font-size:10.5px; text-transform:uppercase; letter-spacing:.08em; color:var(--ink-faint); font-weight:700; }
.g-row .g-v{ font-size:14px; font-weight:600; }

.upload-btn{ display:flex; align-items:center; justify-content:center; gap:8px; width:100%; background:var(--accent); color:#fff; border:none; border-radius:12px; padding:12px; font-size:14px; font-weight:700; cursor:pointer; }
.upload-btn:active{ transform:scale(.98); }
.upload-btn svg{ width:16px; height:16px; }
.upload-btn[disabled]{ opacity:.5; cursor:not-allowed; }

.scan-card{ display:flex; align-items:center; gap:12px; }
.scan-thumb{ width:56px; height:72px; border-radius:8px; object-fit:cover; flex:0 0 auto; box-shadow:0 4px 10px -2px rgba(0,0,0,.25); }
.scan-status{ flex:1; }
.scan-title{ font-size:13.5px; font-weight:700; }
.scan-sub{ font-size:12px; color:var(--ink-faint); margin-top:2px; }
.scan-bar{ height:5px; border-radius:3px; background:var(--surface-2); overflow:hidden; margin-top:7px; }
.scan-bar-fill{ height:100%; background:var(--accent); width:0%; transition:width .25s linear; }

.drive-tree{ display:flex; flex-direction:column; gap:2px; }
.drive-root{ display:flex; align-items:center; gap:8px; font-size:13.5px; font-weight:700; padding:4px 0; }
.drive-root svg{ width:16px; height:16px; color:var(--brass); }
.drive-sub{ display:flex; align-items:center; gap:8px; padding:6px 0 6px 22px; font-size:13px; border-top:1px solid var(--border-soft); }
.drive-sub:first-of-type{ border-top:none; }
.drive-sub svg{ width:14px; height:14px; color:var(--ink-faint); flex:0 0 auto; }
.drive-sub .dn{ flex:1; font-weight:600; }
.drive-sub .dc{ font-size:11.5px; color:var(--ink-faint); font-variant-numeric:tabular-nums; }
.drive-note{ font-size:11px; color:var(--ink-faint); line-height:1.4; padding-top:2px; }

.settings-row{ display:flex; align-items:center; gap:12px; background:var(--surface); border:1px solid var(--border-soft); border-radius:14px; padding:12px 14px; }
.settings-row svg{ width:18px; height:18px; color:var(--accent); }
.settings-row .sname{ font-size:14px; font-weight:600; flex:1; }
.settings-row .sval{ font-size:12.5px; color:var(--ink-faint); }
.settings-row.link{ cursor:pointer; }
.settings-row.link:active{ transform:scale(.99); }

.empty-note{ font-size:12.5px; color:var(--ink-faint); font-style:italic; padding:2px; }
.error-note{ font-size:12.5px; color:var(--due); font-weight:600; padding:2px; }

.modal-overlay{ position:absolute; inset:0; background:rgba(23,17,10,.55); z-index:60; display:none; align-items:flex-end; justify-content:center; }
.modal-overlay.open{ display:flex; }
.modal-overlay.open .sheet{ animation:sheetup .28s cubic-bezier(.2,.9,.3,1); }
@keyframes sheetup{ from{ transform:translateY(100%);} to{ transform:translateY(0);} }
.sheet{ background:var(--bg); width:100%; border-radius:22px 22px 0 0; padding:8px 18px 22px; display:flex; flex-direction:column; gap:12px; max-height:82%; overflow-y:auto; }
.sheet-handle{ width:36px; height:4px; border-radius:2px; background:var(--border); margin:6px auto 2px; }
.sheet h3{ font-size:17px; }
.form-field{ display:flex; flex-direction:column; gap:5px; }
.form-field label{ font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.07em; color:var(--ink-faint); }
.form-field input, .form-field textarea, .form-field select{ font-size:14px; padding:10px 12px; border-radius:10px; border:1px solid var(--border); background:var(--surface); color:var(--ink); }
.form-field textarea{ resize:none; min-height:60px; }
.form-check{ display:flex; align-items:center; gap:8px; font-size:13.5px; font-weight:600; }
.sheet-actions{ display:flex; gap:10px; margin-top:4px; }
.btn{ flex:1; padding:12px; border-radius:12px; font-size:14px; font-weight:700; cursor:pointer; border:1px solid var(--border); background:var(--surface); color:var(--ink); }
.btn.primary{ background:var(--accent); border-color:var(--accent); color:#fff; }
.btn:active{ transform:scale(.98); }
.btn[disabled]{ opacity:.55; cursor:not-allowed; }

.receipt{ background:#fff; color:#2a2a2a; border-radius:6px; padding:18px; font-family:var(--font-mono); font-size:11.5px; line-height:1.7; box-shadow:0 6px 20px rgba(0,0,0,.15); }
.receipt .rh{ text-align:center; font-weight:700; font-size:13px; margin-bottom:8px; }
.receipt hr{ border:none; border-top:1px dashed #999; margin:8px 0; }
.receipt .rrow{ display:flex; justify-content:space-between; }

.toast{ position:absolute; left:16px; right:16px; bottom:22px; background:var(--ink); color:var(--bg); padding:11px 14px; border-radius:12px; font-size:13px; font-weight:600; display:flex; align-items:center; gap:8px; box-shadow:var(--shadow-2); z-index:70; transform:translateY(140%); transition:transform .32s cubic-bezier(.2,.9,.3,1); }
.toast.show{ transform:translateY(0); }
.toast.error{ background:var(--due); color:#fff; }
.toast svg{ width:16px; height:16px; color:var(--ok); flex:0 0 auto; }
.toast.error svg{ color:#fff; }

.spinner-wrap{ display:flex; align-items:center; justify-content:center; padding:40px 0; color:var(--ink-faint); font-size:13px; }

