/* Team alerts panel. Dark only, one accent (green), one radius (8px), system type. */
:root {
  color-scheme: dark;
  --bg: #0e1012;
  --surface: #15181b;
  --surface-2: #1b1f23;
  --line: #262b31;
  --line-strong: #343a41;
  --text: #e4e7ea;
  --muted: #9ba4ad;
  --faint: #7f8891;
  --accent: #5cbf8c;
  --accent-hover: #6fcc9b;
  --accent-ink: #0b1a12;
  --accent-soft: rgba(92, 191, 140, 0.12);
  --warn: #e3b45e;
  --warn-soft: rgba(227, 180, 94, 0.1);
  --danger: #f08174;
  --danger-soft: rgba(240, 129, 116, 0.1);
  --radius: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  font-variant-numeric: tabular-nums;
}
[hidden] { display: none !important; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.shell { max-width: 820px; margin: 0 auto; padding: 0 16px 96px; }
.muted { color: var(--muted); }

/* ---------- boot ---------- */
.screen-boot { padding-top: 64px; }

/* ---------- auth ---------- */
.screen-auth { padding-top: clamp(40px, 12vh, 112px); }
.auth { max-width: 360px; display: grid; gap: 16px; }
.auth-title { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -0.01em; }
.auth-lede { margin: -8px 0 4px; color: var(--muted); }
.auth-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

.field { display: grid; gap: 6px; }
.field label { font-size: 13px; font-weight: 550; color: var(--text); }
.field input {
  height: 40px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
}
.field input:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field-help { margin: 0; font-size: 12.5px; color: var(--muted); }
.form-msg { margin: 0; min-height: 1.45em; color: var(--danger); }
.form-msg[data-kind="info"] { color: var(--accent); }

/* ---------- buttons ---------- */
.btn {
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease), transform 0.1s var(--ease);
}
.btn:hover { background: var(--surface-2); border-color: #46505a; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.btn-primary, .btn-take, .btn-done { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover, .btn-take:hover, .btn-done:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-wide { height: 40px; padding: 0 20px; }
.btn-quiet { border-color: transparent; color: var(--muted); }
.btn-quiet:hover { color: var(--text); }
.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(92, 191, 140, 0.4);
}
.link-btn:hover { text-decoration-color: currentColor; }

/* ---------- top of the list ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 56px;
  border-bottom: 1px solid var(--line);
}
.wordmark { font-weight: 650; letter-spacing: -0.01em; }
.who { display: flex; align-items: center; gap: 4px; min-width: 0; }
.who-name { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rename-row { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; padding: 10px 0 0; font-size: 13px; }

.statusbar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px 16px;
  flex-wrap: wrap;
  padding: 12px 0;
}
.watcher-line, .counts { margin: 0; font-size: 13px; color: var(--muted); }
.watcher-line.is-alarm { color: var(--danger); font-weight: 550; }
.net-banner {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid rgba(240, 129, 116, 0.35);
  background: var(--danger-soft);
  border-radius: var(--radius);
  color: var(--danger);
}

/* ---------- cards ---------- */
.list { display: grid; gap: 8px; }
.card {
  position: relative;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 0;
}
.card.is-mine { border-color: rgba(92, 191, 140, 0.45); box-shadow: inset 3px 0 0 var(--accent); }
.card.is-taken { background: #131518; }
.card.is-taken .card-title, .card.is-taken .card-snippet { color: var(--muted); }
.card.is-busy { opacity: 0.6; }

.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 12.5px; }
.card-source { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.card-keyword {
  flex: none;
  max-width: 50%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 1px 8px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 550;
}
.card-title { margin: 6px 0 4px; font-size: 15px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.card-title a { text-decoration: none; }
.card-title a:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--faint); }
.card-snippet { margin: 0; color: #c2c8ce; overflow-wrap: anywhere; }

.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; margin-top: 10px; }
.card-info { display: grid; gap: 2px; font-size: 12.5px; min-width: 0; }
.card-when { color: var(--faint); }
.card-taken { color: var(--text); font-weight: 550; }
.card.is-mine .card-taken { color: var(--accent); }
.card.is-stale .card-taken { color: var(--warn); }
.card.is-stale { border-color: rgba(227, 180, 94, 0.35); }
.card-actions { display: flex; gap: 6px; margin-left: auto; }

.empty { padding: 48px 0; }
.empty-title { margin: 0 0 4px; font-size: 15px; font-weight: 600; }

.skeleton { height: 128px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
@media (prefers-reduced-motion: no-preference) {
  .skeleton { animation: breathe 1.6s ease-in-out infinite; }
  @keyframes breathe { 50% { opacity: 0.55; } }
}

/* ---------- toasts ---------- */
.toasts {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: min(480px, calc(100% - 32px));
  display: grid;
  gap: 8px;
  z-index: 20;
}
.toast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 6px 6px 6px 14px;
  background: #22272c;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(4, 6, 8, 0.5);
}
.toast-error { border-color: rgba(240, 129, 116, 0.45); }
.toast-error .toast-text { color: var(--danger); }
.toast-text { padding: 6px 0; }
.btn-undo { color: var(--accent); border-color: rgba(92, 191, 140, 0.45); }
@media (prefers-reduced-motion: no-preference) {
  .toast { animation: rise 0.22s var(--ease); }
  @keyframes rise { from { opacity: 0; transform: translateY(6px); } }
}

/* ---------- dialog ---------- */
.dialog {
  width: min(400px, calc(100% - 32px));
  padding: 20px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
}
.dialog::backdrop { background: rgba(6, 8, 10, 0.7); }
.dialog form { display: grid; gap: 14px; }
.dialog-title { margin: 0; font-size: 16px; font-weight: 650; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- touch and narrow screens ---------- */
@media (pointer: coarse) {
  .btn { height: 40px; padding: 0 14px; }
}
@media (max-width: 520px) {
  .card { padding: 12px; }
  .card-actions { width: 100%; }
  .card-actions .btn { flex: 1; }
}

/* ---------- admin tabs ---------- */
.tabs {
  display: flex;
  gap: 4px;
  margin-top: 8px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none;
  height: 40px;
  padding: 0 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s var(--ease), border-color 0.15s var(--ease);
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tab:focus-visible { outline-offset: -2px; }

.view-meta { margin: 0; padding: 0 0 10px; font-size: 13px; color: var(--muted); min-height: 1.45em; }

/* ---------- history ---------- */
.filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; padding: 14px 0 10px; }
.field select {
  height: 36px;
  width: 100%;
  min-width: 0;
  padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font: inherit;
  color: inherit;
}
.field select:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field select:disabled { opacity: 0.5; cursor: default; }

.hrow {
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 0;
}
.hrow.is-busy { opacity: 0.6; }
.hrow-head { display: flex; align-items: baseline; gap: 4px 10px; flex-wrap: wrap; font-size: 12.5px; }
.hrow-who { color: var(--text); font-weight: 550; }
.hrow-when { color: var(--faint); }
.hrow-title { margin: 4px 0 0; font-size: 14px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.hrow-title a { text-decoration: none; }
.hrow-title a:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--faint); }
.hrow-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; margin-top: 8px; }
.hrow-where { font-size: 12.5px; color: var(--muted); min-width: 0; overflow-wrap: anywhere; }

.pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.pill-done, .pill-ok { background: var(--accent-soft); color: var(--accent); }
.pill-skipped { background: var(--surface-2); color: var(--muted); }
.pill-fail { background: var(--danger-soft); color: var(--danger); }

/* ---------- this week ---------- */
.weekbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0 6px; }
.week-label { margin: 0; font-weight: 600; text-align: center; }
.panel-block { padding-top: 16px; }
.block-title { margin: 0 0 8px; font-size: 13px; font-weight: 650; color: var(--muted); letter-spacing: 0.02em; }
.block-help { margin: -4px 0 8px; font-size: 12.5px; color: var(--faint); }

/* ---------- tables ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.data { width: 100%; border-collapse: collapse; font-size: 13px; }
.data th, .data td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.data th { font-size: 12px; font-weight: 600; color: var(--faint); white-space: nowrap; background: var(--surface-2); }
.data tbody tr:last-child td { border-bottom: 0; }
.data .num { text-align: right; white-space: nowrap; }
.data .label { white-space: nowrap; }
.data .nowrap { white-space: nowrap; color: var(--muted); }
.data .err { color: var(--muted); min-width: 180px; overflow-wrap: anywhere; }
.data tr.is-source td { font-weight: 600; }
.data tr.is-source:not(:first-child) td { border-top: 1px solid var(--line-strong); }
.data tr.is-site td { color: #c2c8ce; }
.data tr.is-site td.label { padding-left: 28px; color: var(--muted); }
.data tr.is-failing td.err { color: var(--danger); }
.data tr.is-empty td { padding: 16px 12px; }

@media (max-width: 520px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .hrow { padding: 10px 12px; }
}

/* Watcher table stacks on phones so the error text is readable without scrolling. */
@media (max-width: 520px) {
  .data-stack thead { display: none; }
  .data-stack, .data-stack tbody { display: block; }
  .data-stack tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 12px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
  }
  .data-stack tbody tr:last-child { border-bottom: 0; }
  .data-stack td { padding: 0; border: 0; text-align: left; }
  .data-stack td.num, .data-stack td.nowrap, .data-stack td.err { grid-column: 1 / -1; font-size: 12.5px; text-align: left; min-width: 0; }
  .data-stack td.num::before, .data-stack td.nowrap::before, .data-stack td.err::before {
    content: attr(data-label) ": ";
    color: var(--faint);
  }
  .data-stack tr.is-empty { display: block; }
}
