/* ── Reset & base ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand:     #1f4e5f;
  --brand-lt:  #e6f0f3;
  --brand-dk:  #143847;
  --surface:   #ffffff;
  --bg:        #f5f5f7;
  --border:    #e2e8f0;
  --text:      #1e293b;
  --muted:     #64748b;
  --ready:     #16a34a;
  --ready-bg:  #dcfce7;
  --snoozed:   #d97706;
  --snoozed-bg:#fef3c7;
  --done:      #6366f1;
  --done-bg:   #eef2ff;
  --danger:    #dc2626;
  --radius:    10px;
  --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,.10);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font: inherit; }

/* ── Layout ────────────────────────────────────────────────────────── */
.app-header {
  background: var(--brand);
  color: #fff;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.app-header .logo {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -.3px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.app-header .logo-mark {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  object-fit: cover;
  display: block;
  flex-shrink: 0;
}
.app-header .back-btn {
  background: rgba(255,255,255,.2);
  border: none;
  color: #fff;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: .85rem;
  transition: background .15s;
}
.app-header .back-btn:hover { background: rgba(255,255,255,.3); }

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.page-subtitle {
  color: var(--muted);
  font-size: .9rem;
  margin-bottom: 24px;
}

/* ── Cards / grid ──────────────────────────────────────────────────── */
.workflow-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.workflow-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: box-shadow .15s, transform .15s;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.workflow-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.workflow-card h2 {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
}
.workflow-card .meta {
  font-size: .82rem;
  color: var(--muted);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.workflow-card .meta span { display: flex; align-items: center; gap: 4px; }
.workflow-card .arrow {
  margin-top: auto;
  color: var(--brand);
  font-size: .85rem;
  font-weight: 500;
}

/* ── Status badge ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  text-transform: capitalize;
}
.badge.ready    { background: var(--ready-bg);   color: var(--ready); }
.badge.snoozed  { background: var(--snoozed-bg); color: var(--snoozed); }
.badge.completed{ background: var(--done-bg);    color: var(--done); }

/* ── Filter bar ────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-btn {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: .82rem;
  font-weight: 500;
  color: var(--muted);
  transition: all .15s;
}
.filter-btn:hover { border-color: var(--brand); color: var(--brand); }
.filter-btn.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

/* ── Step panel ────────────────────────────────────────────────────── */
.steps-nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.step-tab {
  padding: 7px 16px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: .83rem;
  font-weight: 500;
  color: var(--muted);
  transition: all .15s;
  white-space: nowrap;
}
.step-tab:hover  { border-color: var(--brand); color: var(--brand); }
.step-tab.active {
  background: var(--brand-lt);
  border-color: var(--brand);
  color: var(--brand);
  font-weight: 600;
}

/* ── Person card ───────────────────────────────────────────────────── */
.person-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.person-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 14px;
}
.person-card .avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--brand-lt);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--brand);
}
.person-card .avatar img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
}
.person-card .info { flex: 1; min-width: 0; }
.person-card .name { font-weight: 600; font-size: .95rem; }
.person-card .step-label {
  font-size: .8rem;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.person-card .actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Buttons ───────────────────────────────────────────────────────── */
.btn {
  padding: 7px 14px;
  border-radius: 7px;
  border: none;
  font-size: .82rem;
  font-weight: 500;
  transition: opacity .15s, background .15s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary  { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dk); }
.btn-success  { background: var(--ready-bg); color: var(--ready); border: 1px solid #bbf7d0; }
.btn-success:hover:not(:disabled) { background: #bbf7d0; }
.btn-warn     { background: var(--snoozed-bg); color: var(--snoozed); border: 1px solid #fde68a; }
.btn-warn:hover:not(:disabled) { background: #fde68a; }
.btn-ghost    { background: transparent; color: var(--muted); border: 1.5px solid var(--border); }
.btn-ghost:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.btn-danger   { background: #fee2e2; color: var(--danger); border: 1px solid #fca5a5; }
.btn-danger:hover:not(:disabled) { background: #fca5a5; }
.btn-note     { background: var(--brand-lt); color: var(--brand); border: 1px solid #bfd5dc; }
.btn-note:hover:not(:disabled) { background: #bfd5dc; }
textarea.field-input { resize: vertical; min-height: 88px; }

/* ── Search box ────────────────────────────────────────────────────── */
.search-wrap {
  position: relative;
  width: 100%;
  max-width: 420px;
}
.search-wrap input {
  width: 100%;
  padding: 9px 14px 9px 38px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  font-size: .9rem;
  outline: none;
  background: var(--surface);
  transition: border-color .15s;
}
.search-wrap input:focus { border-color: var(--brand); }
.search-wrap .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: .9rem;
  pointer-events: none;
}
.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  z-index: 50;
  max-height: 280px;
  overflow-y: auto;
}
.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background .1s;
  border-bottom: 1px solid var(--border);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--brand-lt); }
.search-result-item .sr-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--brand-lt);
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; font-weight: 700; color: var(--brand);
  flex-shrink: 0;
}
.search-result-item .sr-avatar img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.search-result-item .sr-name { font-size: .88rem; font-weight: 500; }

/* ── Modal ─────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border-radius: 14px;
  padding: 28px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 16px; }
.modal label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
.modal input[type="date"] {
  width: 100%; padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px; font-size: .9rem; outline: none;
}
.modal input[type="date"]:focus { border-color: var(--brand); }
.modal .modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ── Add-person bar ────────────────────────────────────────────────── */
.add-person-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 24px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.add-person-bar .search-wrap { flex: 1; min-width: 220px; }

/* ── Empty state ───────────────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}
.empty .empty-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty p { font-size: .95rem; }

/* ── Toast ─────────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #1e293b;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: .88rem;
  box-shadow: var(--shadow-md);
  transition: transform .25s ease;
  z-index: 300;
  pointer-events: none;
  white-space: nowrap;
}
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--danger); }

/* ── Schedule modal extras ─────────────────────────────────────────── */
.modal-subtitle {
  font-size: .85rem;
  color: var(--muted);
  margin-bottom: 20px;
  line-height: 1.5;
}
.field-group { margin-bottom: 16px; }
.field-group > label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 7px;
}
.rec-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.rec-tab {
  padding: 6px 14px;
  border-radius: 7px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: .82rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all .15s;
}
.rec-tab:hover  { border-color: var(--brand); color: var(--brand); }
.rec-tab.active { background: var(--brand); border-color: var(--brand); color: #fff; }

.day-pills { display: flex; gap: 5px; flex-wrap: wrap; }
.day-pill {
  width: 42px;
  height: 38px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: .78rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all .15s;
}
.day-pill:hover  { border-color: var(--brand); color: var(--brand); }
.day-pill.active {
  background: var(--brand-lt);
  border-color: var(--brand);
  color: var(--brand);
}

.field-input {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: .9rem;
  outline: none;
  transition: border-color .15s;
  font-family: inherit;
  background: var(--surface);
}
.field-input:focus { border-color: var(--brand); }

.sched-preview {
  background: var(--brand-lt);
  border: 1px solid #c7d2fe;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 4px;
  font-size: .85rem;
  color: var(--brand-dk);
  line-height: 1.5;
}
.sched-preview strong { font-weight: 700; }

/* ── Scheduled tasks panel ─────────────────────────────────────────── */
.scheduled-panel {
  margin-top: 36px;
  border-top: 1px solid var(--border);
  padding-top: 24px;
}
.scheduled-panel h3 {
  font-size: .95rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 12px;
}
.task-list { display: flex; flex-direction: column; gap: 8px; }
.task-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.task-row .task-info { flex: 1; min-width: 0; }
.task-row .task-title { font-size: .88rem; font-weight: 600; }
.task-row .task-meta  { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.task-status {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px;
  font-size: .73rem; font-weight: 600; white-space: nowrap;
}
.task-status.pending   { background: #fef9c3; color: #a16207; }
.task-status.running   { background: #dbeafe; color: #1d4ed8; }
.task-status.completed { background: var(--ready-bg); color: var(--ready); }
.task-status.failed    { background: #fee2e2; color: var(--danger); }
.task-status.cancelled { background: var(--bg); color: var(--muted); }
.task-recurrence { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.task-history-row { display: flex; gap: 5px; margin-top: 8px; flex-wrap: wrap; }
.history-chip {
  font-size: .72rem; font-weight: 600;
  padding: 2px 8px; border-radius: 999px;
  white-space: nowrap;
}
.history-chip.completed { background: var(--ready-bg); color: var(--ready); }
.history-chip.failed    { background: #fee2e2; color: var(--danger); }
.history-chip.running   { background: #dbeafe; color: #1d4ed8; }
.btn-cancel-task {
  background: transparent; border: 1.5px solid var(--border);
  color: var(--muted); border-radius: 6px; padding: 4px 10px;
  font-size: .75rem; cursor: pointer; transition: all .15s; flex-shrink: 0;
}
.btn-cancel-task:hover { border-color: var(--danger); color: var(--danger); }

/* ── List management page ──────────────────────────────────────────── */
.list-meta-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.list-meta-info { flex: 1; min-width: 0; }
.list-meta-actions { flex-shrink: 0; padding-top: 4px; }

.list-stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.stat-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 110px;
}
.stat-label {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}
.stat-value {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}
.stat-value.status-ok   { color: var(--ready); }
.stat-value.status-warn { color: var(--snoozed); font-size: .85rem; }

.rule-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}
.rule-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.rule-number {
  font-size: .8rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.subset-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}
.subset-badge.subset-all { background: var(--brand-lt); color: var(--brand); }
.subset-badge.subset-any { background: #fef3c7; color: #92400e; }
.condition-count {
  margin-left: auto;
  font-size: .78rem;
  color: var(--muted);
}

.conditions-list { padding: 4px 0; }
.condition-row {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
}
.condition-row:last-child { border-bottom: none; }
.condition-desc {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.condition-value-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.comparison-badge {
  font-size: .72rem;
  font-weight: 600;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 7px;
  color: var(--muted);
  white-space: nowrap;
}
.condition-value {
  font-size: .88rem;
  font-weight: 500;
  color: var(--text);
}
.btn-edit-date {
  margin-left: auto;
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 3px 10px;
  font-size: .75rem;
  font-weight: 500;
  color: var(--brand);
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.btn-edit-date:hover { background: var(--brand-lt); border-color: var(--brand); }

.date-editor {
  margin-top: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
}
.date-editor-fields {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.date-editor-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* ── Quick-nav bar ─────────────────────────────────────────────────── */
.quicknav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
  position: sticky;
  top: 56px;
  z-index: 90;
  min-height: 44px;
}
.quicknav::-webkit-scrollbar { display: none; }
.quicknav-group {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 0;
  flex-shrink: 0;
}
.quicknav-label {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  padding-right: 4px;
  white-space: nowrap;
}
.quicknav-pills {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
}
.qnav-pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  font-size: .78rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  text-decoration: none;
  transition: border-color .15s, background .15s, color .15s;
}
.qnav-pill:hover {
  border-color: var(--brand);
  background: var(--brand-lt);
  color: var(--brand);
}
.quicknav-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 14px;
  flex-shrink: 0;
}

/* ── Dashboard top bar ─────────────────────────────────────────────── */
.dash-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.header-date {
  margin-left: auto;
  font-size: .82rem;
  opacity: .75;
}
.dash-chips {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 2px;
}
.dash-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 80px;
  box-shadow: var(--shadow);
}
.dash-chip-label {
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}
.dash-chip-val {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
}

/* ── Dashboard list cards ───────────────────────────────────────────── */
.dash-list-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}
.dash-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.dash-list-info  { flex: 1; min-width: 0; }
.dash-list-title { font-size: 1rem; font-weight: 700; margin-bottom: 3px; }
.dash-list-meta  { font-size: .8rem; color: var(--muted); }
.dash-list-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.btn-remove-list {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: .9rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  line-height: 1;
  transition: color .15s, background .15s;
}
.btn-remove-list:hover { color: var(--danger); background: #fee2e2; }
.dash-list-rules { padding: 16px 20px; }

/* ── Date condition rows ────────────────────────────────────────────── */
.date-cond-row {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.date-cond-row:last-child { border-bottom: none; }

.date-cond-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.date-cond-desc {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text);
}

.date-cond-inputs {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.date-input-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.date-input-label {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}
.date-range-sep {
  color: var(--muted);
  font-size: 1rem;
  padding-bottom: 8px;
}
.date-save-btn {
  padding: 8px 18px;
  white-space: nowrap;
  align-self: flex-end;
}
.btn-saved {
  background: var(--ready) !important;
  pointer-events: none;
}

/* ── Add list error ─────────────────────────────────────────────────── */
.add-list-error {
  color: var(--danger);
  font-size: .82rem;
  margin-bottom: 8px;
}

/* ── Auth overlay ──────────────────────────────────────────────────── */
#auth-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px 40px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-md);
}
.auth-logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--brand);
  margin-bottom: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.auth-logo-mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  display: block;
}
.auth-box h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 10px;
}
.auth-box p {
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.6;
  margin-bottom: 28px;
}
.auth-connect-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--brand);
  color: #fff;
  padding: 12px 28px;
  border-radius: 8px;
  font-size: .95rem;
  font-weight: 600;
  text-decoration: none;
  transition: background .15s;
}
.auth-connect-btn:hover { background: var(--brand-dk); color: #fff; }

/* ── Auth user in header ────────────────────────────────────────────── */
.auth-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.auth-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,.4);
  flex-shrink: 0;
}
.auth-name {
  font-size: .82rem;
  opacity: .9;
  font-weight: 500;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.auth-logout {
  font-size: .78rem;
  padding: 4px 10px;
  border-radius: 5px;
  background: rgba(255,255,255,.15);
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s;
}
.auth-logout:hover { background: rgba(255,255,255,.28); color: #fff; }

/* ── Loading ───────────────────────────────────────────────────────── */
.loading {
  display: flex; align-items: center; justify-content: center;
  padding: 60px;
  color: var(--muted);
  gap: 10px;
}
.spinner {
  width: 22px; height: 22px;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Section header ────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 10px;
}
.section-header h2 {
  font-size: 1.05rem;
  font-weight: 600;
}
.count-chip {
  display: inline-flex;
  align-items: center;
  background: var(--brand-lt);
  color: var(--brand);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: .78rem;
  font-weight: 600;
  margin-left: 8px;
}

/* ── Quick-nav active state ─────────────────────────────────────────── */
.qnav-pill.qnav-active {
  border-color: var(--brand);
  background: var(--brand-lt);
  color: var(--brand);
  font-weight: 600;
}

/* ── Service Plans page ─────────────────────────────────────────────── */
.sp-plan-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}

.sp-plan-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  flex-wrap: wrap;
}

.sp-plan-date {
  font-size: .82rem;
  font-weight: 700;
  color: var(--brand);
  white-space: nowrap;
  min-width: 130px;
}

.sp-plan-title {
  flex: 1;
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  min-width: 0;
}

.sp-type-label {
  font-size: .75rem;
  color: var(--muted);
  margin-top: 2px;
}

.sp-plan-badge-wrap {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.sp-plan-body {
  border-top: 1px solid var(--border);
}
.sp-plan-body:empty { display: none; }

.sp-people-loading {
  display: flex;
  justify-content: center;
  padding: 14px;
}

.sp-people-list {
  display: flex;
  flex-direction: column;
}

.sp-person-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  border-bottom: 1px solid var(--border);
}
.sp-person-row:last-child { border-bottom: none; }

.sp-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.sp-avatar-init {
  background: var(--brand-lt);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .78rem;
  font-weight: 700;
}

.sp-person-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sp-person-name {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text);
}

.sp-person-role {
  font-size: .78rem;
  color: var(--muted);
}

.sp-decline-reason {
  font-size: .75rem;
  color: var(--danger);
  font-style: italic;
}

/* ── Service plan badges ────────────────────────────────────────────── */
.sp-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  white-space: nowrap;
}
.sp-confirmed   { background: var(--ready-bg);   color: var(--ready); }
.sp-unconfirmed { background: var(--snoozed-bg); color: var(--snoozed); }
.sp-pending     { background: var(--snoozed-bg); color: var(--snoozed); }
.sp-declined    { background: #fee2e2;            color: var(--danger); }
.sp-error       { background: #fee2e2;            color: var(--danger); }

.sp-loading-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: .4; }
  50%       { opacity: 1; }
}

.sp-error-msg {
  padding: 10px 20px;
  font-size: .82rem;
  color: var(--danger);
}

.error-text {
  color: var(--danger);
  font-size: .88rem;
}

/* ── Folder card ────────────────────────────────────────────────────── */
.folder-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}
.folder-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.folder-card-icon { font-size: 1rem; flex-shrink: 0; }
.folder-card-name {
  flex: 1;
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
}
.folder-card-body { }

/* ── Accordion ──────────────────────────────────────────────────────── */
.acc-item {
  border-bottom: 1px solid var(--border);
}
.acc-item:last-child { border-bottom: none; }

.acc-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 20px;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  transition: background .15s;
}
.acc-header:hover { background: var(--bg); }

.acc-chevron {
  font-size: .65rem;
  color: var(--muted);
  flex-shrink: 0;
  width: 12px;
  text-align: center;
}

.acc-title-block {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.acc-name {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text);
}
.acc-date {
  font-size: .75rem;
  color: var(--muted);
}

.acc-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.acc-body {
  display: none;
  border-top: 1px solid var(--border);
}
.acc-item.open .acc-body { display: block; }

.acc-plan { }
.acc-plan-date {
  padding: 10px 20px 4px;
  font-size: .78rem;
  font-weight: 700;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: .03em;
}

.sp-empty-msg {
  padding: 20px;
  font-size: .85rem;
  color: var(--muted);
  text-align: center;
}
.sp-all-confirmed {
  padding: 12px 20px;
  font-size: .82rem;
  color: var(--muted);
}

/* ── Workflow mappings list ──────────────────────────────────────────── */
.map-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 4px;
}
.map-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .85rem;
}
.map-st-name {
  flex: 1;
  font-weight: 500;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.map-arrow { color: var(--muted); flex-shrink: 0; }
.map-wf-id {
  font-family: monospace;
  font-size: .82rem;
  color: var(--brand);
  flex-shrink: 0;
}

/* ── Add to workflow button ─────────────────────────────────────────── */
.sp-add-btn {
  font-size: .75rem;
  padding: 4px 10px;
  white-space: nowrap;
  background: transparent;
  color: var(--brand);
  border: 1.5px solid var(--brand);
  border-radius: 6px;
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
.sp-add-btn:hover:not(:disabled) {
  background: var(--brand);
  color: #fff;
}
.sp-add-btn:disabled { opacity: .6; cursor: not-allowed; }
.sp-add-btn.sp-added {
  background: var(--ready-bg);
  color: var(--ready);
  border-color: #bbf7d0;
  pointer-events: none;
}
