:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-soft: #eef5ff;
  --text: #172033;
  --muted: #637089;
  --line: #dbe3ef;
  --primary: #1769e0;
  --primary-dark: #0f4fab;
  --danger: #c73636;
  --success: #10805a;
  --warning: #a35d00;
  --shadow: 0 18px 46px rgba(31, 45, 70, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(23, 105, 224, 0.12), transparent 34rem),
    linear-gradient(180deg, #f8fbff 0%, var(--bg) 42%, #eef3f9 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

.app-shell {
  width: min(1560px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.topbar,
.auth-grid,
.panel,
.table-wrap {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 16px 18px;
  border-radius: 8px;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  color: #fff;
  font-weight: 800;
  background: linear-gradient(135deg, #1769e0, #12a68a);
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.brand p,
.hint,
.muted {
  color: var(--muted);
}

.brand p {
  margin: 3px 0 0;
  font-size: 13px;
}

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

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
}

.tab,
.btn,
.icon-btn {
  min-height: 38px;
  border-radius: 8px;
  padding: 0 14px;
  color: var(--text);
  background: #e8eef7;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    transform 0.15s ease;
}

.tab:hover,
.btn:hover,
.icon-btn:hover {
  transform: translateY(-1px);
}

.tab.active,
.btn.primary {
  color: #fff;
  background: var(--primary);
}

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

.btn.ghost {
  background: transparent;
  border: 1px solid var(--line);
}

.btn.success {
  color: #fff;
  background: var(--success);
}

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

.admin-grid {
  display: grid;
  grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.settings-layout {
  display: grid;
  grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.settings-notice {
  grid-column: 1 / -1;
}

.settings-stack {
  display: grid;
  gap: 18px;
}

.mail-panel[hidden] {
  display: none;
}

.panel,
.auth-grid,
.table-wrap {
  border-radius: 8px;
}

.panel {
  padding: 20px;
}

.panel h2,
.panel h3 {
  margin: 0 0 14px;
  font-size: 18px;
}

.panel p {
  line-height: 1.65;
}

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

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

.field span,
.label {
  color: #34415a;
  font-size: 13px;
  font-weight: 650;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  background: #fff;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23, 105, 224, 0.12);
}

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

.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #34415a;
  font-size: 13px;
  font-weight: 650;
}

.check input {
  width: 16px;
  min-height: 16px;
}

.table-wrap {
  overflow: auto;
}

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

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

th {
  color: #34415a;
  background: #f7faff;
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  color: #2b3a55;
  background: #e9eff8;
  font-size: 12px;
  font-weight: 700;
}

.badge.green {
  color: #0e6247;
  background: #dff5ec;
}

.badge.red {
  color: #9d2323;
  background: #fde6e6;
}

.badge.orange {
  color: var(--warning);
  background: #fff0d9;
}

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

.account-section {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.account-section > .table-wrap {
  margin-top: 10px;
}

.account-section:last-child {
  margin-bottom: 0;
}

.account-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faff;
  cursor: pointer;
  list-style: none;
}

.account-head::-webkit-details-marker {
  display: none;
}

.account-head h3 {
  margin: 0;
  font-size: 15px;
}

.limit-control {
  display: grid;
  grid-template-columns: 92px 64px;
  gap: 8px;
  align-items: center;
}

.record-value {
  min-width: 220px;
}

.record-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

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

.metric {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.metric b {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

.hint {
  margin: 8px 0 0;
  font-size: 13px;
}

.notice {
  margin: 12px 0 0;
  border: 1px solid #bfe6d6;
  border-radius: 8px;
  padding: 11px 12px;
  color: #0e6247;
  background: #e8f8f1;
  font-size: 14px;
  line-height: 1.5;
}

.toast {
  position: fixed;
  z-index: 30;
  right: 18px;
  top: 18px;
  max-width: min(420px, calc(100vw - 36px));
  border-radius: 8px;
  padding: 12px 14px;
  color: #fff;
  background: #172033;
  box-shadow: var(--shadow);
}

.empty {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.divider {
  height: 1px;
  margin: 14px 0;
  background: var(--line);
}

@media (max-width: 880px) {
  .grid,
  .auth-grid,
  .admin-grid,
  .settings-layout,
  .summary {
    grid-template-columns: 1fr;
  }

  .settings-notice {
    grid-column: auto;
  }

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

  .actions {
    justify-content: flex-start;
  }
}
