:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef2f5;
  --text: #15212f;
  --muted: #627083;
  --line: #dce3ea;
  --primary: #0f766e;
  --primary-strong: #115e59;
  --accent: #e11d48;
  --warning: #b7791f;
  --radius: 8px;
  --shadow: 0 18px 40px rgba(21, 33, 47, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  background: var(--bg);
  color: var(--text);
}

body.locked {
  overflow: hidden;
}

button,
input,
textarea,
select {
  font: inherit;
}

.sidebar {
  min-height: 100vh;
  padding: 24px 18px;
  background: #17212b;
  color: #f8fafc;
  position: sticky;
  top: 0;
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--primary);
  font-weight: 800;
}

.brand small,
.eyebrow,
.muted {
  color: var(--muted);
}

.brand small {
  display: block;
  color: #b6c2cf;
}

.menu {
  display: grid;
  gap: 6px;
}

.menu button {
  width: 100%;
  border: 0;
  border-radius: var(--radius);
  padding: 12px 14px;
  text-align: left;
  color: #d7dee6;
  background: transparent;
  cursor: pointer;
}

.menu button:hover,
.menu button.active {
  background: #223242;
  color: #ffffff;
}

.app {
  min-width: 0;
  padding: 28px;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  place-items: center;
  padding: 22px;
  background: #17212b;
}

.login-screen.active {
  display: grid;
}

.login-card {
  width: min(100%, 420px);
  display: grid;
  gap: 14px;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

.login-card h1 {
  font-size: 1.7rem;
}

.login-brand {
  margin-bottom: 4px;
  color: var(--text);
}

.topbar {
  min-height: 76px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 22px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.user-chip {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: #fff;
  font-size: 0.9rem;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 3vw, 2.5rem);
}

h2 {
  margin-bottom: 16px;
  font-size: 1.05rem;
}

.primary {
  border: 0;
  border-radius: var(--radius);
  padding: 11px 16px;
  color: #fff;
  background: var(--primary);
  font-weight: 700;
  cursor: pointer;
}

.primary:hover {
  background: var(--primary-strong);
}

.secondary {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
  color: var(--text);
  background: #fff;
  font-weight: 700;
  cursor: pointer;
}

.secondary:hover {
  background: var(--surface-2);
}

.danger-button {
  border: 1px solid #fecdd3;
  border-radius: var(--radius);
  padding: 8px 10px;
  color: #be123c;
  background: #fff1f2;
  font-weight: 700;
  cursor: pointer;
}

.danger-button:hover {
  background: #ffe4e6;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.stat,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat {
  padding: 18px;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 1.7rem;
}

.panel {
  padding: 18px;
}

.panel-grid,
.split,
.wide-split {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 16px;
  align-items: start;
}

.split {
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
}

.wide-split {
  grid-template-columns: minmax(320px, 460px) minmax(0, 1fr);
}

.smtp-layout {
  display: grid;
  grid-template-columns: minmax(360px, 520px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.smtp-builder {
  border-top: 4px solid var(--primary);
}

.stack {
  display: grid;
  gap: 16px;
}

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

.panel-head h2 {
  margin: 0;
}

.panel-head span {
  color: var(--muted);
  font-size: 0.9rem;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  color: var(--primary-strong);
  background: #d9f5f0;
  font-size: 0.82rem;
  font-weight: 700;
}

.badge.warn {
  color: var(--warning);
  background: #fff3d7;
}

.badge.danger {
  color: var(--accent);
  background: #ffe4ea;
}

.form {
  display: grid;
  gap: 13px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 11px;
  color: var(--text);
  background: #fff;
}

textarea {
  min-height: 100px;
  resize: vertical;
}

.code-field {
  min-height: 180px;
  font-family: Consolas, "Liberation Mono", monospace;
  font-size: 0.86rem;
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

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

.check input {
  width: auto;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.item-card {
  min-height: 130px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.item-card h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.item-card p {
  margin-bottom: 12px;
  color: var(--muted);
}

.item-card pre {
  max-height: 180px;
  overflow: auto;
  margin: 10px 0 0;
  padding: 10px;
  border-radius: var(--radius);
  background: #fff;
  color: var(--muted);
  white-space: pre-wrap;
  font-size: 0.78rem;
}

.list-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.list-pill {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.list-pill strong,
.list-pill span {
  display: block;
}

.list-pill span {
  color: var(--muted);
  font-size: 0.85rem;
}

.quota-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.quota-box {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.quota-box span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.quota-box strong {
  display: block;
  margin-top: 6px;
  font-size: 1.25rem;
}

.quota-note {
  margin: 12px 0 0;
}

.system-panel {
  margin-top: 16px;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.status-box {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.status-box span,
.status-box small {
  display: block;
}

.status-box span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.status-box strong {
  display: block;
  margin: 5px 0;
}

.status-box small {
  color: var(--muted);
  line-height: 1.35;
}

.bars {
  display: grid;
  gap: 14px;
}

.bar-row {
  display: grid;
  gap: 7px;
}

.bar-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.9rem;
}

.bar-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: 360px;
  padding: 13px 15px;
  border-radius: var(--radius);
  color: #fff;
  background: #17212b;
  box-shadow: var(--shadow);
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 980px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    position: static;
  }

  .menu {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .menu button {
    text-align: center;
  }

  .stats-grid,
  .panel-grid,
  .split,
  .smtp-layout,
  .wide-split,
  .status-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app,
  .sidebar {
    padding: 18px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    justify-content: stretch;
  }

  .top-actions button,
  .user-chip {
    width: 100%;
    justify-content: center;
  }

  .menu {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .field-grid,
  .quota-grid {
    grid-template-columns: 1fr;
  }
}
