:root {
  --bg: #f5f7f7;
  --surface: #ffffff;
  --surface-soft: #eef4f3;
  --text: #16201f;
  --muted: #6f7d7a;
  --border: #dbe3e1;
  --accent: #0f8f83;
  --accent-dark: #0a6f66;
  --amber: #c98218;
  --danger: #c44949;
  --shadow: 0 16px 42px rgba(22, 32, 31, .08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

.app-shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: #12211f;
  color: #d7e2df;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.app-brand { color: #fff; display: flex; align-items: center; gap: 12px; font-weight: 800; text-decoration: none; font-size: 18px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 8px; display: inline-grid; place-items: center;
  color: #fff; background: var(--accent); font-weight: 800; letter-spacing: 0;
}
.sidebar .nav { gap: 4px; }
.sidebar .nav-link {
  color: #b7c5c2; border-radius: 8px; padding: 11px 12px; font-size: 14px; display: flex; align-items: center; gap: 10px;
}
.sidebar .nav-link i { width: 18px; text-align: center; }
.sidebar .nav-link:hover, .sidebar .nav-link.active { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-footer { margin-top: auto; font-size: 13px; color: #aebfbb; display: flex; align-items: center; gap: 8px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #52c48f; box-shadow: 0 0 0 4px rgba(82,196,143,.14); }

.main-panel { padding: 24px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.topbar h1 { font-size: 28px; font-weight: 800; margin: 0; }
.topbar p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.search-box {
  height: 38px; min-width: 260px; display: flex; align-items: center; gap: 9px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 0 12px; color: var(--muted);
}
.search-box input { border: 0; outline: 0; width: 100%; font-size: 14px; }
.user-pill { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; font-size: 14px; }
.icon-btn {
  width: 36px; height: 36px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text);
  display: inline-grid; place-items: center; text-decoration: none;
}
button.icon-btn { cursor: pointer; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.metric-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow);
  padding: 18px; min-height: 112px; position: relative;
}
.metric-card span { color: var(--muted); font-size: 13px; font-weight: 700; text-transform: uppercase; }
.metric-card strong { display: block; font-size: 30px; margin-top: 10px; }
.metric-card i { position: absolute; top: 18px; right: 18px; color: var(--accent); }
.metric-card.danger i { color: var(--danger); }

.dashboard-grid, .editor-grid, .settings-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.content-panel, .ops-panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); padding: 18px;
}
.panel-heading { display: flex; justify-content: space-between; gap: 14px; align-items: center; margin-bottom: 16px; }
.panel-heading h2, .ops-panel h2 { font-size: 18px; margin: 0; font-weight: 800; }
.panel-heading p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.btn { border-radius: 8px; font-weight: 700; font-size: 14px; }
.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

.table { font-size: 14px; }
.table thead th { color: var(--muted); text-transform: uppercase; font-size: 12px; letter-spacing: 0; border-bottom-color: var(--border); }
.table-action { width: 32px; height: 32px; border-color: transparent; }
.status-chip {
  display: inline-flex; align-items: center; min-height: 24px; padding: 4px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 800; background: var(--surface-soft); color: var(--muted);
}
.status-chip.sent, .status-chip.delivered, .status-chip.delivery, .status-chip.active { color: #0d756d; background: #dff4f1; }
.status-chip.sending, .status-chip.queued { color: #8a5a0b; background: #fff0d8; }
.status-chip.bounced, .status-chip.bounce, .status-chip.complaint, .status-chip.complained { color: #a13c3c; background: #fbe2e2; }
.status-chip.draft { color: #5c6866; background: #edf1f0; }

.ops-panel { position: sticky; top: 18px; }
.ops-item { display: flex; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--border); }
.ops-item i { margin-top: 3px; color: var(--accent); }
.ops-item.wait i { color: var(--amber); }
.ops-item strong { display: block; font-size: 14px; }
.ops-item span, .ops-note, .text-muted { color: var(--muted); font-size: 13px; }
.ops-note { margin-top: 14px; background: var(--surface-soft); border-radius: 8px; padding: 12px; }

.code-editor { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.settings-list { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 12px; margin: 0; }
.settings-list dt { color: var(--muted); font-size: 13px; }
.settings-list dd { margin: 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.checklist i { color: var(--accent); margin-right: 8px; }
.empty-state { min-height: 260px; display: grid; place-items: center; text-align: center; color: var(--muted); }
.empty-state i { font-size: 36px; color: var(--accent); }
.empty-state strong, .empty-state span { display: block; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }

.login-screen { min-height: 100vh; display: grid; place-items: center; background: #12211f; }
.login-card { width: min(420px, calc(100% - 32px)); background: #fff; border-radius: 8px; padding: 30px; box-shadow: 0 24px 70px rgba(0,0,0,.22); }
.login-card h1 { font-size: 24px; margin: 16px 0 4px; font-weight: 800; }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .dashboard-grid, .editor-grid, .settings-grid { grid-template-columns: 1fr; }
  .ops-panel { position: static; }
}

@media (max-width: 760px) {
  .main-panel { padding: 16px; }
  .topbar, .topbar-actions, .panel-heading { align-items: stretch; flex-direction: column; }
  .search-box { min-width: 0; width: 100%; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 520px) {
  .metric-grid { grid-template-columns: 1fr; }
  .settings-list { grid-template-columns: 1fr; }
}
