@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("../fonts/atkinson-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("../fonts/atkinson-700.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Outfit";
  src: url("../fonts/outfit-500.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Outfit";
  src: url("../fonts/outfit-600.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}

:root {
  --ink: #142033;
  --blue: #1558c8;
  --blue-deep: #0d3f93;
  --blue-soft: #e7f0fb;
  --paper: #eef3f8;
  --white: #fff;
  --muted: #44566c;
  --line: #d5dee9;
  --safety: #0c6b45;
  --danger: #9d2c2c;
  --side: #0f1b2d;
  --side-elev: #16263d;
  --shadow: 0 10px 30px rgba(20, 32, 51, 0.06);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(21, 88, 200, 0.08), transparent 28%),
    var(--paper);
  font-family: "Atkinson Hyperlegible", "Segoe UI", sans-serif;
  font-size: 1.02rem;
  line-height: 1.55;
}
h1, h2, .brand, button, .btn, .stat strong, .eyebrow {
  font-family: Outfit, "Segoe UI", sans-serif;
  letter-spacing: -0.02em;
}
h1 { margin: 0; font-size: clamp(1.6rem, 2vw, 1.9rem); font-weight: 600; }
h2 { margin: 0 0 12px; font-size: 1.12rem; font-weight: 600; }
a { color: var(--blue-deep); }

.icon, .nav-icon, .card-icon, .chip-icon, .stat-icon {
  width: 18px;
  height: 18px;
  fill: currentColor;
  flex: none;
}

.shell {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  min-height: 100vh;
}

.side {
  background: linear-gradient(180deg, var(--side) 0%, #122033 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 20px 14px 16px;
  overflow-y: auto;
  max-height: 100vh;
  position: sticky;
  top: 0;
  border-right: 1px solid rgba(255,255,255,0.04);
}
.side-top { padding: 4px 8px 8px; }
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 1.15rem;
}
.brand svg { width: 30px; height: 30px; }
.brand-tag {
  margin: 8px 0 0;
  color: #8ea3bb;
  font-size: 0.8rem;
}
.side-label {
  margin: 18px 10px 8px;
  color: #86a0ba;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
}
.side nav { display: grid; gap: 3px; }
.side nav a,
.side-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #d7e3f0;
  text-decoration: none;
  padding: 9px 12px;
  border-radius: 10px;
  transition: background .15s ease, color .15s ease;
}
.side nav a:hover,
.side-logout:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
}
.side nav a.is-active {
  background: rgba(21, 88, 200, 0.28);
  color: #fff;
  box-shadow: inset 3px 0 0 #4d8ef0;
}
.side nav a .nav-icon { opacity: 0.85; }
.side nav a.is-active .nav-icon { opacity: 1; color: #9fc2ff; }
.side-foot {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: grid;
  gap: 8px;
}
.side-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
}
.side-user strong,
.side-user span { display: block; }
.side-user span { color: #9bb0c6; font-size: 0.86rem; margin-top: 2px; }
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--blue);
  color: #fff;
  font-family: Outfit, sans-serif;
  font-weight: 600;
}
.side-logout { color: #b7c7d8; font-size: 0.92rem; }

.main {
  padding: 28px 32px 48px;
  min-width: 0;
}
.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(213, 222, 233, 0.9);
}
.eyebrow {
  margin: 0 0 6px;
  color: var(--blue-deep);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.top-sub {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.country-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue-deep);
  font-weight: 700;
  font-size: 0.84rem;
}
.country-chip.is-off {
  background: #fbeeee;
  color: var(--danger);
}
.chip-icon { width: 14px; height: 14px; }
.country-switch {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}
.country-switch label {
  display: grid;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
}
.country-switch select { min-width: 220px; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat, .card, .login-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.stat {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
}
.stat-icon-wrap {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--blue-soft);
  color: var(--blue-deep);
}
.stat-icon-wrap.warn { background: #f8f1df; color: #7a5b12; }
.stat-icon-wrap.good { background: #e7f6ee; color: var(--safety); }
.stat-icon-wrap.hot { background: #fbeeee; color: var(--danger); }
.stat-icon { width: 20px; height: 20px; }
.stat span { display: block; color: var(--muted); font-size: 0.9rem; }
.stat strong { display: block; margin-top: 4px; font-size: 1.7rem; line-height: 1.1; }

.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
}
.card-icon {
  width: 28px;
  height: 28px;
  padding: 5px;
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue-deep);
}
.grid-2 {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 16px;
  align-items: start;
}
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 700; font-size: 0.84rem; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue-deep);
  font-size: 0.82rem;
  font-weight: 700;
}
.badge.pending { background: #f8f1df; color: #7a5b12; }
.badge.approved, .badge.completed, .badge.active, .badge.paid, .badge.resolved, .badge.closed { background: #e7f6ee; color: var(--safety); }
.badge.rejected, .badge.cancelled, .badge.disabled, .badge.inactive { background: #fbeeee; color: var(--danger); }

form.stack, .stack { display: grid; gap: 12px; }
label { display: grid; gap: 6px; font-weight: 700; font-size: 0.92rem; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--blue);
  color: #fff;
  font: inherit;
  font-family: Outfit, sans-serif;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
button.ghost, .btn.ghost {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.row-actions form { display: inline; }
.row-actions button { min-height: 32px; padding: 0 10px; font-size: 0.88rem; }
.notice {
  border: 1px solid var(--line);
  border-left: 4px solid var(--safety);
  background: #f3faf6;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
}
.notice.bad { border-left-color: var(--danger); background: #fdf6f6; }
.empty { color: var(--muted); margin: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; align-items: end; }
.filters label { margin: 0; }
.toolbar { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.muted { color: var(--muted); }
.split-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.panel-gap { margin-top: 16px; }

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(21, 88, 200, 0.12), transparent 30%),
    var(--paper);
}
.login-card { width: min(420px, 100%); }
.login-card h1 { margin: 12px 0 8px; }
.login-card p { margin: 0 0 18px; color: var(--muted); }
.login-card .brand { color: var(--ink); margin-bottom: 8px; }

input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 3px solid #8eb4ef;
  outline-offset: 2px;
}

/* Settings tabs */
.settings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 18px;
  padding: 6px;
  background: rgba(255,255,255,0.72);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.settings-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  font-family: Outfit, sans-serif;
  font-weight: 600;
  font-size: 0.92rem;
}
.settings-tab:hover { background: var(--blue-soft); color: var(--blue-deep); }
.settings-tab.is-active {
  background: var(--blue);
  color: #fff;
}
.settings-tab .tab-icon { width: 16px; height: 16px; }

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.settings-form .settings-grid { margin-bottom: 8px; }

/* Toggle switch */
.toggle-form { display: inline-flex; margin: 0; }
.toggle {
  display: inline-flex !important;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  font-weight: 700;
  margin: 0;
}
.toggle input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.toggle-track {
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: #c5d0dc;
  position: relative;
  transition: background .18s ease;
  flex: none;
}
.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(20,32,51,.25);
  transition: transform .18s ease;
}
.toggle input:checked + .toggle-track {
  background: var(--blue);
}
.toggle input:checked + .toggle-track .toggle-thumb {
  transform: translateX(20px);
}
.toggle input:focus-visible + .toggle-track {
  outline: 3px solid #8eb4ef;
  outline-offset: 2px;
}
.toggle.is-disabled { opacity: 0.55; cursor: not-allowed; }
.toggle-text { min-width: 1.6rem; color: var(--muted); font-size: 0.86rem; }
.toggle input:checked ~ .toggle-text { color: var(--blue-deep); }

.toggle-row-list { display: grid; gap: 12px; margin: 8px 0 4px; }
.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fbfe;
}
.toggle-row p { margin: 4px 0 0; font-size: 0.9rem; }

.feature-list { display: grid; gap: 10px; }
.feature-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fbfe;
}
.feature-copy { display: grid; gap: 4px; }
.feature-copy .badge { justify-self: start; margin-top: 4px; }
.feature-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
  justify-content: flex-end;
}
.feature-control { display: grid; gap: 6px; justify-items: start; }
.feature-control-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.inline-clear { margin: 0; }
.inline-clear button { min-height: 30px; padding: 0 10px; font-size: 0.82rem; }

.country-meta {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--blue-soft);
  padding: 14px;
}
.country-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}
.country-meta-grid .span-2 { grid-column: 1 / -1; }
.country-meta-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.country-meta-grid strong { display: block; margin-top: 2px; }
.check-row {
  display: flex !important;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}
.check-row input { width: auto; }

.settings-subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 16px;
  padding: 4px;
  background: transparent;
}
.settings-subtab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  text-decoration: none;
  font-family: Outfit, sans-serif;
  font-weight: 600;
  font-size: 0.88rem;
}
.settings-subtab:hover {
  background: var(--blue-soft);
  color: var(--blue-deep);
  border-color: #b7cce8;
}
.settings-subtab.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
.settings-subtab .tab-icon { width: 15px; height: 15px; }

.email-preview-frame {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #eef3f8;
  min-height: 420px;
  flex: 1;
}
.email-preview-frame iframe {
  width: 100%;
  min-height: 420px;
  height: min(70vh, 640px);
  border: 0;
  background: #eef3f8;
}

.email-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.email-workspace.has-side {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
}
.email-workspace-main { min-width: 0; }
.email-preview-side {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow: auto;
  display: flex;
  flex-direction: column;
}
.email-preview-side-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.email-row.is-previewing {
  background: #f3f8ff;
}
.js-email-preview.is-active {
  background: var(--blue-soft);
  color: var(--blue-deep);
  border-color: #b7cce8;
}
.js-email-preview.is-loading {
  opacity: 0.6;
  pointer-events: none;
}
.email-template-table td .empty {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .email-workspace.has-side { grid-template-columns: 1fr; }
  .email-preview-side { position: static; max-height: none; }
}
@media (max-width: 900px) {
  .shell, .stats, .grid-2, .grid-3, .settings-grid, .feature-row { grid-template-columns: 1fr; }
  .feature-controls { justify-content: flex-start; }
  .side { position: static; max-height: none; }
  .side-foot { margin-top: 16px; }
  .main { padding: 20px 16px 40px; }
  .settings-tabs { overflow-x: auto; flex-wrap: nowrap; }
  .email-workspace.has-side { grid-template-columns: 1fr; }
}
