/* ============ Tokens ============ */
:root {
  --accent: #0d9488;
  --accent-ink: #ffffff;
  /* Teal accent scale (shared by dashboard + collector) */
  --accent-50:  #f0fdfa;
  --accent-100: #ccfbf1;
  --accent-200: #99f6e4;
  --accent-300: #5eead4;
  --accent-400: #2dd4bf;
  --accent-500: #14b8a6;
  --accent-600: #0d9488;
  --accent-700: #0f766e;
  --accent-800: #115e59;
  --accent-900: #134e4a;
  --bg: #f5f6f9;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e7e9ef;
  --border-strong: #d6dae2;
  --text: #1b1f26;
  --text-2: #5a626d;
  --text-3: #8b929d;
  --radius: 14px;
  --radius-sm: 9px;
  --radius-pill: 999px;
  --shadow-card: 0 1px 2px rgba(17, 24, 39, .04), 0 2px 6px rgba(17, 24, 39, .05);
  --shadow-pop: 0 10px 30px rgba(17, 24, 39, .12), 0 2px 8px rgba(17, 24, 39, .08);
  --editable-bg: rgba(17, 24, 39, .035);
  --card-gap: 18px;
  --pad: 26px;

  --u-high: #d8474d;
  --u-medium: #bf8108;
  --u-low: #5f6b7a;
  --st-new: #0d9488;
  --st-inprogress: #bf8108;
  --st-waiting: #8957c7;
  --st-done: #2f9e6a;

  --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.accent-text {
  color: var(--accent);
}

/* ============ Layout ============ */
.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 40px 28px 96px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.topbar-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: center;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.topbar-nav-link:hover {
  background: var(--accent-50);
  border-color: var(--accent-300);
  color: var(--accent-700);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  flex: none;
  display: grid;
  place-items: center;
  color: var(--accent-ink);
  background: var(--accent);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 35%, transparent);
}

.brand h1 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.02em;
  margin: 0;
}

.brand p {
  margin: 3px 0 0;
  font-size: 13.5px;
  color: var(--text-2);
  font-weight: 500;
}

.theme-switch {
  display: inline-flex;
  gap: 3px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-card);
}

.theme-btn {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  padding: 7px 16px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all .15s;
}

.theme-btn:hover {
  color: var(--text);
}

.theme-btn.is-active {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 2px 6px color-mix(in srgb, var(--accent) 30%, transparent);
}

/* ============ Stats ============ */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 30px 0 36px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}

.stat-label {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-3);
}

.stat-value {
  display: block;
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1.05;
  margin: 8px 0 4px;
}

.stat-sub {
  font-size: 13px;
  color: var(--text-2);
  font-weight: 500;
}

.stat-urgent .stat-value {
  color: var(--u-high);
}

.stat-pending .stat-value {
  color: var(--accent);
}

/* ============ Inbox / toolbar ============ */
.inbox-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}

.inbox-head h2 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.01em;
  margin: 0;
}

.toolbar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-card);
  margin-bottom: var(--card-gap);
}

.toolbar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-row+.toolbar-row {
  margin-top: 12px;
}

.toolbar-foot {
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px dashed var(--border);
}

.result-count {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-3);
  letter-spacing: -.01em;
}

.search {
  flex: 1 1 280px;
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  height: 38px;
  color: var(--text-3);
  transition: border-color .15s, box-shadow .15s;
}

.search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
}

.search input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text);
}

.search input::placeholder {
  color: var(--text-3);
}

.search-x {
  border: none;
  background: none;
  color: var(--text-3);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 2px;
  border-radius: 5px;
}

.search-x:hover {
  color: var(--text);
  background: var(--editable-bg);
}

/* segmented urgency filter */
.urg-filter {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 3px;
}

.seg {
  white-space: nowrap;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all .14s;
}

.seg:hover {
  color: var(--text);
}

.seg.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-card);
}

.seg.is-active[data-urg="high"] {
  color: var(--u-high);
}

.seg.is-active[data-urg="medium"] {
  color: var(--u-medium);
}

.seg.is-active[data-urg="low"] {
  color: var(--u-low);
}

/* sort buttons — pill, clearly actionable */
.sortgroup {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.sort-lead {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-3);
  margin-right: 2px;
}

.sortbtn {
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  padding: 7px 12px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all .14s;
}

.sortbtn:hover {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border-strong));
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 5%, var(--surface));
}

.sortbtn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 28%, transparent);
}

.filtergroup {
  display: inline-flex;
  gap: 8px;
  margin-left: auto;
}

/* ============ Generic Select (editable / actionable control) ============ */
.sel {
  position: relative;
  display: inline-block;
}

.sel-btn {
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 600;
  transition: all .14s;
}

.sel-btn:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border-strong));
}

.sel.is-open .sel-btn {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}

.sel-caret {
  color: var(--text-3);
  transition: transform .18s;
}

.sel.is-open .sel-caret {
  transform: rotate(180deg);
}

.sel-menu {
  position: absolute;
  z-index: 40;
  top: calc(100% + 6px);
  min-width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-pop);
  padding: 5px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: pop .12s ease;
}

.sel-left {
  left: 0;
}

.sel-right {
  right: 0;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.sel-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
  white-space: nowrap;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-align: left;
  padding: 7px 9px;
  border-radius: 7px;
  cursor: pointer;
}

.sel-opt:hover {
  background: var(--editable-bg);
}

.sel-opt.is-active {
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  color: var(--accent);
}

.sel-opt-check {
  color: var(--accent);
}

.filter-pick .sel-btn {
  color: var(--text-2);
  font-weight: 600;
}

/* ============ Editable text (pencil affordance on hover) ============ */
.ed-view {
  position: relative;
  display: inline-flex;
  align-items: flex-start;
  gap: 6px;
  max-width: 100%;
  cursor: text;
  border-radius: 6px;
  padding: 2px 5px;
  margin: -2px -5px;
  transition: background .14s, box-shadow .14s;
  outline: none;
}

.ed-view .ed-text {
  word-break: break-word;
}

.ed-pencil {
  opacity: 0;
  flex: none;
  color: var(--text-3);
  transition: opacity .14s;
  margin-top: 2px;
}

.ed-view:hover {
  background: var(--editable-bg);
  box-shadow: inset 0 0 0 1px var(--border);
}

.ed-view:hover .ed-pencil {
  opacity: .65;
}

.ed-view:focus-visible {
  box-shadow: inset 0 0 0 1.5px var(--accent);
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}

.ed-view.is-empty .ed-text {
  color: var(--text-3);
  font-style: italic;
}

.ed-input {
  font-family: inherit;
  width: 100%;
  border: 1.5px solid var(--accent);
  background: var(--surface);
  color: var(--text);
  border-radius: 7px;
  padding: 5px 8px;
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
  resize: vertical;
}

textarea.ed-input {
  line-height: 1.55;
}

.ed-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.01em;
}

input.ed-name {
  font-size: 17px;
  font-weight: 700;
}

.ed-mono,
.ed-mono input {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: -.02em;
}

.ed-summary {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-2);
  display: block;
}

.ed-summary.ed-view {
  display: block;
}

.ed-summary .ed-pencil {
  position: absolute;
  right: 6px;
  top: 6px;
}

textarea.ed-summary {
  font-size: 13.5px;
}

.ed-body {
  font-size: 13.5px;
}

/* ============ Card ============ */
.cards {
  display: flex;
  flex-direction: column;
  gap: var(--card-gap);
}

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: box-shadow .18s, transform .18s, border-color .18s;
}

.card:hover {
  box-shadow: var(--shadow-pop);
}

.card-rail {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
}

.card[data-urgency="HIGH"] .card-rail {
  background: var(--u-high);
}

.card[data-urgency="MEDIUM"] .card-rail {
  background: var(--u-medium);
}

.card[data-urgency="LOW"] .card-rail {
  background: var(--u-low);
}

.card-inner {
  padding: var(--pad);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-right: 40px; /* clearance for the hover delete button (top-right) */
}

.card-id {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.created {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-3);
  letter-spacing: -.02em;
}

.created svg {
  color: var(--text-3);
}

/* urgency dropdown */
.urg-sel .sel-btn {
  padding: 0;
  border: none;
  background: none;
  box-shadow: none;
}

.urg-sel.is-open .sel-btn {
  box-shadow: none;
}

.urg-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .05em;
  padding: 5px 10px 5px 9px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
}

.urg-sel .sel-caret {
  margin-left: 1px;
}

.u-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
}

.u-high {
  color: var(--u-high);
}

.urg-badge.u-high {
  background: color-mix(in srgb, var(--u-high) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--u-high) 24%, transparent);
}

.u-medium {
  color: var(--u-medium);
}

.urg-badge.u-medium {
  background: color-mix(in srgb, var(--u-medium) 13%, var(--surface));
  border-color: color-mix(in srgb, var(--u-medium) 26%, transparent);
}

.u-low {
  color: var(--u-low);
}

.urg-badge.u-low {
  background: color-mix(in srgb, var(--u-low) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--u-low) 24%, transparent);
}

.u-dot.u-high {
  background: var(--u-high);
}

.u-dot.u-medium {
  background: var(--u-medium);
}

.u-dot.u-low {
  background: var(--u-low);
}

.urg-opt {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* source badge — static (not editable) */
.src-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .05em;
  padding: 5px 9px;
  border-radius: 7px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
}

.src-badge svg {
  opacity: .8;
}

/* status dropdown */
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 600;
}

.st-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.st-new {
  color: var(--st-new);
}

.st-inprogress {
  color: var(--st-inprogress);
}

.st-waiting {
  color: var(--st-waiting);
}

.st-done {
  color: var(--st-done);
}

/* fields */
.card-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 18px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.field-label {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-3);
  margin-bottom: 7px;
}

.contact-lines {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.contact-line {
  display: flex;
  align-items: center;
  gap: 7px;
}

.contact-ic {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  flex: none;
}

.add-line {
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px dashed var(--border-strong);
  background: none;
  color: var(--text-3);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all .14s;
}

.add-line:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 18%, transparent);
  color: color-mix(in srgb, var(--accent) 80%, var(--text));
  font-size: 12.5px;
  font-weight: 600;
  padding: 4px 6px 4px 11px;
  border-radius: var(--radius-pill);
}

.chip-x {
  display: grid;
  place-items: center;
  border: none;
  background: none;
  color: inherit;
  opacity: .55;
  cursor: pointer;
  padding: 2px;
  border-radius: 50%;
}

.chip-x:hover {
  opacity: 1;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}

.chip-add {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px dashed var(--border-strong);
  background: none;
  color: var(--text-3);
  border-radius: 50%;
  cursor: pointer;
}

.chip-add:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.chip-input {
  font-family: inherit;
  font-size: 12.5px;
  border: 1.5px solid var(--accent);
  background: var(--surface);
  border-radius: var(--radius-pill);
  padding: 4px 11px;
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
  width: 150px;
}

/* split: summary + actions */
.card-split {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) 1px minmax(0, .95fr);
  gap: 22px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.split-divider {
  background: var(--border);
}

.summary-field .ed-summary {
  margin-top: -2px;
}

/* actions */
.actions-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.actions-title {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-3);
}

.actions-prog {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
}

.prog-track {
  width: 54px;
  height: 5px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
}

.prog-fill {
  display: block;
  height: 100%;
  background: var(--st-done);
  border-radius: 3px;
  transition: width .25s;
}

.actions-empty {
  font-size: 12.5px;
  color: var(--text-3);
  font-style: italic;
  margin: 2px 0 10px;
}

.act-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.act {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 5px 6px;
  border-radius: 8px;
  transition: background .12s;
}

.act:hover {
  background: var(--surface-2);
}

.act .ed-view {
  flex: 1;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
}

.act-box {
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border-radius: 6px;
  border: 1.6px solid var(--border-strong);
  background: var(--surface);
  display: grid;
  place-items: center;
  color: #fff;
  cursor: pointer;
  transition: all .14s;
}

.act-box:hover {
  border-color: var(--accent);
}

.act-box svg {
  display: block;
  margin-left: -4px;
}

.act.is-done .act-box {
  background: var(--st-done);
  border-color: var(--st-done);
}

.act.is-done .ed-view .ed-text {
  color: var(--text-3);
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--text-3) 60%, transparent);
}

.act-rm {
  flex: none;
  border: none;
  background: none;
  color: var(--text-3);
  cursor: pointer;
  opacity: 0;
  padding: 3px;
  border-radius: 6px;
  transition: opacity .12s;
}

.act:hover .act-rm {
  opacity: .6;
}

.act-rm:hover {
  opacity: 1;
  background: color-mix(in srgb, var(--u-high) 12%, transparent);
  color: var(--u-high);
}

.act-add {
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 9px;
  border: none;
  background: none;
  color: var(--accent);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  padding: 5px 6px;
  border-radius: 7px;
}

.act-add:hover {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.act-add-input {
  font-family: inherit;
  font-size: 13px;
  margin-top: 9px;
  width: 100%;
  border: 1.5px solid var(--accent);
  background: var(--surface);
  border-radius: 8px;
  padding: 7px 10px;
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}

/* empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 60px 20px;
  color: var(--text-3);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}

.empty-state p {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
}

/* ============ Density ============ */
[data-density="compact"] {
  --pad: 18px;
  --card-gap: 12px;
}

[data-density="compact"] .stat {
  padding: 16px 18px;
}

[data-density="compact"] .stat-value {
  font-size: 32px;
}

[data-density="compact"] .card-fields,
[data-density="compact"] .card-split {
  margin-top: 14px;
  padding-top: 13px;
}

/* ============ Error banner (added for API wiring) ============ */
.banner-error {
  background: color-mix(in srgb, var(--u-high) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--u-high) 35%, transparent);
  color: var(--u-high);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin: 16px 0 0;
}
/* ============ Card delete button (delete-on-hover) ============ */
.card-del { position: absolute; top: 12px; right: 12px; z-index: 2; display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid var(--border); background: var(--surface); color: var(--text-3); border-radius: 8px; cursor: pointer; opacity: 0; transform: translateY(-2px); transition: opacity .14s, transform .14s, color .14s, border-color .14s, background .14s; }
.card:hover .card-del { opacity: 1; transform: translateY(0); }
.card-del:hover { color: var(--u-high); border-color: color-mix(in srgb, var(--u-high) 40%, var(--border)); background: color-mix(in srgb, var(--u-high) 10%, var(--surface)); }
.card-del:focus-visible { opacity: 1; transform: translateY(0); outline: 2px solid var(--accent); outline-offset: 1px; }

.card-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  margin-top: 14px;
}
.reprocess-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background .14s, border-color .14s, color .14s;
}
.reprocess-btn:hover:not(:disabled) {
  background: var(--accent-50);
  border-color: var(--accent-300);
  color: var(--accent-700);
}
.reprocess-btn.is-busy { opacity: .65; cursor: default; }
.reprocess-err {
  font-size: 12px;
  color: var(--u-high);
}

/* ============ Confirm modal ============ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: grid; place-items: center; padding: 24px;
  background: color-mix(in srgb, var(--text) 38%, transparent);
  backdrop-filter: blur(2px);
  animation: modal-fade .16s ease;
}
.modal-card {
  width: 100%; max-width: 408px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 28px 28px 24px;
  box-shadow: 0 24px 60px rgba(17,24,39,.28), 0 4px 14px rgba(17,24,39,.14);
  text-align: left;
  animation: modal-pop .2s cubic-bezier(.2,.9,.3,1.4);
}
.modal-icon {
  width: 44px; height: 44px; border-radius: 12px; flex: none;
  display: grid; place-items: center; margin-bottom: 16px;
  color: var(--u-high);
  background: color-mix(in srgb, var(--u-high) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--u-high) 22%, transparent);
}
.modal-title { margin: 0 0 7px; font-size: 18px; font-weight: 800; letter-spacing: -.02em; color: var(--text); }
.modal-msg { margin: 0; font-size: 14px; line-height: 1.5; color: var(--text-2); font-weight: 500; }
.modal-hl { color: var(--text); font-weight: 700; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.modal-btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: inherit; font-size: 13.5px; font-weight: 700;
  padding: 10px 16px; border-radius: 10px; cursor: pointer;
  transition: background .14s, border-color .14s, color .14s, box-shadow .14s;
}
.modal-btn-ghost { background: var(--surface); border: 1px solid var(--border-strong); color: var(--text-2); }
.modal-btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: var(--text-3); }
.modal-btn-danger { background: var(--u-high); border: 1px solid var(--u-high); color: #fff; box-shadow: 0 4px 12px color-mix(in srgb, var(--u-high) 32%, transparent); }
.modal-btn-danger:hover { background: color-mix(in srgb, var(--u-high) 88%, #000); }
.modal-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.modal-btn-danger:focus-visible { outline-color: color-mix(in srgb, var(--u-high) 60%, #000); }

@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-pop { from { opacity: 0; transform: translateY(8px) scale(.97); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .modal-overlay, .modal-card { animation: none; }
}

/* ============ Login / Admin pages ============ */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px 28px;
  box-shadow: var(--shadow-pop);
}
.login-field {
  margin-bottom: 14px;
}
.login-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 5px;
}
.login-input {
  font-size: 14px;
  padding: 9px 11px;
}
.login-btn {
  width: 100%;
  margin-top: 6px;
  padding: 11px;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background .14s;
}
.login-btn:hover:not(:disabled) { background: var(--accent-700); }
.login-btn:disabled { opacity: .5; cursor: not-allowed; }

/* Admin page layout */
.admin-wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 40px 28px 96px;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.admin-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1.5px solid var(--border);
}
.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--surface-2); }
.admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 600;
}
.admin-badge-active { background: color-mix(in srgb, var(--st-done) 12%, transparent); color: var(--st-done); }
.admin-badge-inactive { background: color-mix(in srgb, var(--text-3) 12%, transparent); color: var(--text-3); }
.admin-actions { display: flex; gap: 6px; }
.admin-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.admin-icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.admin-icon-btn.danger:hover { background: color-mix(in srgb, var(--u-high) 10%, transparent); color: var(--u-high); border-color: color-mix(in srgb, var(--u-high) 30%, transparent); }
.admin-add-form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 18px;
}
.admin-add-form .login-field { flex: 1; min-width: 140px; margin-bottom: 0; }
.admin-add-btn {
  padding: 9px 18px;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background .14s;
}
.admin-add-btn:hover:not(:disabled) { background: var(--accent-700); }
.admin-add-btn:disabled { opacity: .5; cursor: not-allowed; }
