/* PetRecords Staff Portal — global styles + theme tokens
   (Carries the sage palette + Fraunces/Inter type system from the public site
    into a denser, more workhorse admin shell.) */

:root {
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --gap: 16px;
  --pad-x: 28px;
  --row: 52px;

  /* default palette (sage) */
  --bg:        #f5f3ec;
  --surface:   #ffffff;
  --surface-2: #faf8f1;
  --surface-3: #f1eee4;
  --line:      #e6e2d6;
  --line-soft: #efeadc;
  --ink:       #1f2622;
  --ink-2:     #4b554f;
  --ink-3:     #828b85;
  --ink-4:     #b3b9b3;
  --accent:    #4f7a5a;
  --accent-2:  #dde7d3;
  --accent-ink:#26402c;
  --warn:      #b97532;
  --warn-soft: #f4e1cc;
  --danger:    #a93b3b;
  --danger-soft:#f0d6d6;
  --good:      #4f7a5a;
  --info:      #4a6b8a;
  --rail-bg:   #efece2;

  --font: "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --serif: "Fraunces", "Source Serif Pro", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --shadow-1: 0 1px 0 rgba(255,255,255,.6) inset, 0 1px 2px rgba(20,28,24,.04);
  --shadow-2: 0 4px 24px rgba(20,28,24,.06), 0 1px 2px rgba(20,28,24,.05);
}

/* Palettes */
.pal-sage   { --bg:#f5f3ec; --surface:#fff; --surface-2:#faf8f1; --surface-3:#f1eee4; --line:#e6e2d6; --line-soft:#efeadc; --rail-bg:#efece2;
              --ink:#1f2622; --ink-2:#4b554f; --ink-3:#828b85;
              --accent:#4f7a5a; --accent-2:#dde7d3; --accent-ink:#26402c; }
.pal-indigo { --bg:#f4f5fa; --surface:#fff; --surface-2:#f9fafd; --surface-3:#eef0f8; --line:#e2e5ee; --line-soft:#ecf0f7; --rail-bg:#eef0f8;
              --ink:#171a25; --ink-2:#3a4254; --ink-3:#737d92;
              --accent:#3a5ad9; --accent-2:#dee6fb; --accent-ink:#16276f; }
.pal-ember  { --bg:#faf5ed; --surface:#fff; --surface-2:#fbf4ec; --surface-3:#f3e9da; --line:#ecdfd2; --line-soft:#f2e9de; --rail-bg:#f3eada;
              --ink:#27201a; --ink-2:#4f4137; --ink-3:#7e7068;
              --accent:#c75d3a; --accent-2:#f4d9c8; --accent-ink:#6a2611; }

/* Density */
.den-spacious { --pad-x: 36px; --gap: 22px; --row: 56px; }
.den-balanced { --pad-x: 24px; --gap: 14px; --row: 48px; }
.den-dense    { --pad-x: 18px; --gap: 10px; --row: 40px; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; border: 0; background: none; padding: 0; cursor: pointer; color: inherit; }
input, textarea, select { font: inherit; color: inherit; }
.serif { font-family: var(--serif); font-weight: 400; letter-spacing: -0.01em; }
.mono  { font-family: var(--mono); }
.muted { color: var(--ink-3); }
.tiny  { font-size: 12px; }
.bold  { font-weight: 600; }

/* ============ App shell ============ */
.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--rail-w, 240px) 1fr;
}
.app.rail-collapsed { --rail-w: 64px; }

/* Side rail */
.rail {
  background: var(--rail-bg);
  border-right: 1px solid var(--line);
  position: sticky; top: 0;
  height: 100vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.rail-head {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(140deg, var(--accent), color-mix(in oklab, var(--accent) 60%, var(--ink)));
  display: grid; place-items: center; color: white;
  font-family: var(--serif); font-weight: 500; font-size: 18px;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.18);
  flex-shrink: 0;
}
.brand-name { font-family: var(--serif); font-size: 17px; letter-spacing: -0.01em; line-height: 1; }
.brand-name .dot { color: var(--accent); }
.brand-sub { font-size: 10.5px; color: var(--ink-3); margin-top: 3px; letter-spacing: 0.04em; text-transform: uppercase; font-weight: 600; }

.rail-collapse {
  margin-left: auto; width: 28px; height: 28px; border-radius: 8px;
  display: grid; place-items: center; color: var(--ink-3);
}
.rail-collapse:hover { background: var(--line-soft); color: var(--ink); }
.rail-collapsed .brand-text, .rail-collapsed .rail-collapse { display: none; }

.rail-body { flex: 1; overflow: auto; padding: 16px 12px 12px; }
.rail-body::-webkit-scrollbar { width: 8px; }
.rail-body::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; }

.rail-section {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-3); margin: 14px 10px 6px; font-weight: 600;
}
.rail-collapsed .rail-section { display: none; }

.rail-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: 9px; color: var(--ink-2);
  font-size: 13.5px; margin-bottom: 1px; cursor: pointer;
  position: relative; width: 100%; text-align: left;
  font-weight: 450;
}
.rail-item:hover { background: var(--line-soft); color: var(--ink); }
.rail-item.active {
  background: var(--surface);
  color: var(--accent-ink);
  font-weight: 550;
  box-shadow: 0 1px 2px rgba(20,28,24,.04), 0 0 0 1px var(--line);
}
.rail-item.active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px;
  background: var(--accent); border-radius: 0 3px 3px 0;
}
.rail-item .ico { width: 18px; flex-shrink: 0; display: grid; place-items: center; color: currentColor; }
.rail-item .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-item .meta {
  font-size: 11px; color: var(--ink-3);
  background: var(--line-soft); padding: 1px 6px; border-radius: 99px;
}
.rail-item.active .meta { background: var(--accent-2); color: var(--accent-ink); }
.rail-item .chev { color: var(--ink-3); opacity: .6; }
.rail-collapsed .rail-item { justify-content: center; padding: 10px 0; gap: 0; }
.rail-collapsed .rail-item .lbl,
.rail-collapsed .rail-item .meta,
.rail-collapsed .rail-item .chev { display: none; }
.rail-collapsed .rail-item.active::before { display: none; }

.rail-sub { padding-left: 22px; margin-top: 2px; }
.rail-collapsed .rail-sub { display: none; }
.rail-sub .rail-item { padding: 6px 11px; font-size: 12.5px; color: var(--ink-3); }
.rail-sub .rail-item.active { background: transparent; box-shadow: none; color: var(--accent-ink); font-weight: 600; }
.rail-sub .rail-item.active::before { display: none; }
.rail-sub .rail-item.active::after {
  content: ""; position: absolute; left: 5px; top: 50%; transform: translateY(-50%);
  width: 5px; height: 5px; border-radius: 50%; background: var(--accent);
}

.rail-foot {
  border-top: 1px solid var(--line);
  padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
}
.quick-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.rail-collapsed .quick-row { grid-template-columns: 1fr; }
.quick-btn {
  height: 38px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--ink-2);
}
.quick-btn:hover { color: var(--accent); border-color: color-mix(in oklab, var(--accent) 50%, var(--line)); }
.rail-collapsed .quick-label { display: none; }
.quick-label { font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; padding: 0 4px 2px; }

.user-tile {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--line);
}
.user-tile:hover { background: var(--surface-2); }
.user-tile .name { font-size: 13px; font-weight: 600; line-height: 1.2; }
.user-tile .role { font-size: 11px; color: var(--ink-3); }
.rail-collapsed .user-tile { justify-content: center; padding: 4px; background: transparent; border: 0; }
.rail-collapsed .user-tile .info { display: none; }

/* ============ Main column ============ */
.main {
  min-width: 0;
  display: flex; flex-direction: column;
}

/* Top bar (page header) */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 16px var(--pad-x) 0;
  background: var(--bg);
}
.topbar-inner {
  flex: 1; min-width: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px 14px 0 0;
  border-bottom: 0;
  padding: 18px 24px 16px;
}
.page-title h1 {
  margin: 0; font-family: var(--serif); font-size: 26px; font-weight: 400; letter-spacing: -0.015em;
  line-height: 1.1;
}
.page-title .kicker {
  font-size: 11px; color: var(--ink-3); text-transform: uppercase;
  letter-spacing: 0.1em; font-weight: 600; margin-bottom: 4px;
}
.page-title .sub { font-size: 13px; color: var(--ink-3); margin-top: 2px; }

.page-actions { display: flex; gap: 8px; align-items: center; }

/* Search box (header) */
.search-h {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 12px; width: 280px;
  color: var(--ink-3);
}
.search-h input { background: none; border: 0; outline: 0; width: 100%; color: var(--ink); font-size: 13px; }
.search-h .kbd { font-family: var(--mono); font-size: 10.5px; padding: 1px 6px; border: 1px solid var(--line); border-radius: 5px; }

/* Global search results dropdown */
.search-h { position: relative; }
.search-results {
  position: absolute; left: 0; right: 0; top: calc(100% + 8px); z-index: 70;
  max-height: 60vh; overflow: auto; padding: 6px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow-2);
}
.search-group + .search-group { margin-top: 4px; border-top: 1px solid var(--line); padding-top: 4px; }
.search-group-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-3); font-weight: 600; padding: 6px 10px 4px;
}
.search-hit {
  display: flex; flex-direction: column; gap: 1px;
  padding: 8px 11px; border-radius: 9px; text-decoration: none; color: var(--ink-2);
}
.search-hit:hover, .search-hit.is-active { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.search-hit-title { font-size: 13px; font-weight: 600; }
.search-empty { padding: 12px; text-align: center; }

/* Row action (ellipsis) menu — reuses the account-menu panel styling */
.row-menu { position: relative; display: inline-block; }
.row-menu > summary { list-style: none; cursor: pointer; }
.row-menu > summary::-webkit-details-marker { display: none; }
.row-menu-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 60;
  min-width: 210px; padding: 6px; text-align: left;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow-2);
}
.row-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: 9px; font-size: 13px;
  color: var(--ink-2); width: 100%; text-align: left; text-decoration: none;
  background: none; border: 0; cursor: pointer;
}
.row-menu-item:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.row-menu-item.is-danger { color: var(--danger); }
.row-menu-item.is-danger:hover { background: color-mix(in oklab, var(--danger) 10%, var(--surface)); }

/* ---- Modals ---- */
body.modal-open { overflow: hidden; }
.modal { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 24px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(20, 26, 22, .45); backdrop-filter: blur(2px); }
.modal-card {
  position: relative; z-index: 1; width: 100%; max-width: 720px;
  max-height: calc(100vh - 48px); overflow: auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow-2);
}
.modal-card.sm { max-width: 520px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0;
  background: var(--surface); border-radius: 16px 16px 0 0;
}
.modal-head h2 { margin: 0; font-family: var(--serif); font-size: 19px; font-weight: 500; }
.modal-body { padding: 20px; }
.modal-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 16px 20px; border-top: 1px solid var(--line); position: sticky; bottom: 0;
  background: var(--surface); border-radius: 0 0 16px 16px;
}

/* Breadcrumb strip */
.crumbs {
  display: flex; align-items: center; gap: 8px;
  padding: 12px var(--pad-x);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.crumbs a { color: var(--accent); }
.crumbs .sep { color: var(--ink-4); }
.crumbs .current { color: var(--ink-2); font-weight: 500; }

/* Page surface — most pages live inside this card */
.page {
  margin: 0 var(--pad-x) 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 14px 14px;
  padding: 24px 24px 28px;
  min-height: calc(100vh - 220px);
}

/* ============ Avatars ============ */
.avatar {
  width: 34px; height: 34px; border-radius: 999px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  display: inline-grid; place-items: center;
  color: var(--accent-ink); font-weight: 600; font-size: 12px;
  flex-shrink: 0; overflow: hidden;
  position: relative;
}
.avatar.xs { width: 22px; height: 22px; font-size: 9px; }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.md { width: 40px; height: 40px; font-size: 14px; }
.avatar.lg { width: 96px; height: 96px; font-size: 32px; border: 4px solid var(--surface); box-shadow: 0 4px 14px rgba(0,0,0,.08); }

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: 9px; font-weight: 550; font-size: 13px;
  background: var(--ink); color: var(--surface);
  transition: transform .08s ease, background .15s, border-color .15s;
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn.accent { background: var(--accent); color: white; }
.btn.warn { background: var(--warn); color: white; }
.btn.danger { background: var(--danger); color: white; }
.btn.ghost {
  background: transparent; color: var(--ink-2);
  border-color: var(--line);
}
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); border-color: var(--ink-3); }
.btn.ghost.accent { color: var(--accent); border-color: color-mix(in oklab, var(--accent) 40%, var(--line)); background: transparent; }
.btn.ghost.accent:hover { background: var(--accent-2); color: var(--accent-ink); }
.btn.link { background: transparent; color: var(--accent); padding: 4px 6px; }
.btn.link:hover { background: var(--accent-2); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.lg { padding: 11px 18px; font-size: 14.5px; }
.btn.icon { width: 32px; height: 32px; padding: 0; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ============ Badges ============ */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 550;
  padding: 2px 9px; border-radius: 999px;
  background: var(--line-soft); color: var(--ink-2);
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.good   { background: color-mix(in oklab, var(--good) 14%, var(--surface)); color: var(--good); }
.badge.warn   { background: color-mix(in oklab, var(--warn) 16%, var(--surface)); color: var(--warn); }
.badge.danger { background: color-mix(in oklab, var(--danger) 14%, var(--surface)); color: var(--danger); }
.badge.info   { background: color-mix(in oklab, var(--info)  14%, var(--surface)); color: var(--info); }
.badge.accent { background: var(--accent-2); color: var(--accent-ink); }
.badge.outline { background: var(--surface); border-color: var(--line); color: var(--ink-2); }
.badge.lg { font-size: 12.5px; padding: 4px 12px; }
.badge.code { font-family: var(--mono); font-weight: 500; font-size: 11px; letter-spacing: 0.02em; }

/* ============ Cards & sections ============ */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
}
.card.tight { padding: 14px; }
.card.flat { background: var(--surface-2); }
.card-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 12px; }
.card-h h3 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -0.005em; }
.card-h .more { color: var(--ink-3); font-size: 12.5px; }

.section-h { display: flex; align-items: end; justify-content: space-between; margin: 8px 0 14px; gap: 12px; }
.section-h h2 { margin: 0; font-family: var(--serif); font-size: 20px; font-weight: 500; letter-spacing: -0.01em; }
.section-h .sub { font-size: 12.5px; color: var(--ink-3); }
.section-h::after { content: none; }

/* Section underline (like the existing "Dog List" / "Contacts" headings) */
.section-title {
  font-family: var(--serif); font-size: 22px; font-weight: 500; letter-spacing: -0.01em;
  margin: 0 0 4px;
  display: inline-block;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--accent);
}

/* ============ Grids ============ */
.grid { display: grid; gap: var(--gap); }
.g-2 { grid-template-columns: repeat(2, 1fr); }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-4 { grid-template-columns: repeat(4, 1fr); }
.g-12 { grid-template-columns: 1fr 1fr; }
.g-21 { grid-template-columns: 2fr 1fr; }
@media (max-width: 1100px) {
  .g-4 { grid-template-columns: repeat(2,1fr); }
  .g-3, .g-12, .g-21 { grid-template-columns: 1fr; }
}

/* ============ Stat tiles (dashboard) ============ */
.kpi {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 20px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  position: relative; overflow: hidden;
}
.kpi-ico {
  width: 44px; height: 44px; border-radius: 11px;
  display: grid; place-items: center;
  background: var(--accent-2); color: var(--accent-ink);
  flex-shrink: 0;
}
.kpi-ico.warn { background: color-mix(in oklab, var(--warn) 20%, var(--surface)); color: var(--warn); }
.kpi-ico.info { background: color-mix(in oklab, var(--info) 14%, var(--surface)); color: var(--info); }
.kpi-ico.danger { background: color-mix(in oklab, var(--danger) 14%, var(--surface)); color: var(--danger); }
.kpi-ico.ember { background: color-mix(in oklab, #c75d3a 18%, var(--surface)); color: #8a3919; }
.kpi-ico.plum  { background: color-mix(in oklab, #7a4ea6 18%, var(--surface)); color: #4b2870; }
.kpi-body { min-width: 0; flex: 1; }
.kpi .lbl  { font-size: 11.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.kpi .v    { font-family: var(--serif); font-size: 26px; line-height: 1.05; letter-spacing: -0.02em; margin-top: 4px; font-weight: 500; }
.kpi .delta { font-size: 11.5px; color: var(--good); margin-top: 4px; display: inline-flex; align-items: center; gap: 3px; }
.kpi .delta.down { color: var(--danger); }
.kpi .delta.flat { color: var(--ink-3); }
.kpi-spark { position: absolute; right: 0; bottom: 0; opacity: .35; }

/* ============ Tables ============ */
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.table th {
  text-align: left; font-weight: 600; font-size: 11px; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.07em;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  position: sticky; top: 0; z-index: 1;
}
.table td {
  padding: 14px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
.table tbody tr:hover td { background: var(--surface-2); }
.table tbody tr.selected td { background: color-mix(in oklab, var(--accent) 6%, var(--surface)); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }

.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.table-toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.table-toolbar .grow { flex: 1; }

/* Compact list rows */
.list-row {
  display: grid; align-items: center; gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
}
.list-row:hover { background: var(--surface-2); }
.list-row:last-child { border-bottom: 0; }

/* ============ Search / inputs ============ */
.input {
  width: 100%; padding: 9px 12px;
  border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
  outline: 0; font-size: 13.5px;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 18%, transparent);
}
.input.search-ico {
  padding-left: 34px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23828b85' stroke-width='1.8' stroke-linecap='round'><circle cx='11' cy='11' r='7'/><path d='m20 20-3.5-3.5'/></svg>");
  background-repeat: no-repeat;
  background-position: 11px center;
  background-size: 14px 14px;
}

.field { display: flex; flex-direction: column; gap: 5px; }
.field label {
  font-size: 11px; color: var(--ink-3); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.field .help { font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }
.field input, .field textarea, .field select {
  padding: 10px 12px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface);
  outline: 0; font-size: 13.5px;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 18%, transparent);
}
.field.locked input, .field.locked textarea, .field.locked select {
  background: var(--surface-3); color: var(--ink-2);
}
.field-grid { display: grid; gap: 14px; grid-template-columns: repeat(3, 1fr); }
.field-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.field-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .field-grid { grid-template-columns: 1fr 1fr; } }

/* Tabs */
.tabs {
  display: flex; gap: 4px; border-bottom: 1px solid var(--line);
  margin: -4px 0 22px; padding: 0 4px;
  overflow: auto;
}
.tabs button {
  padding: 12px 18px; font-size: 13.5px; color: var(--ink-3); font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  white-space: nowrap;
}
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

/* Section divider with title */
.sec-h {
  display: flex; align-items: baseline; gap: 12px;
  margin: 26px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.sec-h h4 {
  margin: 0; font-family: var(--serif); font-size: 16px; font-weight: 500;
  letter-spacing: -0.005em;
}
.sec-h .desc { font-size: 12px; color: var(--ink-3); }
.sec-h-accent { border-bottom: 2px solid var(--accent); padding-bottom: 6px; max-width: 240px; }

/* Photo placeholder (woven texture) */
.photo {
  background: linear-gradient(135deg, var(--accent-2), color-mix(in oklab, var(--accent) 40%, var(--surface)));
  display: grid; place-items: center;
  color: var(--accent-ink); font-family: var(--serif); font-weight: 500;
  position: relative; overflow: hidden;
}
.photo::after {
  content: ""; position: absolute; inset: 0;
  background-image: repeating-linear-gradient(135deg, rgba(0,0,0,.04) 0 2px, transparent 2px 12px);
  pointer-events: none;
}

/* Divider */
.hr { height: 1px; background: var(--line); border: 0; margin: 16px 0; }

/* Row helpers */
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 10px; }

/* Pagination */
.pager { display: flex; align-items: center; gap: 6px; }
.pager button {
  width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); font-size: 13px;
  display: grid; place-items: center;
}
.pager button:hover { background: var(--surface-2); color: var(--ink); }
.pager button.active { background: var(--accent); color: white; border-color: var(--accent); font-weight: 600; }
.pager .info { font-size: 12.5px; color: var(--ink-3); margin-right: 8px; }

/* Notice banner */
.notice {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px; border-radius: 10px;
  background: color-mix(in oklab, var(--warn) 12%, var(--surface));
  border: 1px solid color-mix(in oklab, var(--warn) 35%, var(--line));
  color: var(--ink-2); font-size: 13px;
  margin: 14px 0;
}
.notice .ico { color: var(--warn); flex-shrink: 0; margin-top: 1px; }
.notice strong { color: var(--ink); }
.notice.info {
  background: color-mix(in oklab, var(--info) 10%, var(--surface));
  border-color: color-mix(in oklab, var(--info) 30%, var(--line));
}
.notice.info .ico { color: var(--info); }
.notice.accent {
  background: var(--accent-2);
  border-color: color-mix(in oklab, var(--accent) 35%, var(--line));
}
.notice.accent .ico { color: var(--accent); }

/* Footer */
.foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px var(--pad-x);
  font-size: 12px; color: var(--ink-3);
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.foot a { color: var(--ink-2); }

/* Empty state */
.empty {
  border: 1px dashed var(--line); border-radius: 12px;
  padding: 28px; text-align: center; color: var(--ink-3); font-size: 13px;
}

/* User dropdown chip in topbar */
.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 12px 5px 5px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line);
}
.user-chip:hover { background: var(--surface-3); }
.user-chip .name { font-size: 13px; font-weight: 600; }

/* Tier medal for dogs */
.medal {
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--serif); font-size: 10px; font-weight: 600;
  color: white; text-transform: uppercase; letter-spacing: 0.04em;
  position: relative;
  background: radial-gradient(circle at 30% 30%, #f0c98a, #b07a2b 70%);
  border: 2px solid #d5a85a;
  box-shadow: inset 0 -2px 4px rgba(0,0,0,.2), 0 1px 3px rgba(0,0,0,.15);
}
.medal.silver { background: radial-gradient(circle at 30% 30%, #e9eaed, #8c9097 70%); border-color: #b8bcc1; }
.medal.platinum { background: radial-gradient(circle at 30% 30%, #cbd5dc, #5b6772 70%); border-color: #9aa5ad; }
.medal.bronze { background: radial-gradient(circle at 30% 30%, #e8b08a, #8c4c25 70%); border-color: #b87a4b; }
.medal small { font-size: 7.5px; opacity: .92; line-height: 1; margin-top: -2px; }

/* Pedigree (rose-tinted family cards) */
.ped-card {
  border-radius: 14px; padding: 16px;
  text-align: center;
  border: 1px solid var(--line);
}
.ped-card.dam  { background: linear-gradient(180deg, #fbe4ee, #f4d3e3); border-color: #ecc3d4; }
.ped-card.sire { background: linear-gradient(180deg, #d8eef0, #c4e3e6); border-color: #b7d6da; }
.ped-card.self { background: var(--surface); border-color: var(--line); }
.ped-photo {
  width: 88px; height: 88px; border-radius: 50%;
  margin: 4px auto 10px;
  background: var(--surface); border: 3px solid white;
  display: grid; place-items: center;
  color: var(--ink-3); font-family: var(--serif); font-size: 22px;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
  overflow: hidden;
}
.ped-name { font-family: var(--serif); font-size: 16px; font-weight: 500; margin-bottom: 8px; color: var(--ink); }
.ped-meta { font-size: 11.5px; color: var(--ink-2); line-height: 1.5; }

/* 4-generation pedigree tree */
.ped-tree {
  display: grid; grid-template-columns: repeat(5, 1fr);
  grid-template-rows: auto repeat(16, 1fr); gap: 6px;
  min-height: 520px; overflow-x: auto;
}
.ped-tree-head {
  grid-row: 1; text-align: center; font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); padding-bottom: 4px;
}
.ped-tree-cell {
  display: flex; flex-direction: column; justify-content: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px; min-width: 130px;
}
.ped-tree-cell.is-empty { background: var(--surface-2); border-style: dashed; }
.ped-tree-role { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 600; }
.ped-tree-name { font-family: var(--serif); font-size: 14px; font-weight: 500; color: var(--ink); margin-top: 2px; }
.ped-tree-meta { font-size: 11px; color: var(--ink-2); margin-top: 2px; }

/* Cover banner with overlap avatar (contact details page) */
.cover {
  height: 200px; border-radius: 14px;
  background: linear-gradient(135deg, var(--accent-2), color-mix(in oklab, var(--accent) 50%, var(--surface)));
  position: relative; overflow: hidden;
  margin-bottom: 60px;
}
.cover::after {
  content: ""; position: absolute; inset: 0;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,.4), transparent 40%),
    repeating-linear-gradient(135deg, rgba(0,0,0,.03) 0 2px, transparent 2px 18px);
}
.cover-avatar {
  position: absolute; left: 50%; bottom: -50px; transform: translateX(-50%);
  width: 110px; height: 110px; border-radius: 50%;
  border: 5px solid var(--surface);
  background: var(--accent-2);
  display: grid; place-items: center;
  color: var(--accent-ink); font-family: var(--serif); font-size: 36px;
  box-shadow: 0 6px 18px rgba(0,0,0,.10);
  overflow: hidden;
  z-index: 3;
}

/* Toolbar / editor surface */
.editor {
  border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
}
.editor-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px;
  padding: 6px 8px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.tb-btn {
  width: 30px; height: 30px; border-radius: 7px;
  display: inline-grid; place-items: center;
  color: var(--ink-2); font-size: 13px;
}
.tb-btn:hover { background: var(--line-soft); color: var(--ink); }
.tb-sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.tb-select {
  height: 30px; padding: 0 10px;
  border-radius: 7px; font-size: 12.5px;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--ink-2);
}
.editor-body {
  padding: 18px 22px;
  min-height: 360px;
  font-size: 14px; color: var(--ink); line-height: 1.65;
}
.editor-body h2 { font-family: var(--serif); font-size: 22px; font-weight: 500; margin: 0 0 14px; letter-spacing: -0.01em; }
.editor-body h3 { font-size: 15px; font-weight: 600; margin: 18px 0 8px; }
.editor-body p  { margin: 0 0 10px; }
.editor-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px;
  background: var(--surface-2);
  border-top: 1px solid var(--line);
  font-size: 11.5px; color: var(--ink-3);
}

/* Drop zone */
.drop {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px;
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink-3); font-size: 13px;
}
.drop:hover { border-color: var(--accent); color: var(--ink-2); }

/* Pet hero (info page) */
.pet-hero {
  display: flex; align-items: center; gap: 22px;
  padding: 22px;
  background: linear-gradient(135deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line); border-radius: 14px;
  margin-bottom: 22px;
}
.pet-hero .photo-lg {
  width: 116px; height: 116px; border-radius: 50%;
  border: 4px solid var(--surface);
  box-shadow: 0 4px 14px rgba(0,0,0,.08);
  flex-shrink: 0;
}
.pet-hero h1 { margin: 0; font-family: var(--serif); font-size: 32px; font-weight: 500; letter-spacing: -0.02em; }
.pet-hero .meta { font-size: 13px; color: var(--ink-3); margin-top: 4px; }

/* small chip with icon for filters */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 12.5px; color: var(--ink-2);
}
.chip:hover { background: var(--surface-3); }
.chip.active { background: var(--accent-2); color: var(--accent-ink); border-color: color-mix(in oklab, var(--accent) 35%, var(--line)); }

/* ============================================================
   Staff portal additions (not in the static design prototype):
   auth card, account dropdown, toasts, tabs/hidden plumbing,
   and responsive rail behaviour.
   ============================================================ */

[hidden] { display: none !important; }

/* Brand mark + tiles are real links here, not buttons */
a.brand-mark, a.brand-mark:hover,
a.quick-btn, a.quick-btn:hover,
a.rail-item, a.rail-item:hover { text-decoration: none; }
a.user-tile { text-decoration: none; color: inherit; }

/* ---- Auth / login ---- */
.auth-wrap {
  min-height: 100vh; display: grid; place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 18% 22%, color-mix(in oklab, var(--accent) 14%, transparent), transparent 42%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 36px 34px;
  box-shadow: var(--shadow-2);
}
.auth-card .brand {
  display: inline-flex; align-items: center; gap: 12px;
  margin-bottom: 26px; text-decoration: none; color: var(--ink);
}
.auth-card .brand .brand-mark { width: 40px; height: 40px; border-radius: 11px; font-size: 21px; }
.auth-card .brand .brand-name { font-family: var(--serif); font-size: 22px; letter-spacing: -0.01em; }
.auth-card .brand .brand-name .dot { color: var(--accent); }
/* Stacked lockup logo above the login form */
.auth-card .brand-lockup { display: block; margin: 0 auto 22px; }
.auth-logo { display: block; width: 240px; max-width: 100%; height: auto; margin: 0 auto; }
/* App-icon variant of the brand mark (sage icon instead of the "P") */
.brand-mark--icon { background: none; padding: 0; box-shadow: none; overflow: hidden; }
.brand-mark--icon img { width: 100%; height: 100%; display: block; }
.auth-card h2 {
  font-family: var(--serif); font-size: 26px; font-weight: 500;
  letter-spacing: -0.015em; margin: 0 0 6px;
}
.auth-card .lead { color: var(--ink-3); font-size: 13.5px; margin: 0 0 24px; }
.auth-card .field { margin-bottom: 16px; }
.auth-card .field input { width: 100%; }
.auth-card .btn.full { width: 100%; justify-content: center; margin-top: 6px; }
.auth-card .auth-foot { margin-top: 18px; font-size: 12.5px; color: var(--ink-3); text-align: center; }
.auth-card .auth-note {
  margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line);
  font-size: 11.5px; color: var(--ink-3); text-align: center;
}

/* ---- Account dropdown in the topbar ---- */
.user-menu { position: relative; }
.user-menu > summary { list-style: none; cursor: pointer; }
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 60;
  min-width: 220px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow-2);
}
.user-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: 9px; font-size: 13px;
  color: var(--ink-2); width: 100%; text-align: left; text-decoration: none;
}
.user-menu-item:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.user-menu-item.is-danger { color: var(--danger); }
.user-menu-item.is-danger:hover { background: color-mix(in oklab, var(--danger) 10%, var(--surface)); }

/* ---- Toasts ---- */
.toast-wrap {
  position: fixed; right: 18px; bottom: 18px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 11px 15px; border-radius: 10px; font-size: 13px; font-weight: 500;
  background: var(--ink); color: var(--surface);
  box-shadow: var(--shadow-2); transition: opacity .25s, transform .25s;
  max-width: 340px;
}
.toast.success { background: var(--accent); }
.toast.error   { background: var(--danger); }

/* ---- Spinner ---- */
.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .6s linear infinite; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Tab panels (JS-driven) ---- */
.tab-panel[hidden] { display: none !important; }

/* ---- Rail toggle on small screens ---- */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .rail {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 80;
    width: 240px; transform: translateX(-100%); transition: transform .2s ease;
  }
  .app.rail-open .rail { transform: translateX(0); }
  .rail-backdrop { position: fixed; inset: 0; background: rgba(20,28,24,.4); z-index: 70; }
  .topbar { padding-top: 12px; }
}
.rail-mobile-btn {
  display: none;
  width: 36px; height: 36px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface);
  place-items: center; color: var(--ink-2); margin-right: 4px;
}
@media (max-width: 860px) { .rail-mobile-btn { display: grid; } }
