:root {
  color-scheme: dark;
  --bg: #07090d;
  --bg-soft: #0c1118;
  --surface: #111821;
  --surface-2: #151f2b;
  --surface-3: #1b2736;
  --line: #263447;
  --line-strong: #34465d;
  --text: #f3f7fb;
  --muted: #a5b2c4;
  --subtle: #748296;
  --accent: #2fe0ad;
  --accent-strong: #15bd8c;
  --blue: #68a7ff;
  --rose: #ff6f8e;
  --amber: #ffd166;
  --danger: #ff6b6b;
  --shadow: 0 22px 70px rgba(0, 0, 0, .34);
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(47, 224, 173, .11), transparent 28rem),
    linear-gradient(220deg, rgba(104, 167, 255, .10), transparent 30rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, Segoe UI, Arial, sans-serif;
  line-height: 1.5;
}

body::before {
  content: "";
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .035) 1px, transparent 1px);
  background-size: 44px 44px;
  opacity: .45;
}

a { color: #b7dcff; text-decoration: none; }
a:hover { color: #ffffff; }

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

input, select, textarea {
  width: 100%;
  background: #0a1018;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 12px 13px;
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

input:focus, select:focus, textarea:focus {
  border-color: rgba(47, 224, 173, .75);
  box-shadow: 0 0 0 4px rgba(47, 224, 173, .12);
  background: #0d151f;
}

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

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

code {
  display: inline-block;
  max-width: 100%;
  overflow-wrap: anywhere;
  color: #c8f7e8;
  background: rgba(47, 224, 173, .09);
  border: 1px solid rgba(47, 224, 173, .19);
  border-radius: 7px;
  padding: 3px 7px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 32px;
  background: rgba(7, 9, 13, .78);
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  font-size: 20px;
  font-weight: 850;
}

.brand-mark {
  display: grid;
  align-items: center;
  justify-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: #06120f;
  background: linear-gradient(135deg, var(--accent), #a8ffd9);
  box-shadow: 0 12px 32px rgba(47, 224, 173, .22);
  font-size: 13px;
}

.topbar nav {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.topbar nav a {
  color: #c4cfdd;
  border-radius: 8px;
  padding: 8px 10px;
  font-weight: 700;
  font-size: 14px;
}

.topbar nav a:hover { background: rgba(255,255,255,.06); color: #fff; }

body.app-layout {
  background: var(--bg);
}

body.app-layout::before {
  opacity: .18;
}

body.app-layout .topbar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 280px;
  align-items: stretch;
  justify-content: flex-start;
  flex-direction: column;
  gap: 18px;
  padding: 20px 14px;
  overflow-y: auto;
  background: rgba(10, 16, 24, .96);
  border-right: 1px solid rgba(255,255,255,.08);
  border-bottom: 0;
}

body.app-layout .brand {
  padding: 2px 6px 12px;
}

body.app-layout .topbar nav {
  display: block;
}

.sidebar-toggle {
  display: none;
  width: 100%;
  min-height: 38px;
  box-shadow: none;
}

.sidebar-panel {
  display: grid;
  gap: 14px;
}

.sidebar-section {
  display: grid;
  gap: 4px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  border-radius: 8px;
  color: #c8d3e1;
  padding: 8px 10px;
  font-size: 14px;
  font-weight: 750;
}

.side-link:hover {
  background: rgba(255,255,255,.055);
  color: #fff;
}

.side-link.active {
  background: rgba(47, 224, 173, .13);
  color: #dcfff4;
  box-shadow: inset 3px 0 0 var(--accent);
}

.side-link.danger-link {
  color: #ffd4d4;
}

.nav-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 26px;
  height: 26px;
  border-radius: 7px;
  background: rgba(255,255,255,.07);
  color: #e8f2ff;
  font-size: 11px;
  font-weight: 900;
}

body.app-layout .shell {
  width: auto;
  max-width: none;
  margin-left: 280px;
  padding: 32px 36px 70px;
}

.shell {
  position: relative;
  width: 1200px;
  max-width: calc(100% - 32px);
  margin: 0 auto;
  padding: 38px 0 70px;
}

.hero {
  min-height: calc(100vh - 118px);
  display: grid;
  grid-template-columns: calc(100% - 438px) 390px;
  gap: 48px;
  align-items: center;
}

.eyebrow {
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 850;
  margin-bottom: 12px;
}

.hero h1 {
  font-size: 86px;
  line-height: .86;
  margin: 0 0 22px;
}

.lede {
  font-size: 21px;
  color: #c7d3e3;
  max-width: 720px;
}

.button, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(180deg, #3af0bd, var(--accent-strong));
  color: #04130f;
  font-weight: 850;
  padding: 12px 16px;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(47, 224, 173, .18);
  transition: transform .14s ease, box-shadow .14s ease, filter .14s ease;
}

.button:hover, button:hover {
  color: #04130f;
  transform: translateY(-1px);
  filter: brightness(1.03);
  box-shadow: 0 16px 36px rgba(47, 224, 173, .22);
}

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

.button.small {
  min-height: 34px;
  padding: 8px 11px;
  font-size: 14px;
}

.link-button {
  background: transparent;
  color: #b7dcff;
  padding: 8px 0;
  box-shadow: none;
}

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

.hero-panel, .panel, .auth-card, .feature-grid article {
  background:
    linear-gradient(180deg, rgba(255,255,255,.045), transparent),
    linear-gradient(180deg, var(--surface), #0d131c);
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 8px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.hero-panel {
  padding: 26px;
  background:
    linear-gradient(155deg, rgba(47, 224, 173, .12), rgba(104, 167, 255, .06)),
    linear-gradient(180deg, #111b26, #0d131c);
}

.fake-qr {
  width: 210px;
  height: 210px;
  margin: 0 auto 20px;
  background:
    linear-gradient(90deg, rgba(255,255,255,.95) 12px, transparent 12px) 0 0 / 42px 42px,
    linear-gradient(rgba(255,255,255,.95) 12px, transparent 12px) 0 0 / 42px 42px,
    linear-gradient(135deg, var(--accent), var(--blue));
  padding: 12px;
  border-radius: 8px;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  border-top: 1px solid rgba(255,255,255,.09);
  padding: 15px 0;
  color: var(--muted);
}

.metric-row strong { color: var(--text); }

.feature-grid {
  display: grid;
  grid-template-columns: calc(33.33% - 12px) calc(33.33% - 12px) calc(33.33% - 12px);
  gap: 18px;
}

.feature-grid article { min-height: 170px; }

.feature-grid h2, .panel h1, .auth-card h1 { margin-top: 0; }

.feature-grid p, .panel p, .auth-card p { color: var(--muted); }

.auth-card {
  width: 470px;
  max-width: 100%;
  margin: 44px auto;
}

.auth-card.wide {
  width: 780px;
  max-width: 100%;
}

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

.notice {
  border: 1px solid rgba(255, 209, 102, .28);
  background: rgba(255, 209, 102, .10);
  color: #ffe3a1;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 18px;
}

.notice p { margin: 0; }

.toast-stack {
  position: fixed;
  right: 18px;
  top: 18px;
  z-index: 100;
  display: grid;
  gap: 10px;
  width: min(380px, calc(100vw - 36px));
}

.toast {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(255,255,255,.12);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: rgba(12, 18, 28, .98);
  color: var(--text);
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

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

.toast button {
  min-height: 22px;
  width: 22px;
  border-radius: 6px;
  padding: 0;
  background: rgba(255,255,255,.08);
  color: var(--text);
  box-shadow: none;
}

.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0,0,0,.56);
}

.confirm-dialog {
  width: min(440px, 100%);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px;
  background: var(--surface);
  padding: 22px;
  box-shadow: var(--shadow);
}

.confirm-dialog h2 {
  margin: 0 0 8px;
}

.admin-user-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px 180px auto;
}

details summary {
  color: #b7dcff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 750;
  margin-top: 6px;
}

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

.page-head h1 {
  margin: 0;
  font-size: 38px;
}

.page-head p {
  margin: 7px 0 0;
  color: var(--muted);
}

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

.summary-grid h2 {
  margin: 4px 0 0;
  font-size: 34px;
}

.metric-label {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.section-title {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.section-title h2 {
  margin: 0;
}

.section-title p {
  margin: 5px 0 0;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
  background: rgba(17, 24, 33, .76);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  padding: 12px;
}

.inline-form { display: flex; gap: 10px; }

.folder-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: -4px 0 18px;
}

.folder-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  border: 1px solid rgba(104, 167, 255, .22);
  border-radius: 999px;
  background: rgba(104, 167, 255, .11);
  color: #cbe4ff;
  padding: 5px 11px;
  font-size: 13px;
  font-weight: 800;
}

.folder-chip-form {
  margin: 0;
}

.folder-chip button {
  min-height: 20px;
  width: 20px;
  border-radius: 999px;
  padding: 0;
  background: rgba(255, 107, 107, .16);
  color: #ffd5d5;
  box-shadow: none;
  font-size: 13px;
}

.folder-chip button:hover {
  color: #fff;
  background: rgba(255, 107, 107, .28);
  transform: none;
  box-shadow: none;
}

.folder-chip.compact {
  min-height: 24px;
  padding: 3px 9px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  background: rgba(12, 18, 28, .86);
  box-shadow: var(--shadow);
}

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

th, td {
  text-align: left;
  padding: 14px 15px;
  border-bottom: 1px solid rgba(255,255,255,.075);
  vertical-align: middle;
}

tbody tr { transition: background .14s ease; }
tbody tr:hover { background: rgba(255,255,255,.035); }

th {
  color: var(--subtle);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

td form { display: inline; }

.row-actions {
  display: flex;
  gap: 9px;
  align-items: center;
  flex-wrap: wrap;
}

.row-actions a, .row-actions button {
  min-height: 30px;
  border-radius: 7px;
  background: rgba(104, 167, 255, .10);
  color: #c7e2ff;
  padding: 5px 8px;
  box-shadow: none;
  font-size: 13px;
}

.row-actions a:hover, .row-actions button:hover {
  background: rgba(104, 167, 255, .18);
  transform: none;
  color: #fff;
}

.row-actions .danger {
  color: #ffd0d0;
  background: rgba(255, 107, 107, .11);
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #2a3445;
  color: #d7e4f7;
  padding: 4px 9px;
  font-weight: 800;
  font-size: 12px;
}

.pill.active {
  background: rgba(47, 224, 173, .13);
  color: #a7f5da;
  border: 1px solid rgba(47, 224, 173, .24);
}

.two-col, .detail-grid {
  display: grid;
  grid-template-columns: calc(100% - 420px) 400px;
  gap: 20px;
}

.qr-form .panel { align-self: start; }

.color-row {
  display: block;
}

.color-row input[type="color"] {
  min-height: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.color-row input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 11px 0;
}

.color-row input[type="color"]::-webkit-color-swatch {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
}

.color-row input[type="color"]::-moz-color-swatch {
  min-height: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
}

.color-swatch {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.2);
  box-shadow: inset 0 0 0 4px rgba(0,0,0,.16), 0 10px 22px rgba(0,0,0,.22);
}

.color-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0;
}

.color-meta span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 8px;
  background: rgba(255,255,255,.045);
  color: var(--muted);
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 750;
}

.color-meta i {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1px solid rgba(255,255,255,.25);
}

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

.check input {
  width: 17px;
  height: 17px;
}

.qr-preview {
  background:
    linear-gradient(45deg, #e8edf5 25%, transparent 25%) 0 0 / 20px 20px,
    linear-gradient(45deg, transparent 75%, #e8edf5 75%) 0 0 / 20px 20px,
    #fff;
  border-radius: 8px;
  padding: 22px;
  display: grid;
  align-items: center;
  justify-items: center;
  box-shadow: var(--shadow);
}

.qr-preview img {
  width: 100%;
  max-width: 340px;
  height: auto;
}

.break {
  word-break: break-word;
  color: var(--muted);
}

.stats {
  display: grid;
  grid-template-columns: calc(25% - 10.5px) calc(25% - 10.5px) calc(25% - 10.5px) calc(25% - 10.5px);
  gap: 14px;
  margin-bottom: 20px;
}

.stats div {
  background:
    linear-gradient(180deg, rgba(255,255,255,.045), transparent),
    var(--surface-2);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  padding: 18px;
}

.stats span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.stats strong {
  display: block;
  margin-top: 6px;
  font-size: 32px;
}

.analytics-grid {
  display: grid;
  grid-template-columns: calc(33.33% - 12px) calc(33.33% - 12px) calc(33.33% - 12px);
  gap: 18px;
  margin-bottom: 20px;
}

.chart-card {
  background:
    linear-gradient(180deg, rgba(255,255,255,.045), transparent),
    linear-gradient(180deg, var(--surface), #0d131c);
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 8px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.chart-card h2 {
  margin: 0 0 16px;
}

.chart-card p {
  color: var(--muted);
}

.bar-row {
  display: grid;
  grid-template-columns: 82px calc(100% - 136px) 34px;
  gap: 10px;
  align-items: center;
  margin: 12px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.bar-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-row strong {
  color: var(--text);
  text-align: right;
}

.bar-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
}

.bar-track i {
  display: block;
  height: 100%;
  min-width: 3px;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--blue));
}

.empty-chart {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.empty-chart span {
  display: block;
  height: 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
}

.empty-chart span:nth-child(1) { width: 78%; }
.empty-chart span:nth-child(2) { width: 52%; }
.empty-chart span:nth-child(3) { width: 64%; }

.plan-add-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.plan-add-form > * {
  flex: 1 1 120px;
}

.plan-grid {
  display: grid;
  grid-template-columns: calc(50% - 9px) calc(50% - 9px);
  gap: 18px;
}

.plan-editor {
  display: grid;
  gap: 14px;
}

.plan-editor-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.plan-editor-head h2 {
  margin: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: calc(50% - 6px) calc(50% - 6px);
  gap: 12px;
}

.profile-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 20px;
  align-items: start;
}

.profile-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.profile-hero h2 {
  margin: 0 0 4px;
}

.avatar {
  width: 78px;
  height: 78px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.14);
  background: var(--surface-2);
}

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

.mini-stats span {
  display: grid;
  gap: 5px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  background: rgba(255,255,255,.035);
  color: var(--muted);
  padding: 12px;
  font-size: 13px;
  font-weight: 750;
}

.mini-stats strong {
  color: var(--text);
  font-size: 24px;
}

.clean-list {
  list-style: none;
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
}

.clean-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  padding: 8px 0;
  color: var(--muted);
}

.clean-list li:last-child {
  border-bottom: 0;
}

.clean-list span,
.muted {
  color: var(--subtle);
  font-size: 13px;
}

.danger-zone {
  border-color: rgba(255, 107, 107, .32);
}

.button.danger,
button.danger {
  background: rgba(255, 107, 107, .18);
  color: #ffe2e2;
  border: 1px solid rgba(255, 107, 107, .34);
  box-shadow: none;
}

.button.danger:hover,
button.danger:hover {
  color: #fff;
  background: rgba(255, 107, 107, .26);
}

@media (max-width: 860px) {
  .hero, .two-col, .detail-grid, .feature-grid, .analytics-grid, .plan-grid, .summary-grid, .profile-grid {
    grid-template-columns: 100%;
  }

  .hero {
    padding: 34px 0;
    min-height: auto;
  }

  .hero-panel { order: -1; }

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

  .topbar nav { width: 100%; }
  .topbar nav a { padding: 7px 8px; }

  .stats { grid-template-columns: calc(50% - 7px) calc(50% - 7px); }

  .admin-user-toolbar {
    grid-template-columns: 100%;
  }

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

  .inline-form {
    width: 100%;
    flex-direction: column;
  }

  .plan-add-form {
    flex-direction: column;
  }
}

@media (max-width: 980px) {
  body.app-layout .topbar {
    width: 100%;
    height: auto;
    bottom: auto;
    z-index: 20;
    padding: 12px;
    border-right: 0;
    border-bottom: 1px solid rgba(255,255,255,.08);
  }

  body.app-layout .brand {
    padding-bottom: 0;
  }

  .sidebar-toggle {
    display: inline-flex;
  }

  .sidebar-panel {
    display: none;
    max-height: calc(100vh - 120px);
    overflow: auto;
  }

  body.sidebar-open .sidebar-panel {
    display: grid;
  }

  body.app-layout .shell {
    margin-left: 0;
    padding: 118px 16px 56px;
  }
}

@media (max-width: 520px) {
  .shell {
    width: auto;
    max-width: calc(100% - 24px);
    padding-top: 24px;
  }

  .stats { grid-template-columns: 100%; }
  .hero h1 { font-size: 56px; }
  .hero-panel, .panel, .auth-card, .feature-grid article { padding: 18px; }
  .actions, .toolbar { align-items: stretch; flex-direction: column; }
  .actions .button, .toolbar .button { width: 100%; }
}
