/* ==========================================================================
   FUTRWORKS Admin Portal — Sidebar Command layout
   ========================================================================== */

:root {
  --font-sans: "Plus Jakarta Sans", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;

  /* Surfaces */
  --canvas: #f6f5f1;
  --surface: #ffffff;
  --surface-subtle: #faf9f7;
  --sidebar: #14150e;

  /* Ink / text */
  --ink: #17180f;
  --ink-soft: #3a3830;
  --muted: #6d6c67;
  --muted-2: #8a8680;
  --muted-3: #9a9690;

  /* Lines */
  --line: #e8e5df;
  --line-soft: #f2f0ec;
  --line-strong: #e0ddd7;

  /* Brand */
  --accent: #4a7a5a;
  --accent-strong: #1d6940;

  /* Status palettes */
  --ok-bg: #e4f0e8;
  --ok-fg: #1d6940;
  --neutral-bg: #f2f0ed;
  --neutral-fg: #7a7770;
  --warn-fg: #a06020;
  --warn-bg: #fff3e0;
  --info-bg: #eeeeff;
  --info-fg: #4444aa;

  /* On-dark (sidebar) */
  --on-dark: rgba(255, 255, 255, 0.9);
  --on-dark-muted: rgba(255, 255, 255, 0.38);
  --on-dark-faint: rgba(255, 255, 255, 0.22);
  --on-dark-line: rgba(255, 255, 255, 0.06);
  --on-dark-active: rgba(255, 255, 255, 0.1);

  --radius: 6px;
  --radius-sm: 5px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button {
  font-family: inherit;
}

/* ---- App shell --------------------------------------------------------- */

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* The explicit display above beats the `hidden` attribute, so restore it for
   the login gate (which toggles #app hidden until a session exists). */
.app[hidden] {
  display: none;
}

/* ---- Sidebar ----------------------------------------------------------- */

.sidebar {
  width: 212px;
  flex: none;
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 22px 18px 18px;
  border-bottom: 1px solid var(--on-dark-line);
}

/* Close button lives inside the drawer; hidden on desktop */
.sidebar__close {
  display: none;
  margin-left: auto;
  width: 30px;
  height: 30px;
  font-size: 22px;
  line-height: 1;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--on-dark-muted);
  cursor: pointer;
}

.sidebar__close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

/* Drawer backdrop (mobile only) */
.nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 21, 14, 0.45);
  z-index: 40;
  border: none;
}

.nav-backdrop[hidden] {
  display: none;
}

.brand__mark {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.brand__name {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.03em;
}

.brand__sub {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.3);
}

.sidebar__nav {
  padding: 14px 10px;
  flex: 1;
  overflow-y: auto;
}

.nav__group-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--on-dark-faint);
  padding: 0 8px;
  margin-bottom: 6px;
}

.nav__group + .nav__group {
  margin-top: 14px;
}

.nav__item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  margin-bottom: 2px;
  cursor: pointer;
  color: var(--on-dark-muted);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.nav__item svg {
  flex: none;
}

.nav__item:hover {
  color: var(--on-dark);
  background: rgba(255, 255, 255, 0.05);
}

.nav__item[aria-selected="true"] {
  background: var(--on-dark-active);
  color: var(--on-dark);
}

.nav__item--link {
  text-decoration: none;
}

.nav__item-ext {
  margin-left: auto;
  opacity: 0.5;
}

.nav__item--link:hover .nav__item-ext {
  opacity: 1;
}

.sidebar__user {
  padding: 14px 16px;
  border-top: 1px solid var(--on-dark-line);
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  flex: none;
}

.sidebar__user .avatar {
  background: var(--accent);
}

.user__name {
  font-size: 12px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.75);
}

.user__meta {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.28);
}

/* ---- Main area --------------------------------------------------------- */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--canvas);
  overflow: hidden;
  min-width: 0;
}

.topbar {
  height: 52px;
  flex: none;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 24px;
}

/* Hamburger — hidden on desktop, shown when the sidebar collapses to a drawer */
.topbar__menu {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: none;
  margin-left: -8px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
}

.topbar__menu:hover {
  background: var(--neutral-bg);
}

.subnav {
  display: flex;
  height: 100%;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.subnav::-webkit-scrollbar {
  display: none;
}

.subnav__group {
  display: flex;
  height: 100%;
}

.subnav__group[hidden] {
  display: none;
}

.subtab {
  padding: 0 16px;
  height: 52px;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 400;
  color: var(--neutral-fg);
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: color 0.15s;
}

.subtab:hover {
  color: var(--ink);
}

.subtab[aria-selected="true"] {
  font-weight: 600;
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.subtab--link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
}

.subtab--link svg {
  opacity: 0.55;
}

.subtab--link:hover svg {
  opacity: 1;
}

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

.topbar__date {
  font-size: 12px;
  color: var(--muted-3);
  white-space: nowrap;
}

/* ---- Buttons ----------------------------------------------------------- */

.btn {
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn--primary {
  padding: 6px 14px;
  background: var(--sidebar);
  color: #fff;
  border: 1px solid var(--sidebar);
}

.btn--primary:hover {
  background: #000;
}

.btn--ghost {
  padding: 5px 12px;
  background: var(--surface);
  color: var(--ink-soft);
  border: 1px solid var(--line-strong);
}

.btn--ghost:hover {
  border-color: var(--muted-3);
}

.btn--danger {
  padding: 5px 12px;
  background: var(--surface);
  color: #b42318;
  border: 1px solid #f0c4bf;
}

.btn--danger:hover {
  background: #fdeceb;
  border-color: #e4998f;
}

/* ---- Content + panels -------------------------------------------------- */

.content {
  flex: 1;
  overflow-y: auto;
  padding: 22px 24px;
}

.panel {
  animation: fadeUp 0.18s ease;
}

.panel[hidden] {
  display: none;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

.section-head__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 12px;
}

.section + .section {
  margin-top: 22px;
}

.count-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
}

.head-with-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

/* ---- Placeholder pages ------------------------------------------------- */

.placeholder {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
}

.placeholder__text {
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
}

/* ---- Table card -------------------------------------------------------- */

/* Wrapper allows the grid table to scroll horizontally on narrow viewports
   before it falls back to the stacked-card layout. */
.table-wrap {
  width: 100%;
}

/* QR keys are grouped into Valid / Upcoming / Past sections, each spaced out. */
.qr-section + .qr-section {
  margin-top: 22px;
}

.section-subhead {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted-3, #8a857d);
  margin: 0 0 8px;
}

.table-more {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}


.table {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.table__head,
.table__row {
  display: grid;
  align-items: center;
  padding: 10px 16px;
}

.table__head {
  padding: 8px 16px;
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--line);
}

.table__row {
  border-bottom: 1px solid var(--line-soft);
}

.table__row:last-child {
  border-bottom: none;
}

.table__row--dim {
  opacity: 0.5;
}

.th {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.cell {
  font-size: 12px;
  color: var(--muted);
}

.cell--primary {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}

.cell--ink {
  font-size: 12px;
  color: var(--ink);
}

.cell--link {
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
}

.cell-stack__title {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}

.cell-stack__sub {
  font-size: 11px;
  color: var(--muted-3);
}

.cell-chip {
  display: flex;
  align-items: center;
  min-width: 0;
}

.cell-user {
  display: flex;
  align-items: center;
  gap: 9px;
}

.cell-user .avatar {
  width: 26px;
  height: 26px;
  font-size: 10px;
}

/* Column templates per table */
.table--qr .table__head,
.table--qr .table__row {
  grid-template-columns:
    100px minmax(200px, 300px) 120px 120px 76px 120px 1fr;
}

.table--deliveries .table__head,
.table--deliveries .table__row {
  grid-template-columns: 100px 76px 130px 1fr 90px;
}

.table--members .table__head,
.table--members .table__row {
  grid-template-columns: 1.8fr 1.2fr 120px 80px 80px;
}

.table--bookings .table__head,
.table--bookings .table__row {
  grid-template-columns: 1.5fr 180px 1fr 90px;
}

.table--facereg .table__head,
.table--facereg .table__row {
  grid-template-columns: 1.8fr 1.2fr 110px 130px;
}

.table--leaving .table__head,
.table--leaving .table__row {
  grid-template-columns: 1.8fr 1.2fr 110px 110px;
}

.table--sms-history .table__head,
.table--sms-history .table__row {
  grid-template-columns: 110px 1.3fr 120px 100px 1.1fr 90px 120px;
}

/* ---- Day Pass weekly summary (accordion) ------------------------------ */

.section-head__meta {
  font-size: 12px;
  color: var(--muted-2);
}

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

.head-select {
  font-family: inherit;
  font-size: 12px;
  color: var(--ink);
  padding: 5px 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
}

.head-select:focus {
  outline: none;
  border-color: var(--accent);
}

.daypass-nav__range {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  min-width: 124px;
  text-align: center;
}

.daypass-nav__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  font-size: 16px;
  line-height: 1;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.daypass-nav__btn:hover {
  background: var(--surface-subtle);
  border-color: var(--accent-strong);
}

.acc {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.acc-row + .acc-row {
  border-top: 1px solid var(--line);
}

.acc-row__head {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 13px 16px;
  background: none;
  border: 0;
  text-align: left;
  cursor: pointer;
  color: var(--ink);
  transition: background 0.12s;
}

.acc-row__head:hover {
  background: var(--surface-subtle);
}

.acc-row__head:disabled {
  cursor: default;
}

.acc-row--open {
  box-shadow: inset 3px 0 0 var(--accent-strong);
}

.acc-row--open > .acc-row__head {
  background: var(--surface-subtle);
}

.acc-row__chev {
  flex: none;
  width: 14px;
  font-size: 16px;
  line-height: 1;
  color: var(--muted-2);
  transition: transform 0.15s ease;
}

.acc-row--open .acc-row__chev {
  transform: rotate(90deg);
}

.acc-row__date {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.acc-row__weekday {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  width: 34px;
}

.acc-row__day {
  font-size: 13px;
  color: var(--muted-2);
}

.acc-row__today {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-strong);
  border: 1px solid var(--accent-strong);
  border-radius: 999px;
  padding: 1px 7px;
}

.acc-row__title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.acc-row__name {
  flex: 0 1 auto;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.acc-row__sub {
  flex: none;
  font-size: 12px;
  color: var(--muted-3);
}

.acc-row__meta {
  flex: none;
  display: flex;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
}

/* Company rows carry a status badge in the meta slot, which reads better
   center-aligned against the count than the date-accordion's baseline. */
#phonereg-accordion .acc-row__meta {
  align-items: center;
  gap: 10px;
}

.acc-row__count {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

.acc-row__count-label {
  font-size: 11px;
  color: var(--muted-2);
}

.acc-row__canceled {
  font-size: 11px;
  color: var(--muted-3);
}

.acc-row--empty .acc-row__weekday,
.acc-row--empty .acc-row__day {
  color: var(--muted-3);
}

.acc-row__none {
  font-size: 12px;
  color: var(--muted-3);
}

.acc-row__body {
  padding: 4px 16px 14px 44px;
}

.acc-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.acc-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 14px;
  padding: 9px 0;
  border-top: 1px solid var(--line-soft);
}

.acc-item:first-child {
  border-top: 0;
}

.acc-item--dim {
  opacity: 0.55;
}

.acc-item__id {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.acc-item__name {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}

.acc-item__email {
  font-size: 11px;
  color: var(--muted-3);
}

.acc-item__phone {
  font-size: 11px;
  color: var(--muted-3);
}

.acc-item__price {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  min-width: 92px;
  text-align: right;
}

.acc-empty {
  font-size: 12px;
  color: var(--muted-3);
  padding: 4px 0;
}

/* ---- Badges / tags ----------------------------------------------------- */

.badge {
  display: inline-flex;
  width: fit-content;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 12px;
}

.badge--ok {
  background: var(--ok-bg);
  color: var(--ok-fg);
}

.badge--neutral {
  background: var(--neutral-bg);
  color: var(--neutral-fg);
}

.badge--warn {
  background: var(--warn-bg);
  color: var(--warn-fg);
}

.tag {
  display: inline-flex;
  width: fit-content;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 3px;
}

.tag--delivery {
  background: var(--info-bg);
  color: var(--info-fg);
}

.tag--visitor {
  background: var(--warn-bg);
  color: var(--warn-fg);
}

.status {
  font-size: 12px;
  font-weight: 500;
}

.status--ok {
  color: var(--ok-fg);
}

.status--warn {
  color: var(--warn-fg);
}

.status--muted {
  color: var(--muted);
}

/* ---- Stat cards (Facility) -------------------------------------------- */

.stats {
  display: flex;
  gap: 12px;
  margin-bottom: 22px;
}

.stat {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.stat__label {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.stat__value {
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
}

.stat__value--accent {
  color: var(--accent-strong);
}

.stat__value--warn {
  color: var(--warn-fg);
}

/* ---- Face Registration (onboarding funnel) ---------------------------- */

/* Equal-width stat cards even when there are four of them. */
.stats--facereg .stat {
  flex: 1 1 0;
  min-width: 0;
}

/* Sub-header row above the member list: title on the left, filter on the right. */
.section-head--sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-head--sub .section-subhead {
  margin: 0;
}

.stat__hint {
  font-size: 11px;
  color: var(--muted-3);
  margin-top: 4px;
}

/* ---- Questions list ---------------------------------------------------- */

.qlist {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.qrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.qrow:last-child {
  border-bottom: none;
}

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

.qrow__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
}

.qrow__subject {
  font-size: 13px;
  color: var(--ink);
}

.qrow__subject--unread {
  font-weight: 600;
}

.qrow__meta {
  font-size: 11px;
  color: var(--muted-3);
  margin-top: 2px;
}

/* ---- Responsive -------------------------------------------------------- */

/* Tablet / mobile: sidebar collapses into a slide-in drawer and the data
   tables reflow into stacked cards so everything is reachable one-handed. */
@media (max-width: 860px) {
  .topbar__menu {
    display: flex;
  }

  .sidebar__close {
    display: flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    width: 256px;
    max-width: 82vw;
    transform: translateX(-100%);
    transition: transform 0.24s ease;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.35);
  }

  .app.nav-open .sidebar {
    transform: translateX(0);
  }

  .topbar {
    padding: 0 16px;
  }

  .content {
    padding: 18px 16px;
  }

  /* --- Card-style tables --- */
  .table {
    border: none;
    background: transparent;
    border-radius: 0;
    overflow: visible;
  }

  .table__head {
    display: none;
  }

  .table--qr .table__row,
  .table--deliveries .table__row,
  .table--members .table__row,
  .table--facereg .table__row,
  .table--leaving .table__row,
  .table--sms-history .table__row,
  .table--bookings .table__row {
    display: block;
    grid-template-columns: none;
    padding: 0;
    margin-bottom: 10px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
  }

  .table__row:last-child {
    margin-bottom: 0;
  }

  .table__row > * {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-width: 0;
    padding: 9px 14px;
    border-top: 1px solid var(--line-soft);
  }

  .table__row > *::before {
    content: attr(data-label);
    flex: none;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted-2);
  }

  /* First cell acts as the card header */
  .table__row > *:first-child {
    justify-content: flex-start;
    padding: 11px 14px;
    background: var(--surface-subtle);
    border-top: none;
    border-bottom: 1px solid var(--line);
  }

  .table__row > *:first-child::before {
    display: none;
  }

  /* Stacked title/subtitle header (e.g. Facility bookings) */
  .table__row > .cell-stack:first-child {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  /* Row action buttons: right-aligned, no label */
  .table__row > .cell--actions {
    justify-content: flex-end;
  }

  .table__row > .cell--actions::before {
    display: none;
  }

  .table__empty {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
  }

  .stats {
    flex-wrap: wrap;
  }

  .stat {
    min-width: 120px;
  }
}

@media (max-width: 560px) {
  .topbar__date {
    display: none;
  }

  .stats {
    flex-direction: column;
  }

  .section-head {
    gap: 10px;
  }
}

/* ---- Row actions + empty state ---------------------------------------- */

.cell--actions {
  display: flex;
  gap: 14px;
  justify-content: flex-end;
  white-space: nowrap;
}

.link-btn {
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.link-btn:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

.link-btn:disabled {
  color: var(--muted-3);
  cursor: default;
  text-decoration: none;
}

.table__empty {
  padding: 18px 16px;
  font-size: 13px;
  color: var(--muted);
}

.table__empty--error {
  color: var(--warn-fg);
}

/* ---- Modal ------------------------------------------------------------- */

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 21, 14, 0.45);
}

.modal__panel {
  position: relative;
  width: min(420px, calc(100vw - 32px));
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: 0 20px 50px rgba(20, 21, 14, 0.25);
  padding: 20px;
}

.modal__panel--qr {
  width: min(340px, calc(100vw - 32px));
  text-align: center;
}

.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  margin: 0;
}

.modal__close {
  font-size: 20px;
  line-height: 1;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
}

.modal__close:hover {
  color: var(--ink);
}

/* ---- Form -------------------------------------------------------------- */

.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.field__label {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-soft);
}

.field__hint {
  color: var(--muted-3);
  font-weight: 400;
}

.field__input {
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.field__input:focus {
  outline: none;
  border-color: var(--accent);
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

/* Locked toggle (e.g. expired/past keys): visible but not interactive. */
.switch--disabled {
  cursor: default;
  opacity: 0.45;
}

.switch__input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  margin: 0;
}

.switch__track {
  position: relative;
  flex: none;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: var(--muted-3);
  transition: background 0.15s;
}

.switch__thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s;
}

.switch__input:checked + .switch__track {
  background: var(--ok-fg);
}

.switch__input:checked + .switch__track .switch__thumb {
  transform: translateX(18px);
}

.switch__input:focus-visible + .switch__track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.switch__text {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}

/* Compact switch for inline use in table rows */
.switch--sm {
  gap: 8px;
}

.switch--sm .switch__track {
  width: 34px;
  height: 20px;
}

.switch--sm .switch__thumb {
  width: 16px;
  height: 16px;
}

.switch--sm .switch__input:checked + .switch__track .switch__thumb {
  transform: translateX(14px);
}

.switch--sm .switch__text {
  font-size: 12px;
  color: var(--muted);
}

.form__error {
  font-size: 12px;
  color: var(--warn-fg);
  margin: 0;
  min-height: 14px;
}

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

/* Destructive action sits apart, pushed to the opposite end. */
.form__actions #qr-delete:not([hidden]) {
  margin-right: auto;
}

.qr-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.qr-view svg {
  display: block;
  width: 100%;
  height: auto;
  max-width: 300px;
}

.qr-view__code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--ink);
  background: var(--surface-2, #f4f2ee);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
}

/* ---- Section head with multiple actions -------------------------------- */

.section-head__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---- Print QR codes modal ---------------------------------------------- */

.modal__panel--print {
  width: min(460px, calc(100vw - 32px));
}

.print-hint {
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  margin: 0 0 14px;
}

.print-list {
  display: flex;
  flex-direction: column;
  max-height: 46vh;
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}

.print-pick {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.print-list .print-pick:last-child {
  border-bottom: none;
}

.print-pick--all {
  border: none;
  padding: 2px 2px 4px;
  font-weight: 600;
}

.print-pick__check {
  flex: none;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.print-pick__name {
  flex: 1;
  font-size: 13px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.print-pick__type {
  flex: none;
  font-size: 11px;
  color: var(--muted-3);
}

.print-pick__qty {
  flex: none;
  display: flex;
  align-items: center;
  gap: 5px;
}

.print-pick__qty-input {
  width: 56px;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  padding: 4px 6px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.print-pick__qty-input:disabled {
  background: var(--surface-subtle);
  color: var(--muted-3);
}

.print-pick__qty-label {
  font-size: 11px;
  color: var(--muted-3);
}

.print-total {
  margin-right: auto;
  font-size: 12px;
  color: var(--muted);
}

/* ---- Print sheet (A4, 10 cards per page: 2 columns x 5 rows) ----------- */

/* Hidden on screen; only revealed inside the print media query below. */
.print-sheet {
  display: none;
}

@media print {
  /* Hide the live app + modals; show only the generated print sheet. */
  .app,
  .modal {
    display: none !important;
  }

  html,
  body {
    background: #fff;
    margin: 0;
    padding: 0;
  }

  @page {
    size: A4;
    margin: 8mm;
  }

  .print-sheet {
    display: block;
  }

  .print-page {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    /* Left-align so an incomplete last row sits under the left column
       instead of centering in the gap. */
    justify-content: flex-start;
    gap: 4mm;
    width: 100%;
    box-sizing: border-box;
    break-after: page;
    page-break-after: always;
  }

  .print-page:last-child {
    break-after: auto;
    page-break-after: auto;
  }

  /* Fixed 83mm x 51mm (landscape) card so it fits a standard card holder when cut out. */
  .print-badge {
    flex: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 83mm;
    height: 51mm;
    padding: 4mm 3mm 1mm;
    box-sizing: border-box;
    /* Dashed guides so admins can cut the page into cards. */
    border: 0.3mm dashed #9a9690;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .print-badge__name {
    max-width: 100%;
    font-size: 11pt;
    font-weight: 600;
    text-align: center;
    color: #14150e;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
  }

  /* Pushed to the dead bottom of the card, 1mm above the edge (see .print-badge padding-bottom). */
  .print-badge__qr {
    width: 28mm;
    height: 28mm;
    margin-top: auto;
  }

  .print-badge__qr svg {
    display: block;
    width: 100%;
    height: 100%;
  }
}

/* ---- Sidebar user + sign out ------------------------------------------- */
.sidebar__user-id {
  flex: 1;
  min-width: 0;
}

.sidebar__user-id .user__name,
.sidebar__user-id .user__meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar__signout {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--on-dark-line);
  color: var(--on-dark-muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.sidebar__signout:hover {
  color: var(--on-dark);
  border-color: var(--on-dark-faint);
  background: var(--on-dark-active);
}

/* ---- Admins table ------------------------------------------------------ */
.table--admins .table__head,
.table--admins .table__row {
  grid-template-columns: minmax(140px, 1fr) minmax(180px, 1.4fr) 110px 130px auto;
}

.link-btn--danger {
  color: #b42318;
}

.link-btn--danger:hover {
  color: #911b13;
}

/* ---- Invite result ----------------------------------------------------- */
.invite-result__hint {
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  margin: 0 0 12px;
}

.invite-result__row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.invite-result__row .field__input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
}

/* ---- Login gate -------------------------------------------------------- */
.login-gate[hidden] {
  display: none;
}

.login-gate {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--canvas);
}

.login-card {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 20px 50px rgba(20, 21, 14, 0.12);
  padding: 28px;
}

.login-card__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}

.login-card__brand .brand__mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--sidebar);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.login-card__brand .brand__name {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.02em;
}

.login-card__brand .brand__sub {
  font-size: 11px;
  color: var(--muted);
}

.login-card__title {
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 18px;
}

.login-card__submit {
  width: 100%;
  padding: 9px 14px;
  margin-top: 4px;
}

/* ---- Usage Upload (Invoices) ------------------------------------------- */

.usage-month {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.usage-month__label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-2);
}

.usage-month__value {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.usage-intro {
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
  max-width: 640px;
  margin-bottom: 16px;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 36px 24px;
  text-align: center;
  background: var(--surface);
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  transition: border-color 0.15s, background 0.15s;
}

.dropzone--drag {
  border-color: var(--accent);
  background: var(--ok-bg);
}

.dropzone__icon {
  color: var(--muted-2);
  margin-bottom: 4px;
}

.dropzone--drag .dropzone__icon {
  color: var(--accent-strong);
}

.dropzone__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.dropzone__hint {
  font-size: 12px;
  color: var(--muted-3);
}

.dropzone__meta {
  font-size: 12px;
  color: var(--muted-3);
  margin-top: 6px;
}

.dropzone__meta code,
.usage-intro code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  background: var(--neutral-bg);
  border-radius: 3px;
  padding: 1px 5px;
}

.usage-file {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

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

.usage-file__info svg {
  flex: none;
  color: var(--accent-strong);
}

.usage-file__name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.usage-file__meta {
  font-size: 12px;
  color: var(--muted-3);
  margin-top: 1px;
}

.usage-preview {
  margin-top: 22px;
}

.usage-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.usage-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.usage-table th,
.usage-table td {
  padding: 9px 14px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--line-soft);
}

.usage-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--line);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-2);
}

.usage-table tbody tr:last-child td {
  border-bottom: none;
}

.usage-table tbody tr:hover {
  background: var(--surface-subtle);
}

.usage-table td {
  color: var(--ink-soft);
}

.usage-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.usage-table tfoot td {
  font-weight: 600;
  color: var(--ink);
  background: var(--surface-subtle);
  border-top: 1px solid var(--line);
  border-bottom: none;
}

#usage-stats {
  margin-top: 18px;
}

.match-cell {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.match-ico {
  flex: none;
}

.match-ico--ok {
  color: var(--ok-fg);
}

.match-ico--no {
  color: var(--warn-fg);
}

.usage-match-msg {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  font-size: 12px;
  color: var(--muted);
}

.usage-match-msg--ok {
  color: var(--ok-fg);
}

.usage-match-msg--warn {
  color: var(--warn-fg);
}

.usage-match-msg--loading {
  color: var(--ink);
  font-weight: 500;
}

.spinner {
  flex: none;
  width: 14px;
  height: 14px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.usage-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 16px;
}

.usage-actions__note {
  margin-right: auto;
  font-size: 12px;
  color: var(--muted);
}

.usage-actions__note--ok {
  color: var(--ok-fg);
  font-weight: 500;
}

.billing-detail__bar {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.usage-commit-msg {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
}

.usage-commit-msg--loading {
  color: var(--ink);
  font-weight: 500;
}

.usage-commit-msg--ok {
  color: var(--ok-fg);
  font-weight: 500;
}

.usage-commit-msg--warn {
  color: var(--warn-fg);
}

.usage-muted {
  color: var(--muted);
}

.usage-pricing {
  margin: 4px 0 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-subtle);
}

.usage-pricing__fields {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px;
}

.usage-price {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.usage-price__label {
  font-size: 12px;
  color: var(--muted);
}

.usage-price__group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.usage-price__yen {
  font-size: 14px;
  color: var(--muted);
}

.usage-price__unit {
  font-size: 12px;
  color: var(--muted);
}

.usage-price__input {
  width: 96px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
}

/* Read-only state: render like static text, not an input box. */
.usage-price__input:disabled {
  width: 56px;
  padding: 8px 0;
  border-color: transparent;
  background: transparent;
  color: var(--ink);
  font-weight: 600;
  opacity: 1;
}

.usage-price__edit {
  margin-left: auto;
  padding: 6px 14px;
  font-size: 13px;
}

.usage-pricing__note {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.usage-pricing__note--ok {
  color: var(--ok-fg);
}

.usage-pricing__note--warn {
  color: var(--warn-fg);
}

.btn--primary:disabled {
  background: var(--muted-3);
  border-color: var(--muted-3);
  cursor: default;
}
