:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --border: #d8e0ea;
  --muted: #607086;
  --text: #111827;
  --primary: #0f766e;
  --primary-strong: #0b5f59;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --success: #087443;
  --warning: #946200;
  --info-bg: #eef6ff;
  --shadow: 0 16px 40px rgba(18, 24, 38, 0.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;
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

.auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(460px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 32px;
}

.brand {
  color: var(--primary);
  font-weight: 900;
  margin: 0 0 18px;
}

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

h1 {
  margin-bottom: 6px;
}

h2 {
  margin-bottom: 12px;
}

.subtitle,
.toolbar p,
.metric-note,
.admin-name,
.empty {
  color: var(--muted);
}

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

.field {
  display: grid;
  gap: 8px;
}

.field span,
.check-field span {
  color: #344054;
  font-size: 14px;
  font-weight: 800;
}

.field input,
.field select,
.field textarea,
.toolbar input,
.toolbar select {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

.field input,
.field select,
.toolbar input,
.toolbar select {
  height: 44px;
}

.field textarea {
  min-height: 96px;
  padding: 12px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.toolbar input:focus,
.toolbar select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

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

.check-field input,
[data-select-id] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.btn {
  min-height: 44px;
  border-radius: 6px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 900;
  padding: 0 16px;
}

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

.btn.secondary {
  background: #e8eef6;
  color: #243247;
}

.btn.danger {
  background: var(--danger);
}

.mini {
  min-height: 32px;
  border-radius: 6px;
  background: #eef2f7;
  color: #243247;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 900;
}

.mini:hover {
  background: #dbe4ef;
}

.danger-text {
  color: var(--danger);
}

.link-btn,
.icon-btn {
  background: transparent;
  color: var(--primary);
  font-weight: 900;
  padding: 0;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  color: #475467;
}

.icon-btn:hover {
  background: #eef2f7;
}

.alert {
  border-radius: 6px;
  padding: 12px 14px;
  font-weight: 800;
  margin-bottom: 16px;
}

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

.alert.info {
  background: var(--info-bg);
  color: #175cd3;
  border: 1px solid #bfdcff;
}

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 276px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  background: #101828;
  color: #ffffff;
  padding: 24px 18px;
}

.sidebar .brand {
  color: #5eead4;
  font-size: 18px;
}

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

.nav-section {
  color: #98a2b3;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  margin: 16px 8px 4px;
  text-transform: uppercase;
}

.nav button {
  min-height: 40px;
  border-radius: 6px;
  background: transparent;
  color: #d0d5dd;
  text-align: left;
  padding: 0 12px;
  font-weight: 800;
}

.nav button.active,
.nav button:hover {
  background: #1d2939;
  color: #ffffff;
}

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

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

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

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

.dashboard-panels {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 18px;
}

.card,
.table-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(18, 24, 38, 0.05);
}

.card {
  padding: 18px;
}

.metric-card {
  min-height: 126px;
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  margin: 0 0 8px;
  text-transform: uppercase;
}

.metric-value {
  font-size: 30px;
  font-weight: 950;
  margin: 0;
}

.metric-note {
  font-size: 13px;
  font-weight: 700;
  margin: 10px 0 0;
}

.toolbar {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  justify-content: space-between;
  margin: 22px 0 12px;
}

.toolbar-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.toolbar input {
  max-width: 260px;
}

.table-panel {
  overflow: auto;
}

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

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

th {
  background: #f8fafc;
  color: #475467;
  font-size: 12px;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 900;
}

.pill.ok {
  background: #dcfae6;
  color: var(--success);
}

.pill.warn {
  background: #fff4cc;
  color: var(--warning);
}

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

.pill.muted {
  background: #eef2f7;
  color: #475467;
}

.setup-divider {
  height: 1px;
  background: var(--border);
  margin: 22px 0;
}

.hidden {
  display: none;
}

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

.bar-row {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) 3fr 40px;
  gap: 10px;
  align-items: center;
  color: #475467;
  font-size: 13px;
  font-weight: 800;
}

.bar-row div {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eef6;
}

.bar-row i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.bulkbar,
.config-flags,
.activity-split {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.bulkbar {
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

.bulkbar span {
  color: var(--muted);
  font-weight: 900;
}

.feature-grid {
  display: grid;
  grid-template-columns: 1fr repeat(2, minmax(160px, 220px));
  gap: 12px;
  align-items: center;
}

.settings-card,
.profile-card {
  max-width: 820px;
}

.settings-form {
  margin-top: 10px;
}

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

.profile-grid p {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.profile-grid span {
  color: var(--muted);
}

.modal {
  position: fixed;
  inset: 0;
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 0;
  overflow: auto;
}

.modal::backdrop {
  background: rgba(15, 23, 42, 0.42);
}

.modal-panel {
  background: var(--panel);
  padding: 22px;
}

.modal-head,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-actions {
  justify-content: flex-end;
  margin-top: 10px;
}

pre {
  max-height: 70vh;
  overflow: auto;
  border-radius: 8px;
  background: #101828;
  color: #d0d5dd;
  padding: 16px;
}

.loading-line {
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: #dbe4ef;
  margin-bottom: 16px;
}

.loading-line::after {
  content: "";
  display: block;
  width: 30%;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  animation: load 1.1s ease-in-out infinite;
}

@keyframes load {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(360%);
  }
}

@media (max-width: 1040px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    z-index: 5;
    height: auto;
    max-height: 52vh;
  }

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

  .nav-section {
    grid-column: 1 / -1;
  }

  .metrics,
  .dashboard-panels,
  .profile-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .main {
    padding: 18px;
  }

  .auth-panel {
    padding: 24px;
  }

  .metrics,
  .dashboard-panels,
  .feature-grid,
  .profile-grid {
    grid-template-columns: 1fr;
  }

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

  .toolbar-controls {
    justify-content: stretch;
  }

  .toolbar input,
  .toolbar select,
  .toolbar .btn {
    max-width: none;
    width: 100%;
  }
}
