:root {
  --accent: #0f6b72;
  --accent-dark: #0c565b;
  --accent-soft: #eaf4f4;
  --bg: #f4f6f7;
  --surface: #ffffff;
  --border: #e2e5e8;
  --text: #1f2937;
  --text-muted: #6b7280;
  --radius: 8px;
}
* { box-sizing: border-box; }
[x-cloak] { display: none !important; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13.5px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell { display: flex; min-height: 100vh; }

.nav-rail {
  width: 200px;
  background: var(--accent);
  color: white;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 16px 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 30;
  transition: transform 0.2s ease;
}
.nav-rail .brand {
  font-weight: 700; font-size: 15px; padding: 0 18px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.15); margin-bottom: 8px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.nav-collapse-btn {
  background: rgba(255,255,255,0.12); border: none; color: white; cursor: pointer;
  border-radius: 4px; width: 22px; height: 22px; font-size: 13px; line-height: 1; flex-shrink: 0;
}
.nav-collapse-btn:hover { background: rgba(255,255,255,0.25); }
.nav-rail a { display: block; color: rgba(255,255,255,0.85); padding: 10px 18px; font-size: 13px; font-weight: 500; }
.nav-rail a:hover, .nav-rail a.active { background: rgba(255,255,255,0.12); color: white; text-decoration: none; }
.nav-rail .spacer { flex: 1; }

.main-col { flex: 1; display: flex; flex-direction: column; min-width: 0; margin-left: 200px; transition: margin-left 0.2s ease; }
.app-shell.nav-collapsed .nav-rail { transform: translateX(-100%); }
.app-shell.nav-collapsed .main-col { margin-left: 0; }

.nav-toggle-btn {
  background: none; border: 1px solid var(--border); color: var(--text-muted); cursor: pointer;
  border-radius: 6px; width: 30px; height: 30px; font-size: 14px; flex-shrink: 0;
}
.nav-toggle-btn:hover { background: var(--accent-soft); color: var(--accent); }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar input[type=search] {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  width: 280px;
}

.content { padding: 22px 26px 60px; flex: 1; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 20px;
}

.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.page-header h1 { font-size: 18px; margin: 0; }
.page-header .sub { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }

.section-title {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--accent); font-weight: 700; margin: 0 0 12px 0;
}

table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
.data-table th { color: var(--text-muted); font-weight: 600; font-size: 12px; }
.data-table tbody tr:hover { background: var(--accent-soft); cursor: pointer; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent); color: white; border: none; border-radius: 6px;
  padding: 7px 14px; font-size: 13px; cursor: pointer; font-weight: 600;
}
.btn:hover { background: var(--accent-dark); }
.btn.secondary { background: white; color: var(--accent); border: 1px solid var(--accent); }
.btn.secondary:hover { background: var(--accent-soft); }
.btn.danger { background: #fee2e2; color: #b91c1c; }
.btn.small { padding: 4px 10px; font-size: 12px; }

input[type=text], input[type=email], input[type=number], input[type=date], input[type=password], input[type=file], select, textarea {
  border: 1px solid var(--border); border-radius: 6px; padding: 7px 9px; font-size: 13px; font-family: inherit;
  width: 100%;
}
textarea { min-height: 100px; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; margin-top: 10px; }

.tag { display: inline-block; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 2px 9px; font-size: 11px; margin-right: 4px; }

.status-pill { display: inline-block; border-radius: 999px; padding: 2px 9px; font-size: 11px; font-weight: 700; }
.status-pending, .status-sent { background: #f3f4f6; color: #4b5563; }
.status-delivered { background: #eef6fd; color: #0176d3; }
.status-opened { background: #fef3c7; color: #92400e; }
.status-clicked { background: #ede9fe; color: #6d28d9; }
.status-replied { background: #dcfce7; color: #15803d; }
.status-bounced, .status-failed { background: #fee2e2; color: #b91c1c; }

.field-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.field-row .label { color: var(--text-muted); }
.field-row .value { cursor: pointer; border-radius: 4px; padding: 2px 6px; }
.field-row .value:hover { background: var(--accent-soft); }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 32px; }
.field-grid .field-row.span-2 { grid-column: 1 / -1; }
@media (max-width: 720px) { .field-grid { grid-template-columns: 1fr; } }

.edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 32px; }
.edit-grid .field.span-2 { grid-column: 1 / -1; }
@media (max-width: 720px) { .edit-grid { grid-template-columns: 1fr; } }

.related-list { margin-top: 20px; }
.related-list-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.35); display: flex; align-items: flex-start; justify-content: center; padding-top: 8vh; z-index: 50; }
.modal { background: white; border-radius: var(--radius); padding: 22px 26px; width: 480px; max-width: 92vw; box-shadow: 0 10px 30px rgba(0,0,0,0.2); }
.modal h2 { margin: 0 0 14px 0; font-size: 15px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.muted { color: var(--text-muted); }
.actionbar { display: flex; align-items: center; gap: 10px; background: var(--accent-soft); border: 1px solid var(--border); border-radius: 6px; padding: 8px 14px; margin-bottom: 12px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs a { padding: 8px 14px; font-size: 13px; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid transparent; }
.tabs a.active, .tabs a:hover { color: var(--accent); border-bottom-color: var(--accent); text-decoration: none; }

.filter-bar { display: flex; gap: 10px; margin-bottom: 14px; align-items: center; flex-wrap: wrap; }
.filter-bar select, .filter-bar input { width: auto; min-width: 160px; }

.pagination { display: flex; align-items: center; gap: 10px; padding-top: 12px; margin-top: 4px; border-top: 1px solid var(--border); font-size: 12.5px; }

.timeline-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.timeline-item .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 5px; flex-shrink: 0; }
.timeline-item .reply-body { background: var(--accent-soft); border-radius: 6px; padding: 8px 10px; margin-top: 6px; font-size: 12.5px; }

/* Dashboard / Reports */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; }
.stat-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat-tile .stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 600; margin-bottom: 6px; }
.stat-tile .stat-value { font-size: 26px; font-weight: 700; color: var(--text); }
.stat-tile .stat-value.accent { color: var(--accent); }
a.stat-tile { display: block; text-decoration: none; color: inherit; transition: box-shadow 0.15s, border-color 0.15s; }
a.stat-tile:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.08); border-color: var(--accent); text-decoration: none; }

.chart-bars { display: flex; flex-direction: column; gap: 10px; max-height: 320px; overflow-y: auto; padding-right: 6px; }

.card-table-scroll { max-height: 320px; overflow-y: auto; }
.card-table-scroll table.data-table { margin: 0; }
.card-table-scroll th { position: sticky; top: 0; background: var(--surface); z-index: 1; box-shadow: 0 1px 0 var(--border); }
.chart-bar-row { display: grid; grid-template-columns: 150px 1fr 90px; align-items: center; gap: 12px; font-size: 12.5px; }
.chart-bar-row .chart-label { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-bar-track { background: var(--accent-soft); border-radius: 4px; height: 20px; overflow: hidden; }
.chart-bar-fill { background: var(--accent); height: 100%; border-radius: 4px; min-width: 2px; transition: width 0.3s; }
.chart-bar-row .chart-value { text-align: right; color: var(--text-muted); font-weight: 600; white-space: nowrap; }
.chart-bar-row.link .chart-label a { color: var(--text); }
.chart-bar-row.link .chart-label a:hover { color: var(--accent); }

.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .dashboard-grid { grid-template-columns: 1fr; } }

/* Assign Accounts screen */
.assign-layout { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 980px) { .assign-layout { grid-template-columns: 1fr; } }
.assign-cta {
  border: 2px solid var(--accent);
  background: linear-gradient(180deg, var(--accent-soft), var(--surface) 60%);
  position: sticky;
  top: 16px;
}
.assign-cta .btn { width: 100%; justify-content: center; font-size: 14px; padding: 10px 14px; }
.assign-cta .btn:disabled { opacity: 0.45; cursor: not-allowed; }
.coverage-empty { padding: 10px 0; color: var(--text-muted); font-size: 12.5px; }

/* Outreach calendar */
.cal-header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.cal-header h2 { margin: 0; font-size: 16px; min-width: 160px; text-align: center; }
.cal-nav-btn { background: none; border: 1px solid var(--border); color: var(--text-muted); cursor: pointer; border-radius: 6px; width: 30px; height: 30px; font-size: 14px; }
.cal-nav-btn:hover { background: var(--accent-soft); color: var(--accent); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { text-align: center; font-size: 11px; color: var(--text-muted); font-weight: 700; text-transform: uppercase; padding-bottom: 2px; }
.cal-day { border: 1px solid var(--border); border-radius: 8px; min-height: 76px; padding: 7px; font-size: 12px; cursor: pointer; background: var(--surface); transition: border-color 0.15s; }
.cal-day.empty { border: none; background: transparent; cursor: default; }
.cal-day:hover:not(.empty) { border-color: var(--accent); }
.cal-day.today { border-color: var(--accent); border-width: 2px; }
.cal-day.selected { background: var(--accent-soft); border-color: var(--accent); }
.cal-day .cal-date { font-weight: 700; color: var(--text-muted); }
.cal-day .cal-count { margin-top: 8px; font-size: 19px; font-weight: 700; color: var(--accent); line-height: 1; }
.cal-day .cal-count-label { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.cal-day.heat-1 { background: #eaf4f4; }
.cal-day.heat-2 { background: #cfe7e8; }
.cal-day.heat-3 { background: #a9d6d8; }

/* Searchable multi-select filter */
.ms { position: relative; min-width: 170px; }
.ms-control {
  border: 1px solid var(--border); border-radius: 6px; padding: 7px 9px; font-size: 13px;
  background: white; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 6px;
  white-space: nowrap; overflow: hidden;
}
.ms-control .ms-summary { overflow: hidden; text-overflow: ellipsis; }
.ms-control .ms-arrow { color: var(--text-muted); font-size: 10px; flex-shrink: 0; }
.ms-panel {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 40; width: max(100%, 220px);
  background: white; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  padding: 8px;
}
.ms-panel input[type=text] { width: 100%; min-width: 0; margin-bottom: 6px; }
.ms-options { max-height: 220px; overflow-y: auto; }
.ms-option { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 4px; font-size: 12.5px; cursor: pointer; }
.ms-option:hover { background: var(--accent-soft); }
.ms-option input[type=checkbox] { width: auto; min-width: 0; flex: none; margin: 0; }
.ms-empty { padding: 8px 6px; color: var(--text-muted); font-size: 12.5px; }
.ms-clear { font-size: 11.5px; color: var(--accent); cursor: pointer; padding: 4px 6px; }

/* Admin: query editor + mass update/delete */
.admin-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.admin-tabs button { background: none; border: none; padding: 8px 14px; font-size: 13px; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid transparent; cursor: pointer; }
.admin-tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.sql-editor { width: 100%; min-height: 120px; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; padding: 10px; }
.preset-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 16px; }
.preset-chip { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; font-size: 12px; cursor: pointer; font-weight: 600; }
.preset-chip:hover { background: #dcecec; }
.condition-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.condition-row select, .condition-row input { width: auto; }
.condition-row .cond-field { min-width: 160px; }
.condition-row .cond-op { min-width: 190px; }
.condition-row .cond-value { flex: 1; min-width: 120px; }
.remove-row { background: #fee2e2; color: #b91c1c; border: none; border-radius: 6px; width: 28px; height: 28px; cursor: pointer; font-weight: 700; flex-shrink: 0; }
.danger-banner { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; border-radius: 6px; padding: 10px 14px; font-size: 12.5px; margin: 12px 0; }
.warn-banner { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; border-radius: 6px; padding: 10px 14px; font-size: 12.5px; margin: 12px 0; }
.confirm-box { border: 2px dashed #fca5a5; border-radius: 8px; padding: 16px; margin-top: 14px; background: #fff5f5; }
.confirm-box input[type=text] { font-family: ui-monospace, monospace; font-weight: 700; }
.result-scroll { overflow-x: auto; max-height: 420px; overflow-y: auto; }
