:root {
  --navy: #102b46;
  --navy-deep: #0b2033;
  --green: #16836b;
  --green-dark: #106b58;
  --mint: #e8f4ef;
  --mint-border: #cce5d9;
  --ink: #182635;
  --muted: #5b6d7e;
  --line: #dce5eb;
  --paper: #f3f7fa;
  --white: #ffffff;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --warn: #b54708;
  --warn-bg: #fffaeb;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

/* Login view */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(120deg, #0d263e, #174b68 72%, #176b60);
}

.login-card {
  width: min(420px, 100%);
  background: var(--white);
  border-radius: 16px;
  padding: 34px;
  box-shadow: 0 24px 60px rgba(6, 24, 38, 0.35);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.login-brand img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: contain;
  border: 1px solid var(--line);
  padding: 2px;
}

.login-brand h1 {
  margin: 0;
  font-size: 19px;
  color: var(--navy);
}

.login-brand p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

/* Topbar */
.topbar {
  background: var(--navy);
  color: var(--white);
  padding: 0 24px;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.topbar-brand img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--white);
  padding: 2px;
  object-fit: contain;
}

.topbar-brand small {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: #9dc5d8;
  letter-spacing: 0.08em;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.user-pill {
  background: rgba(255, 255, 255, 0.12);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  color: #dcebf2;
}

/* Layout */
.admin-wrap {
  width: min(1280px, 95%);
  margin: 26px auto 60px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.kpi {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px;
}

.kpi-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.kpi-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--navy);
  margin: 6px 0 2px;
  line-height: 1.1;
}

.kpi-sub {
  font-size: 12px;
  color: var(--green);
  font-weight: 600;
}

/* Tabs */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.tab-btn {
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--white);
  color: #34495b;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.tab-btn:hover {
  border-color: var(--green);
  color: var(--green);
}

.tab-btn.active {
  background: var(--navy);
  border-color: var(--navy);
  color: var(--white);
}

/* Panel cards */
.panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 22px;
  margin-bottom: 20px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.panel-head h2 {
  margin: 0;
  font-size: 19px;
  color: var(--navy);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

/* Form controls */
.field {
  margin-bottom: 13px;
}

.field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #34495b;
  margin-bottom: 5px;
}

input,
select,
textarea {
  font-family: inherit;
  font-size: 13px;
  padding: 9px 12px;
  border: 1px solid #c9d6df;
  border-radius: 7px;
  color: var(--ink);
  background: var(--white);
}

.field input,
.field select,
.field textarea {
  width: 100%;
}

.field textarea {
  min-height: 82px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(22, 131, 107, 0.14);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: 7px;
  background: var(--green);
  color: var(--white);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover {
  background: var(--green-dark);
}

.btn.secondary {
  background: var(--white);
  color: var(--navy);
  border-color: var(--line);
}

.btn.secondary:hover {
  border-color: var(--navy);
  background: var(--paper);
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.12);
  color: var(--white);
  border-color: rgba(255, 255, 255, 0.25);
}

.btn.ghost:hover {
  background: rgba(255, 255, 255, 0.22);
}

.btn.danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: #fecdca;
}

.btn.danger:hover {
  background: #fee4e2;
}

.btn.sm {
  padding: 6px 10px;
  font-size: 12px;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  text-align: left;
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: var(--paper);
}

tr:hover td {
  background: #fafcfd;
}

.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--navy);
  white-space: nowrap;
}

.pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: var(--mint);
  color: var(--green-dark);
}

.pill.warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.pill.muted {
  background: var(--paper);
  color: var(--muted);
}

.subtext {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}

.actions-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.notice {
  display: none;
  padding: 10px 13px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  margin-top: 12px;
}

.notice.show {
  display: block;
}

.notice.success {
  background: var(--mint);
  color: #0e5848;
  border: 1px solid var(--mint-border);
}

.notice.error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #fecdca;
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--navy);
  color: var(--white);
  padding: 12px 18px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(10, 30, 48, 0.3);
  z-index: 200;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 32, 51, 0.62);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 150;
  overflow-y: auto;
}

.modal-card {
  width: min(640px, 100%);
  background: var(--white);
  border-radius: 15px;
  padding: 26px 28px;
  box-shadow: 0 24px 60px rgba(6, 22, 36, 0.4);
  max-height: 92vh;
  overflow-y: auto;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.modal-head h3 {
  margin: 0;
  color: var(--navy);
  font-size: 19px;
}

.quote-context {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 12px 14px;
  font-size: 12.5px;
  color: #34495b;
  margin-bottom: 16px;
}

.result-box {
  background: var(--mint);
  border: 1px solid var(--mint-border);
  border-radius: 10px;
  padding: 15px;
  margin-top: 14px;
  font-size: 13px;
  color: #0e5848;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.smtp-banner {
  padding: 13px 16px;
  border-radius: 9px;
  font-size: 13px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
}

.smtp-banner.ok {
  background: var(--mint);
  border-color: var(--mint-border);
  color: #0e5848;
}

.smtp-banner.warn {
  background: var(--warn-bg);
  border-color: #fedf89;
  color: var(--warn);
}

@media (max-width: 1000px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .topbar {
    height: auto;
    padding: 12px 16px;
    flex-wrap: wrap;
  }
  .kpi-grid {
    grid-template-columns: 1fr;
  }
}

