:root {
  color-scheme: light dark;
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-2: #243044;
  --text: #e8eef7;
  --muted: #9aa7b8;
  --accent: #4f8cff;
  --accent-2: #7c5cff;
  --danger: #f05b5b;
  --warn: #e9b949;
  --border: #2c3a50;
  --radius: 10px;
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6fa;
    --surface: #ffffff;
    --surface-2: #eef2f8;
    --text: #1a2332;
    --muted: #5c6b7f;
    --border: #d5deeb;
  }

  .activity-pill-good {
    color: #1a6b3a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.auth-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.auth-card h1 {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
}

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

.stack { display: flex; flex-direction: column; gap: 1rem; }

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field > span {
  font-size: 0.875rem;
  font-weight: 600;
}

.field-checkbox {
  flex-direction: row;
  align-items: flex-start;
  gap: 0.6rem;
}

.field-checkbox input[type="checkbox"] {
  margin-top: 0.2rem;
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
}

.field-checkbox > span {
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1.35;
}

input[type="text"],
input[type="tel"],
input[type="password"],
select,
textarea {
  font: inherit;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}

textarea { min-height: 4rem; resize: vertical; }

.btn {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 0.55rem 1rem;
  background: var(--surface-2);
  color: var(--text);
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  color: #fff;
  font-weight: 600;
}

.btn.secondary { background: var(--surface); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { background: rgba(240, 91, 91, 0.15); border-color: var(--danger); color: var(--danger); }
.btn.small { padding: 0.35rem 0.65rem; font-size: 0.8rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.error { color: var(--danger); margin: 0; }
.warn { color: var(--warn); margin: 0; }

.link {
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
  font: inherit;
  padding: 0;
}

.dashboard .topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { font-weight: 700; letter-spacing: 0.02em; }

.tabs {
  display: flex;
  gap: 0.35rem;
  flex: 1;
}

.tab {
  font: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
}

.tab[aria-selected="true"] {
  color: var(--text);
  border-color: var(--border);
  background: var(--surface-2);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.tab-panels { padding: 1.25rem; max-width: 1100px; margin: 0 auto; }

.panel h2 { margin-top: 0; }

.hidden { display: none !important; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.card-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.card-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.card-list .actions { display: flex; gap: 0.5rem; flex-shrink: 0; flex-wrap: wrap; }

.activity-daily-root {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}

.activity-speed-meta {
  margin: 0 0 0.75rem;
  font-size: 0.875rem;
}

.activity-speed-foot {
  margin: 0.65rem 0 0;
}

.activity-speed-leads-cell {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.activity-speed-card.activity-speed-below-min .activity-speed-foot strong {
  color: var(--danger);
}

.activity-platform-day {
  margin-top: 1rem;
}

.activity-platform-day:first-of-type {
  margin-top: 0.35rem;
}

.activity-platform-day-title {
  margin: 0 0 0.45rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.activity-subheading {
  margin: 1.25rem 0 0.35rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.activity-history-root {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 0.75rem;
}

.activity-va-card {
  padding: 1rem 1.15rem;
}

.activity-va-title {
  margin: 0 0 0.65rem;
  font-size: 1.05rem;
}

.activity-history-table td {
  vertical-align: middle;
}

.activity-pill {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
}

.activity-pill-good {
  background: rgba(80, 200, 120, 0.2);
  color: #8fd9a8;
}

.activity-pill-bad {
  background: rgba(240, 91, 91, 0.2);
  color: var(--danger);
}

.activity-pill-muted {
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 500;
}

.va-sheet-block {
  flex: 1 1 100%;
  width: 100%;
  padding: 0.75rem 0;
  border-top: 1px solid var(--border);
  margin-top: 0.25rem;
}

.va-sheet-block .field span {
  font-size: 0.8rem;
  font-weight: 600;
}

.va-sheet-advanced summary {
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--muted);
}

.va-account-li {
  flex-wrap: wrap;
  align-items: flex-end;
}

.va-account-pw-block {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1 1 14rem;
  min-width: min(100%, 12rem);
}

.va-account-pw-label {
  font-size: 0.75rem;
  color: var(--muted);
}

.va-pw-input {
  width: 100%;
}

/* Admin VA password fields: always plain text, never obscured like login */
.va-password-plain {
  -webkit-text-security: none;
}

.lead-panel-body {
  position: relative;
  min-height: 14rem;
}

.lead-loading {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--border);
  border-radius: var(--radius);
}

.lead-loading.hidden {
  display: none;
}

.lead-spinner {
  width: 2.75rem;
  height: 2.75rem;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: lead-spin 0.7s linear infinite;
}

.lead-loading-label {
  margin: 0;
  font-weight: 500;
}

.va-process-instructions {
  margin-top: 1.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.va-process-instructions-heading {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.va-process-instructions-text {
  margin: 0;
  white-space: pre-wrap;
  font-size: 0.9rem;
  line-height: 1.55;
}

.process-settings-card {
  margin-top: 1.5rem;
}

.template-io-card {
  margin-bottom: 1.25rem;
}

.template-io-actions {
  flex-wrap: wrap;
}

.va-template-and-phone {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.25rem;
  align-items: flex-end;
}

.va-template-field {
  flex: 1 1 14rem;
  min-width: min(100%, 12rem);
}

.va-phone-field {
  flex: 1 1 12rem;
  min-width: min(100%, 10rem);
  max-width: 22rem;
}

.va-outreach-phone {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 1.0625rem;
  letter-spacing: 0.035em;
  font-variant-numeric: tabular-nums;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-left-color: var(--accent);
  background: linear-gradient(165deg, var(--surface-2) 0%, var(--surface) 55%, var(--surface-2) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.va-outreach-phone::placeholder {
  color: var(--muted);
  letter-spacing: normal;
}

.va-outreach-phone:hover:not(:disabled) {
  border-color: var(--accent);
  filter: brightness(1.03);
}

.va-outreach-phone:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 0 0 2px rgba(79, 140, 255, 0.28);
}

.va-outreach-phone:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

@keyframes lead-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .lead-spinner {
    animation: none;
    border-color: var(--accent);
    opacity: 0.85;
  }
}

.editor-sheet {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 50;
}

.editor-inner {
  width: min(900px, 100%);
  max-height: min(92vh, 900px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  padding: 1.25rem 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.editor-head, .editor-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.editor-head h3 { margin: 0; }

.fields-rows {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 140px 1fr max-content auto;
  gap: 0.5rem;
  align-items: center;
}

.field-row-lowercase {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.field-row-lowercase input {
  margin: 0;
  accent-color: var(--accent);
}

.field-row .field-note-col {
  grid-column: 1 / -1;
}

.field-note-input {
  font-size: 0.8125rem;
  padding: 0.4rem 0.55rem;
  width: 100%;
}

.field-control-inline {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.field-control-inline > input[type="text"],
.field-control-inline > select {
  flex: 1 1 10rem;
  min-width: 8rem;
}

.field-va-note {
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--muted);
  flex: 1 1 10rem;
  min-width: 6rem;
  max-width: 22rem;
}

@media (max-width: 720px) {
  .field-row {
    grid-template-columns: 1fr;
  }
}

.field-row .remove {
  align-self: center;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  border: 1px dashed var(--border);
  background: var(--surface-2);
  font-size: 0.85rem;
  cursor: grab;
}

.chip:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.message-editable {
  min-height: 140px;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  white-space: pre-wrap;
}

.message-editable.drag-over {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.lead-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  background: var(--surface);
}

.card h3 { margin: 0 0 0.5rem; font-size: 1rem; }

.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 0.75rem;
  margin: 0;
  font-size: 0.9rem;
}

.kv dt { color: var(--muted); margin: 0; }
.kv dd { margin: 0; word-break: break-word; }

.callout.warn {
  border: 1px solid var(--warn);
  background: rgba(233, 185, 73, 0.12);
  padding: 1rem;
  border-radius: var(--radius);
}

.accounts-form-card {
  margin: 1.25rem 0;
  max-width: 420px;
}

.accounts-form-card h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.accounts-list-heading {
  margin: 1.5rem 0 0.5rem;
  font-size: 1.05rem;
}

.table-scroll {
  overflow-x: auto;
  margin: 0.5rem 0 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  background: var(--surface-2);
  font-weight: 600;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.va-metrics-root {
  margin-bottom: 1.25rem;
}

.va-metrics-target .va-metrics-big {
  margin: 0 0 0.35rem;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.va-metrics-target .va-metrics-unit {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
}

.va-metrics-kv dd {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.va-speed-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 0.5rem 0 0.75rem;
}

.va-speed-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.va-speed-table th,
.va-speed-table td {
  text-align: left;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.va-speed-table th {
  background: var(--surface-2);
  font-weight: 600;
}

.va-speed-table tr:last-child td {
  border-bottom: none;
}

.va-speed-count-cell {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.va-speed-empty {
  padding: 0.65rem 0.6rem;
}

.va-speed-summary {
  margin: 0.5rem 0 0;
}

.va-speed-warn {
  margin-left: 0.35rem;
  color: var(--danger);
  font-weight: 600;
}

.va-metrics-speed.va-speed-below-min .va-speed-summary strong {
  color: var(--danger);
}

.activity-platform-day {
  margin-top: 1rem;
}

.activity-platform-day:first-of-type {
  margin-top: 0.35rem;
}

.activity-platform-day-title {
  margin: 0 0 0.45rem;
  font-size: 0.95rem;
  font-weight: 600;
}
