/* ==========================================================================
   Animal Talent — design system
   One palette, one type scale, one set of components. Each tab (Cats / Dogs /
   Other) re-themes a single --accent token rather than looking like a different
   application.
   ========================================================================== */

:root {
  /* neutrals */
  --bg: #f7f8fa;
  --panel: #ffffff;
  --ink: #16202c;
  --ink-2: #475569;
  --muted: #7b8794;
  --line: #e6e9ef;
  --line-2: #f1f3f7;

  /* brand + default accent (overridden per tab) */
  --brand: #0f5132;
  --accent: #0f766e;
  --accent-soft: #f0fdfa;
  --accent-ink: #115e59;

  /* semantic */
  --ok: #15803d; --ok-soft: #f0fdf4;
  --warn: #b45309; --warn-soft: #fffbeb;
  --danger: #be123c; --danger-soft: #fff1f2;
  --info: #1d4ed8; --info-soft: #eff6ff;

  --topbar-h: 57px;   /* height of the sticky top nav — used for sticky offsets & scroll-margin */
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-1: 0 1px 2px rgba(16,32,44,.04), 0 1px 3px rgba(16,32,44,.06);
  --shadow-2: 0 4px 16px rgba(16,32,44,.08);
}

/* per-tab identity — one token swap, same components */
.theme-cat   { --accent: #7c3aed; --accent-soft: #f6f3ff; --accent-ink: #5b21b6; }
.theme-dog   { --accent: #c2410c; --accent-soft: #fff5ed; --accent-ink: #9a3412; }
.theme-other { --accent: #0e7490; --accent-soft: #ecfeff; --accent-ink: #155e75; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.55 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; letter-spacing: -.01em; }
h3 { font-size: .95rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .82rem; word-break: break-all; }

/* ---------------------------------------------------------------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: #fff; border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(16,32,44,.02);
}
.topbar-in {
  max-width: 1280px; margin: 0 auto; padding: 0 1.25rem;
  display: flex; align-items: center; gap: .35rem; height: 56px;
}
.brand {
  font-weight: 700; letter-spacing: -.02em; color: var(--ink);
  margin-right: 1rem; display: flex; align-items: center; gap: .5rem; white-space: nowrap;
}
.brand .dot { width: 26px; height: 26px; border-radius: 8px; background: var(--brand);
              display: grid; place-items: center; font-size: .9rem; }
.navlink {
  padding: .45rem .7rem; border-radius: var(--radius-sm); color: var(--ink-2);
  font-weight: 550; font-size: .9rem; white-space: nowrap;
}
.navlink:hover { background: var(--line-2); text-decoration: none; color: var(--ink); }
.navlink.on { background: var(--accent-soft); color: var(--accent-ink); }
.navlink .ico { margin-right: .35rem; }
.spacer { flex: 1; }
.who { font-size: .82rem; color: var(--muted); }

.container { max-width: 1280px; margin: 1.5rem auto 3rem; padding: 0 1.25rem; }

/* ---------------------------------------------------------------- surfaces */
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-1);
  padding: 1.1rem 1.25rem; margin-bottom: 1.25rem;
}
.panel.flush { padding: 0; overflow: hidden; }

/* page hero — carries the tab identity */
.hero {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  background: linear-gradient(180deg, var(--accent-soft), #fff 140%);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.25rem; margin-bottom: 1rem;
}
.hero .avatar {
  width: 46px; height: 46px; border-radius: 12px; background: var(--accent);
  display: grid; place-items: center; font-size: 1.4rem; box-shadow: var(--shadow-1);
}
.hero h1 { color: var(--accent-ink); }
.hero .sub { color: var(--ink-2); font-size: .875rem; }
.hero .spacer { flex: 1; }
.hero-stats { display: flex; gap: 1.5rem; }
.hero-stats div { text-align: right; }
.hero-stats .n { font-size: 1.35rem; font-weight: 700; letter-spacing: -.02em; }
.hero-stats .l { font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

/* ---------------------------------------------------------------- sub nav */
.subnav { display: flex; gap: .25rem; margin: 0 0 1.25rem; }
.subnav a {
  padding: .4rem .85rem; border-radius: 999px; color: var(--ink-2);
  font-weight: 550; font-size: .875rem; border: 1px solid transparent;
}
.subnav a:hover { background: #fff; border-color: var(--line); text-decoration: none; }
.subnav a.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.subnav a.on .n { color: rgba(255,255,255,.75); }
.subnav .n { color: var(--muted); font-weight: 500; margin-left: .3rem; }

/* ---------------------------------------------------------------- stats */
.grid { display: grid; gap: 1rem; }
.stats { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .9rem 1rem; box-shadow: var(--shadow-1); display: block;
}
a.stat:hover { border-color: var(--accent); box-shadow: var(--shadow-2); text-decoration: none; transform: translateY(-1px); }
a.stat { transition: box-shadow .15s, transform .15s, border-color .15s; }
.stat .n { font-size: 1.7rem; font-weight: 700; letter-spacing: -.03em; color: var(--ink); }
.stat .l { color: var(--muted); font-size: .8rem; }
.stat.attn .n { color: var(--warn); }
.stat.bad .n { color: var(--danger); }

/* big tab cards on the dashboard */
.tabcards { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.tabcard {
  display: block; padding: 1.15rem 1.25rem; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow-1);
  transition: box-shadow .15s, transform .15s, border-color .15s;
}
.tabcard:hover { text-decoration: none; box-shadow: var(--shadow-2); transform: translateY(-2px); border-color: var(--accent); }
.tabcard .top { display: flex; align-items: center; gap: .65rem; margin-bottom: .85rem; }
.tabcard .ic { width: 38px; height: 38px; border-radius: 10px; background: var(--accent);
               display: grid; place-items: center; font-size: 1.15rem; }
.tabcard .name { font-weight: 650; color: var(--ink); letter-spacing: -.01em; }
.tabcard .n { font-size: 2rem; font-weight: 700; letter-spacing: -.03em; color: var(--accent-ink); line-height: 1; }
.tabcard .l { font-size: .78rem; color: var(--muted); }
.tabcard .meta { display: flex; gap: 1.25rem; margin-top: .75rem; padding-top: .75rem; border-top: 1px solid var(--line-2); }
.tabcard .meta div { font-size: .8rem; color: var(--ink-2); }
.tabcard .meta b { display: block; font-size: .95rem; color: var(--ink); }

/* ---------------------------------------------------------------- bars */
.bars { display: grid; gap: .5rem; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 42px; align-items: center; gap: .6rem; font-size: .85rem; }
.bar-row .k { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .track { background: var(--line-2); border-radius: 999px; height: 8px; overflow: hidden; }
.bar-row .fill { background: var(--accent); height: 100%; border-radius: 999px; }
.bar-row .v { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius);
              box-shadow: var(--shadow-1); background: var(--panel); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
th { background: #fbfcfd; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
     color: var(--muted); font-weight: 650; position: sticky; top: var(--topbar-h); z-index: 20; border-bottom: 1px solid var(--line); }
/* Anchored navigation / scroll-into-view must clear the sticky top nav so a row's
   controls (e.g. the first Approve button) are never hidden underneath it. */
:target, .panel, tbody tr { scroll-margin-top: calc(var(--topbar-h) + 14px); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--accent-soft); }
td.nowrap, th.nowrap { white-space: nowrap; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- chips */
.chip { display: inline-block; padding: .1rem .5rem; border-radius: 999px; background: var(--line-2);
        color: var(--ink-2); font-size: .74rem; margin: .1rem .15rem .1rem 0; white-space: nowrap; }
.chip.skill { background: var(--ok-soft); color: #14532d; }
.chip.trait { background: var(--info-soft); color: #1e3a8a; }
.chip.warning { background: var(--danger-soft); color: #9f1239; }
.chip.compliance { background: var(--warn-soft); color: #92400e; }
.chip.marketing { background: #fdf4ff; color: #86198f; }
.chip.source_view { background: var(--line-2); color: var(--ink-2); }
.chip.accent { background: var(--accent-soft); color: var(--accent-ink); }

.badge { display: inline-block; padding: .12rem .5rem; border-radius: 6px; font-size: .73rem; font-weight: 600; }
.badge.status-active, .badge.status-imported, .badge.status-accepted, .badge.status-confirmed { background: var(--ok-soft); color: #14532d; }
.badge.status-lead, .badge.status-sent, .badge.status-draft, .badge.status-viewed { background: var(--info-soft); color: #1e3a8a; }
.badge.status-needs_review, .badge.status-duplicate_candidate, .badge.status-question, .badge.status-pending { background: var(--warn-soft); color: #92400e; }
.badge.status-removed, .badge.status-error, .badge.status-declined, .badge.status-cancelled, .badge.status-archived { background: var(--danger-soft); color: #9f1239; }
.badge.status-off_site, .badge.status-under_the_counter, .badge.status-skipped, .badge.status-completed { background: var(--line-2); color: var(--ink-2); }

/* count pill (skills / traits in a compact table) */
.countpill { display: inline-grid; place-items: center; min-width: 26px; height: 22px; padding: 0 .4rem;
             border-radius: 999px; font-size: .78rem; font-weight: 650;
             background: var(--accent-soft); color: var(--accent-ink); font-variant-numeric: tabular-nums; }
.countpill.zero { background: var(--line-2); color: var(--muted); font-weight: 500; }

/* ---------------------------------------------------------------- forms */
input[type=text], input[type=email], input[type=password], input[type=search], select, textarea {
  width: 100%; padding: .48rem .6rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
  font: inherit; background: #fff; color: var(--ink); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { min-height: 70px; resize: vertical; }
label { display: block; font-size: .76rem; color: var(--muted); margin: 0 0 .25rem; font-weight: 550;
        text-transform: uppercase; letter-spacing: .04em; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: .7rem .8rem; align-items: end; }

.btn { display: inline-block; padding: .45rem .85rem; border-radius: var(--radius-sm); border: 1px solid var(--line);
       background: #fff; color: var(--ink); cursor: pointer; font: inherit; font-weight: 550; font-size: .875rem; }
.btn:hover { background: var(--line-2); text-decoration: none; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { filter: brightness(.93); }
.btn.danger { background: #fff; color: var(--danger); border-color: #fecdd3; }
.btn.sm { padding: .25rem .55rem; font-size: .8rem; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* multi-select disclosure (skills / traits) */
.multi { position: relative; }
.multi > summary {
  list-style: none; cursor: pointer; padding: .48rem .6rem; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: #fff; font-size: .875rem;
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
}
.multi > summary::-webkit-details-marker { display: none; }
.multi > summary:hover { border-color: var(--accent); }
.multi[open] > summary { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.multi > summary .caret { color: var(--muted); font-size: .7rem; }
.multi-panel {
  position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; width: 280px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-2); padding: .5rem;
}
.multi-list { max-height: 240px; overflow: auto; margin-top: .4rem; }
.multi-list label {
  display: flex; align-items: center; gap: .5rem; padding: .25rem .35rem; border-radius: 6px;
  text-transform: none; letter-spacing: 0; font-size: .85rem; color: var(--ink); font-weight: 400; margin: 0;
  cursor: pointer;
}
.multi-list label:hover { background: var(--accent-soft); }
.multi-list input[type=checkbox] { width: auto; margin: 0; accent-color: var(--accent); }
.sel-count { background: var(--accent); color: #fff; border-radius: 999px; padding: 0 .4rem; font-size: .72rem; font-weight: 650; }

/* ---------------------------------------------------------------- misc */
.cols { display: grid; grid-template-columns: 2fr 1fr; gap: 1.25rem; }
@media (max-width: 900px) { .cols { grid-template-columns: 1fr; } }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: .1rem .75rem; }
.kv .k { color: var(--muted); font-size: .8rem; padding: .35rem 0; }
.kv .v { padding: .2rem 0; }
.field-row { display: flex; align-items: flex-start; gap: .4rem; }
.field-row .val { flex: 1; }
.edit-link { visibility: hidden; color: var(--accent); }
.kv .v:hover .edit-link, .field-row:hover .edit-link { visibility: visible; }

.pagination { display: flex; gap: .5rem; align-items: center; margin-top: .85rem; }
.notice { padding: .65rem .85rem; border-radius: var(--radius-sm); margin-bottom: .85rem; font-size: .9rem; }
.notice.err { background: var(--danger-soft); color: #9f1239; border: 1px solid #fecdd3; }
.notice.ok { background: var(--ok-soft); color: #14532d; border: 1px solid #bbf7d0; }
.notice.warn { background: var(--warn-soft); color: #92400e; border: 1px solid #fde68a; }

.trunc { cursor: help; border-bottom: 1px dotted var(--muted); }

/* under-the-counter animals in red */
tr.utc td { color: var(--danger); }
a.utc-link, a.utc-link strong { color: var(--danger); }
.badge.utc-badge { background: var(--danger-soft); color: #9f1239; }

.talent-item { display: flex; gap: .5rem; align-items: center; padding: .3rem .4rem; border-radius: 6px; cursor: pointer; }
.talent-item:hover { background: var(--accent-soft); }
.talent-item input[type=checkbox] { width: auto; margin: 0; accent-color: var(--accent); }

/* owner (mobile) page */
.owner-wrap { max-width: 560px; margin: 0 auto; padding: 1rem; }
.owner-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-1); padding: 1.1rem 1.2rem; margin-bottom: 1rem; }
.owner-hero { background: var(--brand); color: #fff; border-radius: 14px; padding: 1.2rem; margin-bottom: 1rem; }
.owner-hero h1 { margin: 0; font-size: 1.35rem; color: #fff; }
.actions-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .5rem; }
@media (max-width: 420px) { .actions-3 { grid-template-columns: 1fr; } }
