* { box-sizing: border-box; margin: 0; padding: 0; }

/* Self-hosted rather than pulled from a font CDN on every load. Same type
   system as the Design site, copied over font-for-font. */
@font-face {
  font-family: 'Bebas Neue'; font-style: normal; font-weight: 400;
  font-display: swap; src: url('/fonts/bebas-neue-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 400;
  font-display: swap; src: url('/fonts/inter-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 500;
  font-display: swap; src: url('/fonts/inter-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 600;
  font-display: swap; src: url('/fonts/inter-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 700;
  font-display: swap; src: url('/fonts/inter-700.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 500;
  font-display: swap; src: url('/fonts/ibm-plex-mono-500.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 600;
  font-display: swap; src: url('/fonts/ibm-plex-mono-600.woff2') format('woff2');
}

/* Same design tokens as the Design site (mollys-design-site/public/styles.css)
   so the two admin tools read as one family. */
:root {
  --paper: #f3f5f7;
  --card: #ffffff;
  --ink: #384959;
  --muted: #6b7c8c;
  --line: #e3e7eb;
  --line-strong: #c2cbd3;

  --accent: #384959;
  --accent-dark: #24303b;
  --accent-tint: #e3effb;

  --stamp: #3f5b78;
  --stamp-tint: #bdddfc;

  --highlight: #88bdf2;

  --danger: #a8281c;
  --danger-dark: #841e15;

  --nav-height: 58px;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-pill: 999px;
  --shadow: 0 1px 2px rgba(30, 41, 59, 0.04), 0 2px 8px rgba(30, 41, 59, 0.04);
  --shadow-lift: 0 6px 16px rgba(56, 73, 89, 0.12), 0 16px 34px rgba(56, 73, 89, 0.1);

  --font-display: 'Bebas Neue', 'Arial Narrow', sans-serif;
  --font-body: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
}

body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

p { line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.icon { width: 14px; height: 14px; flex-shrink: 0; vertical-align: -2px; }

/* ---- nav ---- */
nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 20px;
  padding-top: env(safe-area-inset-top);
  flex-wrap: nowrap;
}
nav .brand {
  font-family: var(--font-display);
  font-size: 24px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 13px 18px 13px 0;
  order: 1;
}
nav .nav-links {
  display: flex; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
  order: 2; scrollbar-width: none;
}
nav .nav-links::-webkit-scrollbar { display: none; }
nav a {
  color: rgba(255, 255, 255, 0.85);
  padding: 14px 12px;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  flex: 0 0 auto;
}
nav a:hover { color: #fff; background: rgba(0, 0, 0, 0.16); text-decoration: none; }
nav a.active { color: #fff; background: rgba(0, 0, 0, 0.16); text-decoration: none; box-shadow: inset 0 -3px 0 var(--highlight); }
nav .spacer { flex: 1; order: 3; min-width: 8px; }
nav .nav-actions { display: flex; align-items: center; gap: 6px; order: 4; position: relative; }
nav button {
  background: none; border: 1px solid rgba(255, 255, 255, 0.45); color: #fff;
  padding: 6px 12px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px;
  font-weight: 600; letter-spacing: 0.02em;
}
nav button:hover { background: rgba(0, 0, 0, 0.16); }

nav .icon-btn {
  display: flex; align-items: center; justify-content: center; position: relative;
  width: 34px; height: 34px; padding: 0; flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.45); border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.9); background: none; cursor: pointer;
}
nav .icon-btn:hover { color: #fff; background: rgba(0, 0, 0, 0.16); }
nav .icon-btn.active { color: #fff; background: rgba(0, 0, 0, 0.16); box-shadow: inset 0 -3px 0 var(--highlight); }
nav .icon-btn .icon { width: 18px; height: 18px; }

nav .avatar-initial {
  display: flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--highlight); color: var(--accent-dark);
  font-family: var(--font-display); font-size: 13px; letter-spacing: 0.02em;
}

nav .nav-menu-panel {
  display: none; flex-direction: column; position: absolute; top: calc(100% + 8px); right: 0;
  min-width: 210px; padding: 6px; margin: 0; background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow-lift); z-index: 60;
}
nav .nav-menu-panel.open { display: flex; }
nav .nav-menu-panel a,
nav .nav-menu-panel button {
  display: flex; align-items: center; gap: 9px; padding: 10px 10px; border-radius: var(--radius-sm);
  color: var(--ink); font-size: 13.5px; font-weight: 600; letter-spacing: normal;
  width: 100%; background: none; border: none; text-align: left; cursor: pointer;
}
nav .nav-menu-panel a .icon { color: var(--muted); }
nav .nav-menu-panel a:hover,
nav .nav-menu-panel button:hover { background: var(--paper); color: var(--ink); }
nav .nav-menu-label {
  padding: 8px 10px 10px; font-size: 12.5px; color: var(--muted); font-weight: 600;
  border-bottom: 1px solid var(--line); margin-bottom: 4px;
}

main { max-width: 1180px; margin: 0 auto; padding: 28px 20px 60px; }
h1 {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 400;
  letter-spacing: 0.015em;
  text-transform: uppercase;
  line-height: 1.15;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
h2 {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--stamp);
  margin: 30px 0 12px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
h2 .icon { color: var(--stamp); }

/* ---- cards, tiles & tables ---- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.card.clickable { cursor: pointer; transition: box-shadow 0.12s ease, border-color 0.12s ease; }
.card.clickable:hover { border-color: var(--line-strong); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06); }

.tiles-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 22px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.tile {
  padding: 18px 20px;
  display: flex; align-items: center; gap: 12px;
  border-right: 1px solid var(--line);
}
.tile:last-child { border-right: none; }
.tile .tile-icon { width: 38px; height: 38px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; background: var(--accent-tint); color: var(--accent); flex-shrink: 0; }
.tile .tile-icon .icon { width: 18px; height: 18px; }
.tile.warn .tile-icon { background: #f7ded9; color: var(--danger); }
.tile .n { font-family: var(--font-display); font-size: 30px; letter-spacing: 0.01em; line-height: 1.1; }
.tile .t { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.tile.warn .n { color: var(--danger); }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); border: 1px solid var(--line); }
.table-scroll table { box-shadow: none; border: none; border-radius: 0; }
table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
th, td { text-align: left; padding: 13px 14px; font-size: 14px; border-bottom: 1px solid var(--line); }
th {
  background: var(--card); font-family: var(--font-mono); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); font-weight: 600;
  border-bottom: 1px solid var(--line-strong);
}
tr:last-child td { border-bottom: none; }
tr { transition: background-color 0.12s ease; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--paper); }
tr.clickable:active td { background: var(--paper); }

/* ---- badges: outlined pills, not filled tiles ---- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px;
  border-radius: var(--radius-pill); font-family: var(--font-mono); font-size: 11px;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap;
  border: 1.3px solid currentColor; background: transparent;
}
.badge.grey { color: var(--muted); }
.badge.blue { color: #1660b0; }
.badge.amber { color: #92640a; }
.badge.red { color: #b3400e; }
.badge.green { color: #1f7a2d; }
.badge.purple { color: #6a2d9c; }
.badge.darkgreen { color: #114d1c; }
.badge.outline { color: var(--muted); background: none; }

/* ---- empty states ---- */
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state .empty-icon { width: 34px; height: 34px; color: var(--line-strong); margin-bottom: 10px; }
.empty-state p { font-size: 14px; margin-bottom: 10px; }

/* ---- forms ---- */
form.stack, .stack { display: flex; flex-direction: column; gap: 14px; max-width: 560px; }
label { font-size: 13px; font-weight: 600; color: var(--muted); display: block; margin-bottom: 5px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit; background: #fafbfc; color: var(--ink);
  transition: border-color 0.12s ease, box-shadow 0.12s ease, background-color 0.12s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); background: var(--card);
}
textarea { min-height: 80px; resize: vertical; }
button {
  font-family: var(--font-body); transition: background-color 0.12s ease, border-color 0.12s ease, transform 0.14s var(--ease-out);
}
button.primary, .btn {
  background: var(--accent); color: #fff; border: none; padding: 10px 20px;
  border-radius: var(--radius-pill); font-size: 13.5px; font-weight: 700; letter-spacing: 0.01em;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
button.primary:hover, .btn:hover { background: var(--accent-dark); }
button.secondary {
  background: var(--card); color: var(--ink); border: 1px solid var(--line-strong);
  padding: 9px 18px; border-radius: var(--radius-pill); font-size: 13.5px; font-weight: 600;
  letter-spacing: 0.01em; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
button.secondary:hover { border-color: var(--stamp); background: var(--paper); }
button.danger {
  background: var(--danger); color: #fff; border: none; padding: 10px 20px;
  border-radius: var(--radius-pill); font-size: 13.5px; font-weight: 700; letter-spacing: 0.01em;
  cursor: pointer;
}
button.danger:hover { background: var(--danger-dark); }
button:active:not(:disabled) { transform: scale(0.98); }
button:disabled { opacity: 0.55; cursor: not-allowed; }
.error { background: #f8e4de; color: var(--danger); padding: 10px 14px; border-radius: var(--radius-sm); font-size: 14px; display: none; align-items: center; gap: 8px; border: 1px solid #eec7ba; }
.muted { color: var(--muted); font-size: 13px; }

/* ---- spinner ---- */
.spinner {
  display: inline-block; width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4); border-top-color: currentColor;
  animation: spin 0.6s linear infinite; vertical-align: -2px;
}
button.secondary .spinner { border-color: rgba(56, 73, 89, 0.2); border-top-color: currentColor; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- toasts ---- */
#toast-root {
  position: fixed; top: 16px; right: 16px; left: 16px; z-index: 1000;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
}
.toast {
  background: var(--ink); color: #fff; padding: 11px 14px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 8px;
  box-shadow: var(--shadow-lift); opacity: 0; transform: translateY(-8px);
  transition: opacity 0.18s var(--ease-out), transform 0.18s var(--ease-out); max-width: min(320px, 100%);
}
.toast.in { opacity: 1; transform: translateY(0); }
.toast.success { background: #1f5c2b; }
.toast.error { background: var(--danger-dark); }
.toast .icon { color: #fff; }

/* ---- modals ---- */
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
dialog.modal { opacity: 0; transform: translateY(8px) scale(0.98); transition: opacity 0.2s var(--ease-out), transform 0.2s var(--ease-out); }
dialog.modal.in { opacity: 1; transform: translateY(0) scale(1); }
dialog.modal::backdrop { background: rgba(56, 73, 89, 0); transition: background-color 0.2s var(--ease-out); }
dialog.modal.in::backdrop { background: rgba(56, 73, 89, 0.5); }
dialog.modal h2 { margin: 0; font-family: var(--font-display); font-size: 22px; text-transform: uppercase; letter-spacing: 0.02em; color: var(--ink); border-bottom: none; padding-bottom: 0; }
dialog { border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; max-width: 480px; width: 90%; margin: auto; background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(56, 73, 89, 0.5); }

/* ---- login ---- */
.login-wrap {
  display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px;
  background: var(--paper);
}
.login-box { width: 100%; max-width: 380px; padding: 36px 32px; box-shadow: var(--shadow-lift); }
.login-box h1 { text-align: center; justify-content: center; margin-bottom: 4px; font-size: 30px; }
.login-box .sub { text-align: center; color: var(--muted); font-size: 13.5px; margin-bottom: 26px; }
.login-box button.primary { width: 100%; justify-content: center; padding: 11px 20px; margin-top: 4px; }

/* ---- tabs & misc layout ---- */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 16px; }
.tabs button {
  background: none; border: none; padding: 10px 16px; font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.03em; cursor: pointer; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 22px 0 10px; }

/* ---- reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
  .spinner { animation-duration: 0.6s !important; }
  .toast, dialog.modal, dialog.modal::backdrop {
    transition-property: opacity, background-color !important;
    transition-duration: 0.18s !important;
  }
  .toast, dialog.modal { transform: none !important; }
}

/* ---- mobile (phones) ---- */
@media (max-width: 680px) {
  main { padding: 16px 14px calc(48px + env(safe-area-inset-bottom)); }
  h1 { font-size: 26px; }
  nav { padding: 6px 12px; padding-top: calc(6px + env(safe-area-inset-top)); gap: 6px; flex-wrap: wrap; }
  nav .brand { font-size: 17px; padding: 6px 0; }
  nav a { padding: 12px 11px; font-size: 14px; }
  nav .icon-btn { width: 36px; height: 36px; }

  /* Sideways-scrolling tables are hard to use one-handed on a phone — each row
     becomes its own card instead, with the column header as a left-hand label
     (from the row's own data-label attributes) next to the value. */
  .table-scroll { overflow: visible; border: none; border-radius: 0; }
  .table-scroll table, table.stack-mobile {
    display: block; width: 100%; min-width: 0; background: none; border: none; box-shadow: none;
  }
  .table-scroll thead, table.stack-mobile thead { display: none; }
  .table-scroll tbody, table.stack-mobile tbody { display: block; }
  .table-scroll tr, table.stack-mobile tr {
    display: block; background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 10px; padding: 2px 14px;
  }
  .table-scroll td, table.stack-mobile td {
    display: flex; justify-content: space-between; align-items: center; gap: 14px;
    padding: 11px 0; border-bottom: 1px solid var(--line); text-align: right; font-size: 14.5px;
  }
  .table-scroll tr td:last-child, table.stack-mobile tr td:last-child { border-bottom: none; }
  .table-scroll td::before, table.stack-mobile td::before {
    content: attr(data-label); font-family: var(--font-mono); font-size: 10.5px; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--muted); font-weight: 600; text-align: left; flex-shrink: 0;
  }

  .tiles { grid-template-columns: repeat(2, 1fr); }
  .tile { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .tile:nth-child(2n) { border-right: none; }
  .tile:nth-last-child(-n+2) { border-bottom: none; }
  .section-title { flex-direction: column; align-items: flex-start; gap: 10px; }
  .actions { flex-direction: column; align-items: stretch; }
  .actions button, .actions a.btn { justify-content: center; }
  td.actions, td .actions { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: flex-start !important; }
  td.actions button, td .actions button { justify-content: flex-start; }
  dialog { padding: 18px; max-height: 88vh; overflow-y: auto; }

  /* 16px stops iOS Safari auto-zooming the page when a field is focused —
     below that size it treats the zoom as "helping" you read a small input. */
  input, select, textarea { font-size: 16px; }

  /* Comfortable thumb targets (~44px, the usual touch-target minimum) rather
     than the tighter desktop sizing, which is easy to mis-tap on a phone. */
  button.primary, button.secondary, button.danger, .btn { padding: 12px 20px; min-height: 44px; }
  nav button:not(.icon-btn) { min-height: 40px; padding: 8px 14px; }
}
