:root {
  --bg: #fafaf9;
  --bg-elevated: #ffffff;
  --bg-surface: #f5f5f4;
  --ink: #1c1917;
  --text: #44403c;
  --muted: #78716c;
  --line: rgba(28, 25, 23, 0.08);
  --accent: #0d9488;
  --accent-2: #0f766e;
  --accent-soft: #f0fdfa;
  --accent-glow: rgba(13, 148, 136, 0.12);
  --danger: #dc2626;
  --warning: #d97706;
  --success: #059669;
  --sidebar: #ffffff;
  --sidebar-active: #f0fdfa;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.06);
  --radius-xl: 14px;
  --radius-lg: 10px;
  --radius-md: 6px;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  min-height: 100vh;
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  letter-spacing: 0.005em;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 15% 10%, rgba(13, 148, 136, 0.03), transparent 24rem),
    radial-gradient(circle at 85% 90%, rgba(15, 118, 110, 0.03), transparent 24rem);
}

a { color: inherit; text-decoration: none; }

button, input, select { font: inherit; }

.app-shell {
  position: relative;
  min-height: 100vh;
  display: flex;
}

.nav-toggle { display: none; }

.mobile-menu-button,
.nav-scrim { display: none; }

.sidebar {
  position: sticky;
  top: 0;
  z-index: 20;
  width: 260px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px 16px;
  color: var(--text);
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px 12px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  font-weight: 800;
  letter-spacing: -0.05em;
  background: var(--accent);
}

.brand {
  font-size: 20px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.brand-subtitle {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.operator-card {
  padding: 14px;
  border-radius: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--line);
}

.operator-card span,
.operator-card strong { display: block; }

.operator-card span {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.operator-card strong {
  margin-top: 7px;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
}

.side-nav {
  display: grid;
  gap: 4px;
}

.side-nav a {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 10px 12px 10px 16px;
  border-radius: 10px;
  color: var(--text);
  border: 1px solid transparent;
  transition: background 0.16s ease, color 0.16s ease;
}

.side-nav a::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 0;
  border-radius: 0 99px 99px 0;
  background: var(--accent);
  transition: height 0.16s ease;
}

.side-nav a span {
  margin-right: auto;
  font-weight: 500;
}

.side-nav a em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.side-nav a:hover {
  color: var(--ink);
  background: var(--bg-surface);
}

.side-nav a.active {
  color: var(--accent-2);
  background: var(--sidebar-active);
  border-color: rgba(13, 148, 136, 0.14);
}

.side-nav a.active::before { height: 20px; }

.logout-link {
  margin-top: auto;
  display: block;
  padding: 12px 14px;
  border-radius: 10px;
  color: var(--danger);
  background: rgba(220, 38, 38, 0.04);
  border: 1px solid rgba(220, 38, 38, 0.1);
  text-align: center;
  font-weight: 600;
  transition: background 0.16s ease;
}

.logout-link:hover { background: rgba(220, 38, 38, 0.08); }

.main-content {
  position: relative;
  z-index: 1;
  flex: 1;
  width: min(100%, calc(100vw - 260px));
  padding: 32px;
}

.main-content.full {
  width: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}

.flash-stack {
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
}

.flash {
  position: relative;
  padding: 12px 16px 12px 18px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.flash::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
}

.flash.success { color: var(--success); }
.flash.success::before { background: var(--success); }
.flash.error { color: var(--danger); }
.flash.error::before { background: var(--danger); }

.toast {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 50;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  font-weight: 500;
  animation: toastIn 0.18s ease;
}

.toast.success { color: var(--success); }
.toast.error { color: var(--danger); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-wrap {
  position: relative;
  width: 100%;
  max-width: 1120px;
  display: grid;
  place-items: center;
  min-height: 100vh;
}

.login-wrap::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(#d6d3d1 1px, transparent 1px),
    radial-gradient(#d6d3d1 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: 0 0, 12px 12px;
  opacity: 0.35;
}

.login-card,
.verify-card,
.panel,
.hero-card,
.stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.login-card,
.verify-card {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  padding: 32px;
}

.verify-card {
  display: grid;
  gap: 16px;
}

.verify-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.verify-card .brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--accent);
}

.verify-card .brand { color: var(--ink); }

.verify-card .brand-subtitle {
  margin-top: 4px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 11px;
}

.verify-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--bg-surface);
  font-size: 12px;
  font-weight: 600;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--success);
}

.verify-copy { margin-bottom: 0; }

.verify-meta {
  display: grid;
  gap: 6px;
  padding-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.eyebrow::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 99px;
  background: var(--accent);
}

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

h1,
h2 {
  color: var(--ink);
  letter-spacing: -0.03em;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(28px, 3.6vw, 42px);
  line-height: 1.1;
  font-weight: 700;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(17px, 1.8vw, 21px);
  font-weight: 600;
}

p {
  color: var(--muted);
  line-height: 1.65;
}

.form-grid {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

.form-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

input,
select {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--bg-surface);
  color: var(--ink);
  outline: none;
  transition: border-color 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}

input[type="checkbox"] {
  width: auto;
  min-height: auto;
  margin-right: 8px;
  accent-color: var(--accent);
}

input:focus,
select:focus,
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent-glow);
  outline-offset: 2px;
}

input:focus,
select:focus {
  background: var(--bg-elevated);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn {
  min-height: 42px;
  border: 0;
  border-radius: var(--radius-md);
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0;
  transition: background 0.14s ease, transform 0.12s ease, box-shadow 0.14s ease;
}

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

.btn.primary {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

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

.btn.secondary {
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--line);
}

.btn.secondary:hover {
  background: var(--bg-surface);
  border-color: rgba(13, 148, 136, 0.35);
}

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

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

.btn.small {
  min-height: 34px;
  padding: 7px 11px;
  font-size: 12px;
}

.muted-text { color: var(--muted); font-size: 13px; }

.hint-box {
  margin-top: 0;
  padding: 12px;
  border-radius: var(--radius-lg);
  color: var(--muted);
  background: var(--bg-surface);
  border: 1px solid var(--line);
  font-size: 13px;
}

.hero-card {
  position: relative;
  overflow: hidden;
  padding: clamp(22px, 3.6vw, 32px);
  margin-bottom: 24px;
  background: var(--bg-elevated);
  border-left: 4px solid var(--accent);
}

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

.stat-card {
  position: relative;
  overflow: hidden;
  padding: 20px;
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: var(--accent);
}

.stat-card span {
  display: block;
  color: var(--muted);
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 500;
}

.stat-card strong {
  color: var(--ink);
  font-size: clamp(24px, 2.8vw, 30px);
  font-weight: 700;
  letter-spacing: -0.03em;
}

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

.panel-grid.two-col { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.panel {
  padding: clamp(18px, 3vw, 22px);
  margin-bottom: 16px;
}

.panel-grid .panel { margin-bottom: 0; }

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

.panel-head a,
.panel-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.panel-head a:hover { color: var(--accent); }

.info-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 16px;
  border-radius: var(--radius-lg);
  background: var(--accent-soft);
  border: 1px solid rgba(13, 148, 136, 0.12);
  color: var(--accent-2);
  font-size: 13px;
}

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

.action-stack {
  display: grid;
  gap: 8px;
}

.inline-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 6px;
  align-items: center;
}

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

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

th {
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

td { color: var(--text); }

tr:hover td { background: rgba(0, 0, 0, 0.02); }

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

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge.status-unused {
  color: var(--muted);
  background: var(--bg-surface);
}

.badge.status-used {
  color: var(--success);
  background: rgba(5, 150, 105, 0.08);
}

.badge.status-disabled,
.badge.status-redeemed {
  color: var(--danger);
  background: rgba(220, 38, 38, 0.08);
}

.page-head {
  position: relative;
  margin-bottom: 24px;
  padding: 4px 0 8px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  width: min(360px, calc(100vw - 32px));
  padding: 22px;
  border-radius: var(--radius-xl);
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  transform: translateY(8px);
  transition: transform 0.16s ease;
}

.modal-overlay.open .modal { transform: translateY(0); }

.modal h3 {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
}

.modal p {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 14px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

@media (max-width: 1040px) {
  .sidebar { width: 230px; z-index: 30; }
  .main-content { width: min(100%, calc(100vw - 230px)); padding: 26px; }
  .side-nav a em { display: none; }
}

@media (max-width: 760px) {
  body { background-size: auto; }

  .app-shell { display: block; }

  .mobile-menu-button {
    position: fixed;
    left: 14px;
    top: 12px;
    z-index: 35;
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0 13px;
    border-radius: 999px;
    color: #fff;
    background: var(--accent);
    box-shadow: var(--shadow);
    font-size: 13px;
    font-weight: 600;
  }

  .nav-scrim {
    position: fixed;
    inset: 0;
    z-index: 25;
    display: block;
    pointer-events: none;
    background: rgba(0, 0, 0, 0);
    transition: background 0.2s ease;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 30;
    width: min(84vw, 300px);
    transform: translateX(-104%);
    transition: transform 0.22s ease;
  }

  .nav-toggle:checked ~ .nav-scrim {
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.45);
  }

  .nav-toggle:checked ~ .sidebar { transform: translateX(0); }

  .main-content {
    width: 100%;
    padding: 68px 14px 22px;
  }

  .main-content.full { padding: 18px; }

  .login-card,
  .verify-card { padding: 26px 20px; }

  .panel-grid.two-col,
  .form-grid.compact { grid-template-columns: 1fr; }

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

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

  .panel,
  .hero-card { overflow-x: auto; }

  table { min-width: 640px; }

  .stats-grid table,
  .login-card table { min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
