/* singlesdb — internal admin. One hand-written sheet, no build step.
   Utilitarian: dense tables, 13px system stack, flat surfaces, no pills. */

:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --line: #dde1e6;
  --text: #1b2330;
  --muted: #6a7383;
  --accent: #2559d4;
  --accent-ink: #ffffff;
  --danger: #b3261e;
  --good: #1a7f37;
  --warn: #9a6700;
  --side: #1a222e;
  --side-text: #c7cdd6;
  --side-active: #ffffff;
  --radius: 4px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.shell {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--side);
  color: var(--side-text);
  display: flex;
  flex-direction: column;
  padding: 0.75rem 0;
  position: sticky;
  top: 0;
  height: 100vh;
}

.side-brand {
  color: var(--side-active);
  font-weight: 700;
  font-size: 15px;
  padding: 0.25rem 1rem 0.75rem;
  display: block;
}
.side-brand:hover { text-decoration: none; }
.side-brand small {
  display: block;
  font-weight: 400;
  font-size: 11px;
  color: var(--side-text);
}

.side-nav { display: flex; flex-direction: column; flex: 1; }
.side-nav .nav-group {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8b93a3;
  padding: 0.9rem 1rem 0.25rem;
}
.side-nav a {
  color: var(--side-text);
  padding: 0.3rem 1rem;
  display: block;
}
.side-nav a:hover { color: var(--side-active); text-decoration: none; }
.side-nav a.active {
  color: var(--side-active);
  background: rgba(255, 255, 255, 0.08);
  border-left: 3px solid var(--accent);
  padding-left: calc(1rem - 3px);
}

.side-foot {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding: 0.75rem 1rem 0.25rem;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.side-user {
  color: #8b93a3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.side-foot .side-link { color: var(--side-text); }
.side-foot .side-link:hover { color: var(--side-active); }

.main { padding: 1.25rem 1.5rem 3rem; max-width: 1200px; }

/* login and other signed-out pages */
.auth-main { max-width: 360px; margin: 12vh auto 0; padding: 0 1rem; }

/* ---------- page head ---------- */

.breadcrumbs { font-size: 12px; color: var(--muted); margin-bottom: 0.25rem; }
.breadcrumbs a { color: var(--muted); }
.crumb-sep { margin: 0 0.35rem; color: var(--line); }
.crumb-here { color: var(--muted); }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.page-head h1 { margin: 0; font-size: 20px; }
.page-head .lede { margin: 0.15rem 0 0; color: var(--muted); }
.page-actions { display: flex; gap: 0.5rem; align-items: center; }

/* underline tabs — never pills */
.subnav {
  display: flex;
  gap: 1.25rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1rem;
}
.subnav a {
  color: var(--muted);
  padding: 0.35rem 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.subnav a:hover { text-decoration: none; color: var(--text); }
.subnav a.on { color: var(--text); border-bottom-color: var(--accent); }

/* ---------- flash ---------- */

.flash {
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  margin: 0 0 1rem;
  border: 1px solid;
}
.flash-error { background: #fdecea; border-color: #f5c6c0; color: var(--danger); }
.flash-info { background: #e8f0fe; border-color: #c4d5f7; color: var(--accent); }

/* ---------- panels ---------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.panel-body { padding: 0.75rem; }
.panel-body > :first-child { margin-top: 0; }
.panel-body > :last-child { margin-bottom: 0; }

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

.table-scroll { overflow-x: auto; }

table.data {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
}
.panel table.data { border: 0; }
table.data th, table.data td {
  text-align: left;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  white-space: nowrap;
}
table.data td.wrap, table.data th.wrap { white-space: normal; }
table.data th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
}
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: #f8f9fb; }
table.data td.num, table.data th.num { text-align: right; }

.thumb {
  width: 32px;
  height: 44px;
  object-fit: cover;
  border-radius: 2px;
  display: block;
  background: var(--bg);
}

/* ---------- badges & chips ---------- */

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 0.05rem 0.4rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--bg);
}
.badge-good { color: var(--good); border-color: #b6dfc2; background: #ebf7ee; }
.badge-warn { color: var(--warn); border-color: #ecd9a7; background: #fdf6e3; }
.badge-bad { color: var(--danger); border-color: #f5c6c0; background: #fdecea; }

.muted { color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); }
.empty { color: var(--muted); padding: 1.25rem 0.5rem; text-align: center; }

/* ---------- buttons & forms ---------- */

.btn {
  display: inline-block;
  font: inherit;
  padding: 0.35rem 0.8rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { border-color: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--danger); border-color: #f5c6c0; }
.btn-sm { padding: 0.15rem 0.5rem; font-size: 12px; }

.link-button {
  font: inherit;
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  cursor: pointer;
  text-align: left;
}
.sidebar .link-button { color: var(--side-text); }
.sidebar .link-button:hover { color: var(--side-active); }
.main .link-button { color: var(--accent); }
.main .link-button:hover { text-decoration: underline; }
.link-button.danger { color: var(--danger); }

.inline-form { display: inline; }

label.field { display: block; margin-bottom: 0.75rem; font-weight: 600; }
label.field input, label.field select, label.field textarea {
  display: block;
  width: 100%;
  margin-top: 0.2rem;
  font: inherit;
  font-weight: 400;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
}
label.field input:focus, label.field select:focus, label.field textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}
label.field .hint { font-weight: 400; display: block; margin-top: 0.15rem; }

.row-form { display: flex; gap: 0.75rem; align-items: flex-end; flex-wrap: wrap; }
.row-form label.field { margin-bottom: 0; flex: 1; min-width: 8rem; }
.row-form .grow-2 { flex: 2; }
.row-form .shrink { flex: 0 0 auto; min-width: 0; }

.form-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  max-width: 480px;
}
.form-card.wide { max-width: 720px; }
.form-card h2 { margin: 0 0 0.75rem; font-size: 16px; }
.form-actions { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.75rem; }

/* ---------- stats ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
}
.stat .stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  display: block;
}
.stat .stat-value { font-size: 20px; font-weight: 700; }
.stat .stat-sub { font-size: 12px; color: var(--muted); }

/* ---------- card search (intake) ---------- */

.card-search { position: relative; }
.card-search input[type="search"] {
  width: 100%;
  font: inherit;
  font-size: 15px;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.card-search input[type="search"]:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.search-results { list-style: none; margin: 0.5rem 0 0; padding: 0; }
.search-results li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.25rem;
  border-bottom: 1px solid var(--line);
}
.search-results li:last-child { border-bottom: 0; }
.search-results .result-name { font-weight: 600; }
.search-results .result-meta { color: var(--muted); font-size: 12px; }
.search-results .result-main { flex: 1; min-width: 0; }
.search-results .result-actions { display: flex; gap: 0.35rem; flex: 0 0 auto; }

details.manual-entry { margin-top: 0.75rem; }
details.manual-entry summary { cursor: pointer; color: var(--muted); }
details.manual-entry[open] summary { margin-bottom: 0.5rem; }

/* ---------- batch placement picker ---------- */

table.placement td { padding: 0.25rem 0.35rem; }
.place-cell {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
}
.place-cell:hover { border-color: var(--muted); }
.place-cell.warn { border-color: #ecd9a7; background: #fdf6e3; }
.place-cell input[type="radio"] { accent-color: var(--accent); margin-right: 0.25rem; }
.place-cell:has(input:checked) {
  border-color: var(--accent);
  outline: 1px solid var(--accent);
}

/* ---------- guides ---------- */

.guide-list { list-style: none; margin: 0; padding: 0; }
.guide-list li { padding: 0.35rem 0; border-bottom: 1px solid var(--line); }
.guide-list li:last-child { border-bottom: 0; }

.guide-body {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  max-width: 46rem;
  font-size: 14px;
}
.guide-body h1 { font-size: 20px; margin: 0 0 0.75rem; }
.guide-body h2 {
  font-size: 15px;
  margin: 1.5rem 0 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}
.guide-body h3 { font-size: 14px; margin: 1rem 0 0.35rem; }
.guide-body p, .guide-body li { line-height: 1.65; }
.guide-body ul, .guide-body ol { padding-left: 1.4rem; }
.guide-body li { margin-bottom: 0.3rem; }
.guide-body code {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.05rem 0.3rem;
  font-size: 12px;
}
.guide-body blockquote {
  margin: 0.75rem 0;
  padding: 0.25rem 0.9rem;
  border-left: 3px solid var(--line);
  color: var(--muted);
}

/* ---------- pagination ---------- */

.pager { display: flex; gap: 0.75rem; align-items: center; margin-top: 0.75rem; }
.pager .muted { font-size: 12px; }

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

@media (max-width: 900px) {
  .shell { display: block; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding: 0.5rem 0.75rem;
  }
  .side-brand { padding: 0.25rem 0.5rem; }
  .side-brand small { display: none; }
  .side-nav { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .side-nav .nav-group { display: none; }
  .side-nav a.active { border-left: 0; border-bottom: 2px solid var(--accent); padding: 0.3rem 0.5rem; }
  .side-nav a { padding: 0.3rem 0.5rem; }
  .side-foot { border-top: 0; flex-direction: row; gap: 0.75rem; padding: 0.25rem 0.5rem; }
  .side-user { display: none; }
  .main { padding: 1rem; }
}

@media (max-width: 600px) {
  input, select, textarea { font-size: 16px !important; } /* stop iOS zoom */
}
