:root {
  --bg: #f3f6fb;
  --panel: #ffffff;
  --panel-soft: #f8fbff;
  --line: #d9e2ec;
  --line-strong: #c6d2df;
  --text: #16202f;
  --muted: #66768a;
  --muted-strong: #4f5e72;
  --sidebar: #0f172a;
  --sidebar-soft: #16213a;
  --sidebar-line: rgba(148, 163, 184, 0.18);
  --sidebar-text: #d7e1ef;
  --sidebar-muted: #90a0b7;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.12);
  --success: #0f8b6d;
  --success-soft: rgba(15, 139, 109, 0.12);
  --warning: #b7791f;
  --warning-soft: rgba(183, 121, 31, 0.12);
  --danger: #c2413a;
  --danger-soft: rgba(194, 65, 58, 0.12);
  --shadow: 0 24px 60px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 12px 30px rgba(15, 23, 42, 0.05);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.08), transparent 28%),
    radial-gradient(circle at top right, rgba(14, 165, 233, 0.08), transparent 24%),
    linear-gradient(180deg, #f8fbff 0%, var(--bg) 40%, #eef4fb 100%);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Segoe UI", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
}

a {
  color: inherit;
}

.shell {
  width: min(1560px, calc(100% - 20px));
  margin: 12px auto 20px;
}

.admin-shell {
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 12px;
  min-height: calc(100vh - 24px);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-radius: var(--radius-xl);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, transparent 100%),
    linear-gradient(180deg, #0f172a 0%, #111b31 100%);
  border: 1px solid var(--sidebar-line);
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.24);
}

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

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

.brand-badge {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: #eff6ff;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.brand-copy h1 {
  margin: 0;
  color: var(--sidebar-text);
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.brand-copy p {
  margin: 4px 0 0;
  color: var(--sidebar-muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.sidebar-section {
  border-top: 1px solid rgba(148, 163, 184, 0.12);
  padding-top: 14px;
}

.sidebar-label {
  margin: 0 0 12px;
  color: var(--sidebar-muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.nav-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-links a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--sidebar-muted);
  border: 1px solid transparent;
  background: transparent;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.nav-links a::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: transparent;
}

.nav-links a:hover {
  transform: translateX(2px);
  background: rgba(148, 163, 184, 0.08);
  border-color: rgba(148, 163, 184, 0.12);
  color: var(--sidebar-text);
}

.nav-links a.active {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.24) 0%, rgba(29, 78, 216, 0.18) 100%);
  border-color: rgba(96, 165, 250, 0.26);
  color: #eff6ff;
}

.nav-links a.active::after {
  background: #93c5fd;
}

.nav-links .danger-link {
  margin-top: 10px;
  color: #fca5a5;
}

.sidebar-note {
  margin-top: auto;
  padding: 12px;
  border-radius: 16px;
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.sidebar-note strong {
  display: block;
  color: var(--sidebar-text);
  font-size: 0.9rem;
  margin-bottom: 6px;
}

.sidebar-note p {
  margin: 0;
  color: var(--sidebar-muted);
  font-size: 0.8rem;
  line-height: 1.55;
}

.main-panel {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.utility-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(198, 210, 223, 0.72);
  box-shadow: var(--shadow-soft);
}

.utility-title {
  font-size: 0.88rem;
  color: var(--muted);
}

.utility-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid rgba(198, 210, 223, 0.9);
  color: var(--muted-strong);
  font-size: 0.82rem;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.page-head h1 {
  margin: 12px 0 0;
  font-size: clamp(2rem, 4vw, 2.8rem);
  line-height: 1.02;
  letter-spacing: -0.04em;
}

.page-head p {
  margin: 10px 0 0;
  max-width: 860px;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.62;
}

.layout-grid {
  display: grid;
  gap: 18px;
}

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

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

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

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

.card,
.stat-card,
.hero-card,
.auth-card {
  border-radius: var(--radius-xl);
  border: 1px solid rgba(198, 210, 223, 0.84);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(248, 251, 255, 0.98) 100%);
  box-shadow: var(--shadow-soft);
}

.card,
.hero-card {
  padding: 22px;
}

.stat-card {
  padding: 22px 20px;
}

.hero-card {
  overflow: hidden;
  position: relative;
  background:
    radial-gradient(circle at top right, rgba(37, 99, 235, 0.14), transparent 34%),
    linear-gradient(180deg, #ffffff 0%, #f5f9ff 100%);
}

.hero-card::after {
  content: "";
  position: absolute;
  right: -46px;
  bottom: -72px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.14) 0%, transparent 68%);
}

.stat-label {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
}

.stat-value {
  margin-top: 12px;
  color: var(--text);
  font-size: clamp(2rem, 3.8vw, 3rem);
  line-height: 1;
  letter-spacing: -0.04em;
  font-weight: 800;
}

.stat-meta {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.83rem;
  line-height: 1.5;
}

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

.card-title {
  margin: 0;
  font-size: 1.15rem;
  color: var(--text);
  font-weight: 700;
}

.subtle {
  color: var(--muted);
  font-size: 0.9rem;
}

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

.list-item,
.mini-item {
  padding: 18px;
  border-radius: 18px;
  background: #fff;
  border: 1px solid rgba(217, 226, 236, 0.9);
}

.list-item-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 14px;
}

.list-item h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.35;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  background: #eef4fb;
  color: var(--muted-strong);
}

.pill.sup {
  background: var(--success-soft);
  color: var(--success);
}

.pill.dem {
  background: var(--warning-soft);
  color: var(--warning);
}

.pill.active {
  background: var(--success-soft);
  color: var(--success);
}

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

.footer-note {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.65;
}

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

.form-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-soft);
}

.toggle-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  flex: 0 0 auto;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--text);
  padding: 12px 14px;
  font: inherit;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(37, 99, 235, 0.42);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
  transform: translateY(-1px);
}

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

button,
.button {
  appearance: none;
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #eff6ff;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.18);
}

button:hover,
.button:hover {
  transform: translateY(-1px);
}

button.secondary,
.button.secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: none;
}

button.ghost,
.button.ghost {
  background: var(--accent-soft);
  color: var(--accent-strong);
  box-shadow: none;
}

button.success,
.button.success {
  background: linear-gradient(135deg, #0f8b6d 0%, #0d7c62 100%);
  box-shadow: 0 10px 24px rgba(15, 139, 109, 0.18);
}

button.danger,
.button.danger {
  background: linear-gradient(135deg, #d34f45 0%, #b73a30 100%);
  box-shadow: 0 10px 24px rgba(194, 65, 58, 0.18);
}

button.small,
.button.small {
  padding: 9px 13px;
  border-radius: 10px;
  font-size: 0.8rem;
}

button.full,
.button.full {
  width: 100%;
}

button:disabled,
.button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 12px;
  text-align: left;
  border-bottom: 1px solid #edf2f7;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

tbody tr:hover {
  background: rgba(37, 99, 235, 0.03);
}

.empty {
  padding: 24px;
  border-radius: 16px;
  border: 1px dashed var(--line-strong);
  background: #f8fbff;
  color: var(--muted);
  text-align: center;
}

.error {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(194, 65, 58, 0.16);
}

.code {
  display: block;
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #f8fbff;
  border: 1px solid rgba(198, 210, 223, 0.9);
  color: var(--muted-strong);
  font-size: 0.84rem;
  line-height: 1.55;
  word-break: break-all;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

.auth-card {
  width: min(500px, 100%);
  padding: 28px;
}

.auth-head h1 {
  margin: 12px 0 10px;
  font-size: 2.05rem;
  line-height: 1;
  letter-spacing: -0.04em;
}

.auth-head p {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.65;
}

.qr {
  display: block;
  margin: 0 auto 16px;
  width: min(100%, 240px);
  border-radius: 20px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
}

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

.section-space {
  margin-top: 18px;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (max-width: 1100px) {
  .grid-4,
  .grid-3,
  .split-2-1,
  .two-col {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .shell {
    width: min(100% - 20px, 1440px);
  }

  .admin-shell {
    grid-template-columns: 1fr;
  }

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

  .nav-links {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .nav-links a {
    flex: 1 1 150px;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 14px, 1440px);
    margin-top: 10px;
  }

  .sidebar,
  .card,
  .stat-card,
  .hero-card,
  .auth-card {
    border-radius: 18px;
  }

  .page-head h1 {
    font-size: 1.72rem;
  }
}
