:root {
  --bg: #0a1016;
  --bg-deep: #06090d;
  --card: #151b24;
  --card-edge: #1f2733;
  --ink: #e6edf6;
  --muted: #8b98ad;
  --accent: #14c8a2;
  --accent-2: #29d3ff;
  --border: #2a3342;
  --card-font: "IBM Plex Sans", "Segoe UI", sans-serif;
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
}

* { box-sizing: border-box; }

html {
  background-color: var(--bg-deep);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", "IBM Plex Sans", "Segoe UI", sans-serif;
  background:
    radial-gradient(900px 500px at 15% 10%, rgba(20, 200, 162, 0.12), transparent 60%),
    radial-gradient(800px 500px at 85% 10%, rgba(41, 211, 255, 0.12), transparent 60%),
    linear-gradient(120deg, var(--bg-deep), var(--bg));
  color: var(--ink);
  background-color: var(--bg-deep);
}

img {
  max-width: 100%;
  height: auto;
}

body::before {
  content: "";
  position: fixed;
  inset: -100px;
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: radial-gradient(circle at center, rgba(0,0,0,0.8), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

html, body {
  width: 100%;
  height: 100%;
}

.app-shell {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
  width: 100%;
}

.sidebar {
  flex: 0 0 240px;
  padding: calc(20px + var(--safe-top)) 16px 20px;
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, #121826, #0e141f 60%, #0b111b);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  height: 100vh;
  transition: width 220ms ease, padding 220ms ease;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 12, 0.55);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
  z-index: 20;
}

.sidebar-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 18px;
}

.brand-block {
  display: grid;
  gap: 4px;
}

.brand-title {
  font-weight: 700;
  letter-spacing: 0.4px;
  color: #3de8c4;
  font-size: 1.1rem;
}

.brand-sub {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #6d7c93;
}

.brand-by {
  font-size: 7px;
  letter-spacing: 0.08em;
  color: #7f8da6;
  text-transform: uppercase;
}

.sidebar-toggle {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid #202b3f;
  background: linear-gradient(180deg, #1a2232, #141b28);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #b9c7de;
  cursor: pointer;
  transition: transform 220ms ease, background 220ms ease, border-color 220ms ease;
  box-shadow: 0 6px 16px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.04);
}

.sidebar-toggle .icon {
  width: 14px;
  height: 14px;
  stroke: #cfe1ff;
  stroke-width: 2.4;
  fill: none;
}

.content {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  flex: 1 1 auto;
  width: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(16px + var(--safe-top)) 24px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 20, 28, 0.9);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
  width: 100%;
}

.mobile-menu-toggle {
  display: inline-flex;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(20, 200, 162, 0.6);
  background: linear-gradient(180deg, rgba(20, 200, 162, 0.18), rgba(20, 200, 162, 0.05));
  align-items: center;
  justify-content: center;
  color: var(--accent);
  cursor: pointer;
  flex: 0 0 auto;
  z-index: 12;
}

.mobile-menu-toggle .icon {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.page-title {
  font-weight: 600;
  color: var(--accent);
}

.page-title-wrap {
  display: grid;
  gap: 4px;
}

.page-subtitle {
  color: var(--muted);
  font-size: 0.88rem;
}

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

.desktop-only {
  display: flex;
}

.mobile-only {
  display: none;
}

.sidebar-actions {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid #1f2b3f;
  display: grid;
  gap: 10px;
}

.sidebar-actions .search {
  width: 100%;
}

.search {
  width: 220px;
  background: #0f1520;
}

.user-pill {
  padding: 6px 10px;
  border-radius: 12px;
  background: #12202a;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.85rem;
}

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

.nav .nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #c8d5ea;
  padding: 10px 12px;
  border-radius: 12px;
  background: transparent;
  border: 1px solid transparent;
  font-weight: 500;
}

.nav .nav-item .icon {
  width: 18px;
  height: 18px;
  stroke: #26d9b8;
  stroke-width: 2;
  fill: none;
}

.nav .nav-item:hover {
  background: #141c2b;
  border-color: #1f2b3f;
}

.nav .nav-item.active {
  background: #1b2332;
  border-color: #243148;
  color: #ffffff;
}

/* Collapsed sidebar */
.sidebar.is-collapsed {
  flex-basis: 72px;
  padding: 20px 10px;
}

.sidebar.is-collapsed .brand-block,
.sidebar.is-collapsed .nav .nav-item span {
  display: none;
}

.sidebar.is-collapsed .sidebar-top {
  justify-content: center;
}

.sidebar.is-collapsed .sidebar-toggle {
  transform: rotate(180deg);
}

.sidebar.is-collapsed .nav .nav-item {
  justify-content: center;
  padding: 10px;
}

.logout {
  margin-top: 16px;
  display: grid;
  gap: 8px;
}

.container {
  padding: 24px;
  position: relative;
  z-index: 1;
  width: 100%;
}

.card {
  background: var(--card);
  border: 1px solid var(--card-edge);
  padding: 20px;
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.35);
  font-family: var(--card-font);
}

.section-gap {
  margin-top: 16px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header.align-right {
  justify-content: flex-end;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  table-layout: fixed;
}

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

th {
  color: var(--muted);
  font-weight: 500;
}
/* Table styles kept for other pages if any */

.actions a { margin-right: 0; }

/* Table responsive helpers */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-wrap table {
  min-width: 640px;
}

.form {
  display: grid;
  gap: 12px;
  max-width: 520px;
}

.form.inline {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  max-width: none;
}

input, textarea, select {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #101622;
  color: var(--ink);
  font-size: 0.95rem;
}

input::placeholder, textarea::placeholder {
  color: #5f6b7f;
}

button, .btn {
  background: linear-gradient(90deg, var(--accent), #19d7a9);
  color: #06251f;
  border: none;
  padding: 12px 16px;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  font-weight: 600;
}

.btn.danger {
  background: linear-gradient(90deg, #ff8c8c, #f25f7d);
  color: #2b0a0f;
}

.btn.ghost {
  background: #0f1520;
  color: var(--ink);
  border: 1px solid var(--border);
}

.error { color: #b91c1c; }

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

.mono { font-family: "IBM Plex Mono", "Courier New", monospace; font-size: 0.9rem; }

.badge {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 6px;
  border-radius: 4px;
  background: #2b1f10;
  color: #f4c36b;
  font-size: 0.75rem;
}

.chart { margin-top: 12px; }

.bar {
  display: grid;
  grid-template-columns: 110px 1fr 60px;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.bar-track {
  height: 10px;
  background: #e5e7eb;
  border-radius: 6px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--accent);
}

@media (min-width: 1025px) {
  .mobile-menu-toggle { display: none; }
}

@media (max-width: 820px) {
  .form.inline { grid-template-columns: 1fr; }
  .bar { grid-template-columns: 1fr; }
  .app-shell { flex-direction: column; }
  body.is-drawer-open { overflow: hidden; }
  .topbar { padding-left: 64px; }
  .desktop-only { display: none; }
  .mobile-only { display: grid; }
  .mobile-menu-toggle {
    position: fixed;
    top: calc(12px + var(--safe-top));
    left: 12px;
    z-index: 40;
    box-shadow: 0 10px 24px rgba(0,0,0,0.35);
  }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    border-right: 1px solid var(--border);
    border-bottom: none;
    transform: translateX(-100%);
    z-index: 30;
    width: 260px;
    max-width: 80vw;
    transition: transform 200ms ease;
  }
  .sidebar.is-open {
    transform: translateX(0);
  }
  .topbar { position: relative; }
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
}

/* Dashboard */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.page-head h1 {
  margin: 0;
  color: var(--accent);
}

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

.page-actions.align-right {
  justify-content: flex-end;
  margin-left: auto;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  background: linear-gradient(180deg, #141b27, #111722);
}

.stat-label {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  margin: 6px 0;
}

.grid-two {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 12px;
}

.list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0f1520;
}

.recent-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.qr-thumb {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #0b111a;
  border: 1px solid #1f2b3f;
  flex: 0 0 auto;
}

.recent-left .muted {
  word-break: break-all;
}

.pill {
  padding: 4px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
}

.pill-ok { background: #0d2c24; color: #1ad9a6; }
.pill-warn { background: #2b1f10; color: #f4c36b; }

.empty-box {
  margin-top: 12px;
  padding: 24px;
  border: 1px dashed var(--border);
  border-radius: 10px;
}

.link {
  color: var(--accent);
  text-decoration: none;
}

.inline-form {
  display: inline;
}

.link-danger {
  background: transparent;
  color: #f87171;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
}

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

.action-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  background: linear-gradient(180deg, #141c2b, #0f1623);
  border: 1px solid #1f2b3f;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.action-chip a {
  color: #d7e6ff;
  text-decoration: none;
  font-weight: 600;
}

.action-chip .icon {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  opacity: 0.9;
}

.action-chip .action-select {
  background: #0b1220;
  border: 1px solid #223048;
  color: #d7e6ff;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.action-chip:hover {
  border-color: rgba(20, 200, 162, 0.55);
  box-shadow: 0 0 0 2px rgba(20, 200, 162, 0.12);
  background: linear-gradient(180deg, #182235, #111a29);
}

.action-chip.danger {
  background: linear-gradient(180deg, #241217, #1b0f13);
  border-color: #3a1a21;
}

.action-chip.danger button {
  background: transparent;
  border: none;
  color: #ff8c8c;
  cursor: pointer;
  padding: 0;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.action-chip.danger .icon {
  stroke: #ff8c8c;
}

/* QR cards */
.qr-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 12px;
}

.qr-card {
  background: linear-gradient(180deg, #141b27, #111722);
  border: 1px solid var(--card-edge);
  border-radius: 16px;
  padding: 0;
  box-shadow: 0 12px 30px rgba(0,0,0,0.28);
  display: grid;
  grid-template-rows: 220px auto;
  overflow: visible;
  font-family: var(--card-font);
}

.qr-preview {
  width: 100%;
  height: 100%;
  background: transparent;
  border-bottom: 1px solid #1f2b3f;
  filter: saturate(1) contrast(1.05);
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow: hidden;
}

.qr-preview img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  display: block;
  background: transparent;
}

.qr-body {
  padding: 14px 16px 16px;
  display: grid;
  gap: 10px;
  background: linear-gradient(180deg, rgba(20,27,39,0.35), rgba(17,23,34,0.8));
}

.qr-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.qr-body .title {
  font-size: 1.12rem;
  font-weight: 600;
  letter-spacing: 0.008em;
  color: #eaf2ff;
}

.qr-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
  font-size: 0.9rem;
}

.qr-meta-wide {
  grid-column: 1 / -1;
}

.qr-meta .label {
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.qr-meta .mono,
.qr-meta .muted,
.qr-meta div {
  font-weight: 500;
  color: #dbe5f6;
}

.qr-meta .mono {
  font-size: 0.92rem;
  letter-spacing: 0.01em;
}

@media (max-width: 1100px) {
  .qr-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

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

.qr-menu {
  position: relative;
}

.menu-toggle {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid #1f2b3f;
  background: #141b28;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #cfe1ff;
  cursor: pointer;
}

.menu-toggle .icon {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.menu-panel {
  position: absolute;
  right: 0;
  top: 44px;
  min-width: 200px;
  background: linear-gradient(180deg, #151b28, #101621);
  border: 1px solid #1f2b3f;
  border-radius: 12px;
  padding: 8px;
  box-shadow: 0 18px 40px rgba(0,0,0,0.35);
  display: none;
  z-index: 20;
}

.menu-panel.is-open {
  display: grid;
  gap: 4px;
}

.menu-item {
  color: #d7e6ff;
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 10px;
  display: block;
  font-size: 0.88rem;
}

.menu-item:hover {
  background: #1b2332;
}

.menu-divider {
  height: 1px;
  background: #1f2b3f;
  margin: 4px 0;
}

.menu-label {
  padding: 6px 10px 2px;
  color: #7f8da6;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.menu-item.danger button {
  background: transparent;
  border: none;
  color: #ff8c8c;
  padding: 0;
  cursor: pointer;
  font-size: 0.88rem;
  width: 100%;
  text-align: left;
}

.menu-item.danger {
  background: transparent;
  border: none;
  color: #ff8c8c;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.88rem;
  width: 100%;
  text-align: left;
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(4, 8, 12, 0.6);
  backdrop-filter: blur(4px);
  z-index: 50;
}

.modal.is-open {
  display: flex;
}

.modal-card {
  width: min(560px, 92vw);
  background: linear-gradient(180deg, #151c27, #111722);
  border: 1px solid #253043;
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  font-family: var(--card-font);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.modal-close {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 8px;
}

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-two { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .container { padding: 16px; }
  .card { padding: 16px; }
  .form { gap: 14px; }
  input, textarea, select { padding: 14px 16px; font-size: 1rem; }
  button, .btn { padding: 14px 18px; font-size: 1rem; }
  .topbar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
  }
  .page-title-wrap { flex: 1 1 auto; min-width: 0; }
  .topbar-actions {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    order: 3;
  }
  .search { width: 100%; }
  .user-pill { text-align: center; }
  .page-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .page-actions { width: 100%; }
  .page-actions .btn,
  .page-actions .btn.ghost {
    width: 100%;
    text-align: center;
  }
  .list-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .qr-main { align-items: flex-start; }
  .qr-meta { grid-template-columns: 1fr; }
  .qr-meta-wide { grid-column: auto; }
  .modal-card {
    width: min(560px, 94vw);
    max-height: 90vh;
    overflow: auto;
  }
}

@media (max-width: 720px) {
  table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }
  table { width: 100%; }
  table tr {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px 10px;
    margin-bottom: 10px;
    background: #0f1520;
  }
  table td {
    border: none;
    padding: 6px 0;
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 10px;
    align-items: center;
    word-break: break-word;
  }
  table td::before {
    content: attr(data-label);
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.68rem;
  }
}

/* Login page */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: calc(32px + var(--safe-top)) 32px calc(32px + var(--safe-bottom));
  background:
    radial-gradient(900px 500px at 15% 10%, rgba(20, 200, 162, 0.18), transparent 60%),
    radial-gradient(800px 500px at 85% 10%, rgba(41, 211, 255, 0.16), transparent 60%),
    linear-gradient(120deg, var(--bg-deep), var(--bg));
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: "";
  position: absolute;
  inset: -100px;
  background-image:
    linear-gradient(rgba(255,255,255,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.06) 1px, transparent 1px);
  background-size: 40px 40px;
  opacity: 0.7;
  pointer-events: none;
}

.login-card {
  width: 420px;
  max-width: 92vw;
  min-height: 360px;
  padding: 26px 26px 20px;
  border-radius: 16px;
  background: linear-gradient(180deg, #151c27, #111722);
  border: 1px solid #253043;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  position: relative;
  z-index: 1;
  font-family: var(--card-font);
}

@media (max-width: 720px) {
  .login-page {
    padding: 20px;
  }
  .login-card {
    width: 100%;
    min-height: auto;
    padding: 22px 18px;
  }
}

.login-title {
  margin: 0 0 6px 0;
  font-size: 1.5rem;
}

.login-sub {
  color: var(--muted);
  margin: 0 0 14px 0;
}

.login-brand {
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.3px;
  font-size: 0.95rem;
}

.login-brand-sub {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #6d7c93;
  margin-top: 2px;
}

.login-brand-by {
  font-size: 7px;
  letter-spacing: 0.08em;
  color: #7f8da6;
  text-transform: uppercase;
  margin-top: 2px;
}

.login-note {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.85rem;
}
