/* =========================================================
   Restaurant System - Shared Styles (HTML + CSS only)
   Theme: professional blue / dark blue / bright blue + status colours
   ========================================================= */

:root {
  /* brand blues */
  --accent: #1d4ed8;          /* main: professional blue */
  --accent-dark: #1e3a8a;     /* hover / pressed */
  --secondary: #3b82f6;       /* secondary: bright blue */
  --accent-soft: #eff6ff;
  --accent-line: #bfdbfe;

  /* dark blue (sidebar, featured surfaces) */
  --ink: #0f2557;
  --ink-2: #183577;
  --ink-3: #284a8f;

  /* status */
  --success: #16a34a;
  --success-soft: #dcfce7;
  --warning: #ea580c;
  --warning-soft: #ffedd5;
  --danger: #dc2626;
  --danger-soft: #fee2e2;

  /* neutrals */
  --heading: #111827;
  --text: #1f2937;            /* dark charcoal */
  --muted: #64748b;
  --border: #e5e7eb;
  --bg: #f5f7fa;              /* very light gray */
  --surface: #ffffff;         /* cards */
  --hover: #f3f4f6;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 16px rgba(15, 23, 42, .05);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, .25);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;

  --sidebar-w: 248px;
  --topbar-h: 64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
img, svg { display: block; }
h1, h2, h3, h4 { color: var(--heading); line-height: 1.25; }

.icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }

.muted { color: var(--muted); }
.text-right { text-align: right; }
.text-accent { color: var(--accent); }
.fw-600 { font-weight: 600; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* =========================================================
   Buttons
   ========================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.btn-block { width: 100%; }
.btn-lg { padding: 12px 18px; font-size: 15px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: var(--ink-3); }
.btn-outline { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-outline:hover { border-color: var(--accent-line); color: var(--accent); }
.btn-soft { background: var(--accent-soft); color: var(--accent); }
.btn-soft:hover { background: var(--accent-line); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--ink); background: var(--hover); }

.icon-btn {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.icon-btn .icon { width: 16px; height: 16px; }
.icon-btn.danger:hover { color: var(--danger); border-color: #fecaca; background: var(--danger-soft); }

.btn-group { display: flex; flex-wrap: wrap; gap: 10px; }
.actions { display: flex; gap: 6px; }

/* =========================================================
   Forms
   ========================================================= */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea.form-control { height: auto; padding: 10px 12px; resize: vertical; }
.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-control::placeholder { color: #94a3b8; }
select.form-control {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2378716c' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}
.form-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

.input-icon { position: relative; }
.input-icon > .icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
}
.input-icon .form-control { padding-left: 38px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 16px;
}
.form-grid .span-2 { grid-column: 1 / -1; }

/* checkbox / switch */
.check {
  appearance: none;
  width: 18px;
  height: 18px;
  border: 1.5px solid #cbd5e1;
  border-radius: 5px;
  background: var(--surface) center / 12px no-repeat;
  cursor: pointer;
  vertical-align: middle;
  transition: background-color .15s, border-color .15s;
}
.check:checked {
  background-color: var(--accent);
  border-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5L20 7'/%3E%3C/svg%3E");
}
.switch {
  appearance: none;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: #cbd5e1;
  position: relative;
  cursor: pointer;
  transition: background .2s;
  vertical-align: middle;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
  transition: transform .2s;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(16px); }

/* =========================================================
   App layout (sidebar + topbar + content)
   ========================================================= */
.nav-toggle { display: none; }

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--ink);
  color: #cbd5e1;
  padding: 18px 14px;
  overflow-y: auto;
  z-index: 40;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 22px;
  color: #fff;
}
.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
}
.brand-mark .icon { width: 20px; height: 20px; }
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: .2px; }
.brand-name small { display: block; font-size: 11px; font-weight: 500; color: #94a3b8; letter-spacing: .4px; }

.nav-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #64748b;
  padding: 0 10px;
  margin: 8px 0 6px;
}
.nav { display: flex; flex-direction: column; gap: 2px; list-style: none; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  color: #cbd5e1;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--ink-2); color: #fff; }
.nav-link.active { background: var(--accent); color: #fff; }
.nav-link .icon { width: 18px; height: 18px; }

.sidebar-bottom {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--ink-3);
}
.sidebar-bottom .nav-title { margin-top: 0; }
.nav-link.logout { color: #94a3b8; margin-top: 6px; }

.nav-close { display: none; }
.nav-overlay { display: none; }

/* ---- Main ---- */
.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 28px;
  background: rgba(245, 247, 250, .9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.menu-btn { display: none; }
.topbar .search { flex: 1; max-width: 380px; }
.topbar .search .form-control { height: 40px; background: var(--surface); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
}
.avatar.soft { background: var(--accent-soft); color: var(--accent); }
.user-chip .name { font-weight: 600; font-size: 13px; line-height: 1.2; }
.user-chip .role { font-size: 11px; color: var(--muted); }

.content { padding: 28px; flex: 1; }

/* ---- Page header ---- */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
}
.page-head h1 { font-size: 24px; font-weight: 700; }
.page-head p { color: var(--muted); margin-top: 2px; }
.breadcrumb { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.breadcrumb a:hover { color: var(--accent); }

/* =========================================================
   Cards, stats, grids
   ========================================================= */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}
.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 15px; font-weight: 700; }
.card-head .link { font-size: 13px; font-weight: 600; color: var(--accent); }
.card-head .link:hover { text-decoration: underline; }
.card-body { padding: 20px; }
.card-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}

.grid { display: grid; gap: 20px; }
.grid-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid-1-1 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-1-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.mb-20 { margin-bottom: 20px; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}
.stat {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px;
}
.stat .label { color: var(--muted); font-size: 13px; font-weight: 500; }
.stat .value { font-size: 26px; font-weight: 700; color: var(--ink); margin-top: 6px; letter-spacing: -.3px; }
.stat .trend { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stat .trend b { color: var(--accent); font-weight: 600; }
.stat-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
}
.stat-icon .icon { width: 22px; height: 22px; }
.stat.featured { background: var(--ink); border-color: var(--ink); }
.stat.featured .label, .stat.featured .trend { color: #94a3b8; }
.stat.featured .value { color: #fff; }
.stat.featured .stat-icon { background: var(--accent); color: #fff; }
.stat.featured .trend b { color: #93c5fd; }

/* =========================================================
   Tables
   ========================================================= */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; min-width: 560px; }
.table th, .table td {
  padding: 13px 20px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.table th {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  background: #f9fafb;
}
.table tbody tr:hover { background: #f8fafc; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; }
.table .cell-user { display: flex; align-items: center; gap: 10px; }
.table .cell-user .sub { font-size: 12px; color: var(--muted); }

.table tfoot th {
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 13px;
  text-transform: none;
  letter-spacing: 0;
  border-bottom: 0;
}

/* report filter row */
.report-filter {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 260px)) auto;
  justify-content: start;
  gap: 14px;
  align-items: end;
}
.report-filter .form-group { margin: 0; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.neutral { background: var(--hover); color: var(--muted); }
.badge.dark { background: var(--ink); color: #fff; }
.badge.plain::before { display: none; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.toolbar .search { flex: 1; min-width: 200px; max-width: 360px; }
.toolbar select.form-control { width: auto; min-width: 140px; }
.toolbar .count { margin-left: auto; color: var(--muted); font-size: 13px; }

.pagination { display: flex; gap: 6px; }
.pagination button {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.pagination button:hover { border-color: var(--accent-line); color: var(--accent); }
.pagination button.active { background: var(--ink); border-color: var(--ink); color: #fff; }

/* =========================================================
   Lists (top selling, etc.)
   ========================================================= */
.rank-list { list-style: none; }
.rank-list li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 12px;
  padding: 11px 20px;
}
.rank-list li + li { border-top: 1px dashed var(--border); }
.rank-no {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--hover);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.rank-list li:first-child .rank-no { background: var(--accent); color: #fff; }
.rank-list .name { font-weight: 600; }
.rank-list .qty { font-weight: 700; color: var(--ink); }
.rank-list .qty small { font-weight: 500; color: var(--muted); }
.progress {
  grid-column: 2 / -1;
  height: 6px;
  border-radius: 999px;
  background: var(--hover);
  overflow: hidden;
}
.progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--secondary)); }

.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.quick {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius);
  background: var(--surface);
  font-weight: 600;
  transition: border-color .15s, background .15s;
}
.quick:hover { border-color: var(--accent); background: var(--accent-soft); }
.quick .stat-icon { width: 36px; height: 36px; border-radius: 9px; }
.quick .stat-icon .icon { width: 18px; height: 18px; }

/* =========================================================
   Bar chart (pure CSS)
   ========================================================= */
.chart {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 10px;
  height: 260px;
}
.chart-y {
  position: relative;
  font-size: 11px;
  color: var(--muted);
}
.chart-y span {
  position: absolute;
  right: 0;
  transform: translateY(50%);
  line-height: 1;
}
.chart-y span:nth-child(1) { bottom: 24px; }
.chart-y span:nth-child(2) { bottom: calc(24px + (100% - 24px) * .25); }
.chart-y span:nth-child(3) { bottom: calc(24px + (100% - 24px) * .5); }
.chart-y span:nth-child(4) { bottom: calc(24px + (100% - 24px) * .75); }
.chart-y span:nth-child(5) { bottom: 100%; transform: translateY(50%); }
.chart-plot {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  gap: 8px;
  padding-bottom: 24px;
  background-image: linear-gradient(to top, var(--border) 1px, transparent 1px);
  background-size: 100% calc((100% - 24px) / 4);
  background-position: 0 calc(100% - 24px);
  background-repeat: repeat-y;
  border-bottom: 1px solid var(--border);
  box-shadow: inset 0 1px 0 var(--border);
}
.bar {
  position: relative;
  flex: 1;
  max-width: 44px;
  height: var(--h);
  border-radius: 6px 6px 2px 2px;
  background: #bfdbfe;
  transition: background .15s;
}
.bar:hover { background: var(--secondary); }
.bar.peak { background: var(--accent); }
.bar::after {
  content: attr(data-day);
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--muted);
}
.bar::before {
  content: attr(data-value);
  position: absolute;
  top: -26px;
  left: 50%;
  transform: translateX(-50%);
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--ink);
  color: #fff;
  font-size: 11px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .15s;
}
.bar:hover::before, .bar.peak::before { opacity: 1; }

/* =========================================================
   Tabs (pure CSS radio tabs)
   ========================================================= */
.tab-input { display: none; }
.tab-list {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 20px;
  border-radius: var(--radius);
  background: #e9edf3;
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
}
.tab-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.tab-list label:hover { color: var(--ink); }
.tab-list .count-pill {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  background: #dbe2ea;
  color: var(--muted);
}
.tab-panel { display: none; }

#tab-users:checked ~ .tab-list label[for="tab-users"],
#tab-roles:checked ~ .tab-list label[for="tab-roles"],
#tab-perms:checked ~ .tab-list label[for="tab-perms"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}
#tab-users:checked ~ .tab-list label[for="tab-users"] .count-pill,
#tab-roles:checked ~ .tab-list label[for="tab-roles"] .count-pill,
#tab-perms:checked ~ .tab-list label[for="tab-perms"] .count-pill {
  background: var(--accent);
  color: #fff;
}
#tab-users:checked ~ .panel-users,
#tab-roles:checked ~ .panel-roles,
#tab-perms:checked ~ .panel-perms { display: block; }

/* =========================================================
   Modal (pure CSS using :target)
   ========================================================= */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal:target { display: flex; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .55);
}
.modal-box {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  animation: pop .18s ease-out;
}
.modal-box.sm { max-width: 400px; }
@keyframes pop { from { transform: translateY(10px); opacity: 0; } }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 22px; }
.modal-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  background: #f9fafb;
  border-radius: 0 0 14px 14px;
}
.confirm { text-align: center; padding: 30px 26px 10px; }
.confirm .stat-icon { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 50%; }
.stat-icon.success { background: var(--success-soft); color: var(--success); }
.stat-icon.warning { background: var(--warning-soft); color: var(--warning); }
.stat-icon.danger { background: var(--danger-soft); color: var(--danger); }
.confirm h3 { font-size: 18px; margin-bottom: 6px; }
.confirm p { color: var(--muted); }

/* =========================================================
   Billing
   ========================================================= */
.add-item {
  display: grid;
  grid-template-columns: minmax(0, 2fr) 100px auto;
  gap: 10px;
  align-items: end;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: #f9fafb;
}
.add-item .form-group { margin: 0; }
.qty-ctrl {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.qty-ctrl button {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.qty-ctrl button:hover { background: var(--accent-soft); color: var(--accent); }
.qty-ctrl span { min-width: 30px; text-align: center; font-weight: 600; }

.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  color: var(--muted);
}
.summary-row b { color: var(--ink); font-weight: 600; }
.summary-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 8px;
  padding-top: 14px;
  border-top: 1px dashed #cbd5e1;
}
.summary-total span { font-weight: 600; }
.summary-total strong { font-size: 28px; color: var(--accent); letter-spacing: -.5px; }

.pay-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pay-modes input { display: none; }
.pay-modes label {
  padding: 10px 6px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.pay-modes input:checked + label { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

.customer-pick {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
}
.customer-pick .meta { font-size: 12px; color: var(--muted); }

/* receipt */
.receipt {
  font-family: "Consolas", "Courier New", monospace;
  font-size: 13px;
  max-width: 320px;
  margin: 0 auto;
  padding: 20px;
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius-sm);
  background: #ffffff;
}
.receipt .center { text-align: center; }
.receipt h4 { font-family: var(--font); font-size: 16px; }
.receipt hr { border: 0; border-top: 1px dashed #94a3b8; margin: 10px 0; }
.receipt .line { display: flex; justify-content: space-between; gap: 10px; }
.receipt .line.total { font-weight: 700; font-size: 15px; }

/* =========================================================
   Settings / printer
   ========================================================= */
.status {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  margin-bottom: 18px;
}
.status .stat-icon { background: var(--accent); color: #fff; }
.status small { display: block; color: #94a3b8; font-size: 12px; }
.status .dot {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #4ade80;
}
.status .dot::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 4px rgba(74, 222, 128, .2);
}

.device-list { list-style: none; }
.device-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
}
.device-list li + li { border-top: 1px solid var(--border); }
.device-list .info { flex: 1; min-width: 0; }
.device-list .info b { display: block; }
.device-list .info span { font-size: 12px; color: var(--muted); }

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
}
.setting-row + .setting-row { border-top: 1px solid var(--border); }
.setting-row b { display: block; font-weight: 600; }
.setting-row span { font-size: 12px; color: var(--muted); }

/* =========================================================
   Users / Roles / Permissions
   ========================================================= */
.role-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.role-card { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.role-card .top { display: flex; align-items: center; justify-content: space-between; }
.role-card h4 { font-size: 16px; }
.role-card p { color: var(--muted); font-size: 13px; flex: 1; }
.role-card .meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.avatars { display: flex; }
.avatars .avatar { width: 28px; height: 28px; font-size: 11px; border: 2px solid var(--surface); margin-left: -8px; }
.avatars .avatar:first-child { margin-left: 0; }
.role-card.add {
  align-items: center;
  justify-content: center;
  text-align: center;
  border-style: dashed;
  box-shadow: none;
  min-height: 190px;
  color: var(--muted);
  font-weight: 600;
}
.role-card.add:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.perm-table td:not(:first-child), .perm-table th:not(:first-child) { text-align: center; }
.perm-table .module { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.perm-table .module .stat-icon { width: 30px; height: 30px; border-radius: 8px; }
.perm-table .module .stat-icon .icon { width: 16px; height: 16px; }
.perm-table td.na { color: #cbd5e1; }

/* =========================================================
   Auth pages (Login / Select View)
   ========================================================= */
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  background: var(--surface);
}
.auth-side {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px;
  background: var(--ink);
  color: #cbd5e1;
  overflow: hidden;
}
.auth-side::before,
.auth-side::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .07);
}
.auth-side::before { width: 520px; height: 520px; right: -200px; bottom: -200px; }
.auth-side::after { width: 340px; height: 340px; right: -110px; bottom: -110px; border-color: rgba(59, 130, 246, .5); }
.auth-side .brand { padding: 0; position: relative; }
.auth-side .brand-mark { width: 44px; height: 44px; }
.auth-side .brand-name { font-size: 18px; }
.auth-copy { position: relative; max-width: 440px; }
.auth-copy h2 { color: #fff; font-size: 38px; font-weight: 700; letter-spacing: -.6px; }
.auth-copy h2 em { font-style: normal; color: #60a5fa; }
.auth-copy p { margin-top: 14px; font-size: 15px; color: #94a3b8; }
.auth-points { position: relative; list-style: none; display: flex; flex-wrap: wrap; gap: 10px; }
.auth-points li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--ink-3);
  border-radius: 999px;
  font-size: 13px;
}
.auth-points .icon { width: 15px; height: 15px; color: #60a5fa; }

.auth-main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
}
.auth-form { width: 100%; max-width: 380px; }
.auth-form .mobile-brand { display: none; }
.auth-form h1 { font-size: 28px; font-weight: 700; letter-spacing: -.4px; }
.auth-form .lead { color: var(--muted); margin: 6px 0 28px; }
.auth-form .form-control { height: 46px; }
.auth-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: -2px 0 22px;
  font-size: 13px;
}
.auth-row label { display: flex; align-items: center; gap: 8px; color: var(--muted); cursor: pointer; }
.auth-row a { color: var(--accent); font-weight: 600; }
.auth-row a:hover { text-decoration: underline; }
.auth-note { margin-top: 28px; text-align: center; font-size: 12px; color: var(--muted); }

/* select view */
.view-options { display: grid; gap: 14px; }
.view-option {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color .15s, background .15s;
}
.view-option:hover { border-color: var(--accent); background: var(--accent-soft); }
.view-option .stat-icon { width: 52px; height: 52px; }
.view-option .stat-icon .icon { width: 26px; height: 26px; }
.view-option b { display: block; font-size: 16px; color: var(--ink); }
.view-option span { font-size: 13px; color: var(--muted); }
.view-option .go { margin-left: auto; color: var(--muted); }
.view-option:hover .go { color: var(--accent); }
.welcome-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin-bottom: 26px;
  border-radius: var(--radius);
  background: var(--hover);
}
.welcome-chip .avatar { width: 40px; height: 40px; }
.welcome-chip b { display: block; }
.welcome-chip span { font-size: 12px; color: var(--muted); }
.back-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 22px;
  font-size: 13px;
  color: var(--muted);
}
.back-link:hover { color: var(--accent); }

/* =========================================================
   Responsive
   ========================================================= */

/* Large laptops */
@media (max-width: 1280px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Tablets & small laptops: off-canvas sidebar */
@media (max-width: 1024px) {
  .app { grid-template-columns: minmax(0, 1fr); }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 270px;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: var(--shadow-lg);
  }
  .nav-toggle:checked ~ .app .sidebar { transform: translateX(0); }

  .nav-overlay {
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(15, 23, 42, .5);
    cursor: pointer;
  }
  .nav-toggle:checked ~ .app .nav-overlay { display: block; }

  .nav-close {
    display: grid;
    margin-left: auto;
    background: transparent;
    border-color: var(--ink-3);
    color: #94a3b8;
  }
  .menu-btn { display: inline-grid; }

  .grid-2-1, .grid-1-2, .grid-1-1 { grid-template-columns: minmax(0, 1fr); }
  .report-filter { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-filter .btn { grid-column: 1 / -1; }
  .quick-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-side { display: none; }
  .auth-form .mobile-brand { display: flex; padding: 0 0 28px; color: var(--ink); }
  .auth-form .mobile-brand .brand-name small { color: var(--muted); }
}

/* Phones & portrait tablets: tables become stacked cards */
@media (max-width: 820px) {
  .table-wrap { overflow: visible; }
  .table, .table tbody, .table tfoot, .table tr { display: block; min-width: 0; width: 100%; }
  .table thead { display: none; }
  .table tr { padding: 10px 16px; border-bottom: 1px solid var(--border); }
  .table tbody tr:last-child { border-bottom: 0; }
  .table tfoot tr { background: var(--accent-soft); border-top: 1px solid var(--accent-line); }
  .table td, .table tfoot th {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border: 0;
    white-space: normal;
    text-align: right;
    background: none;
  }
  .table td::before, .table tfoot th::before {
    content: attr(data-label);
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .4px;
    text-align: left;
  }
  .table td[data-label=""]::before { display: none; }
  .table td[data-label=""] { justify-content: flex-end; }
  /* first cell = card title */
  .table td:first-child { justify-content: flex-start; font-size: 15px; padding-bottom: 8px; text-align: left; }
  .table td:first-child::before, .table tfoot th:first-child::before { display: none; }
  .table tfoot th:first-child { font-size: 15px; }
  .perm-table td:not(:first-child) { text-align: right; }
}

/* Portrait tablets: two fields per row inside each card */
@media (min-width: 641px) and (max-width: 820px) {
  .table tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 40px; padding: 12px 20px; }
  .table td:first-child, .table tfoot th:first-child { grid-column: 1 / -1; }
}

/* Bill items: compact two-line rows instead of tall cards */
@media (max-width: 820px) {
  .table.bill-items tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas: "food food del" "price qty total";
    align-items: center;
    column-gap: 14px;
    row-gap: 2px;
    padding: 10px 16px;
  }
  .table.bill-items td { padding: 0; }
  .table.bill-items td::before { display: none; }
  .table.bill-items td[data-label="Food"] { grid-area: food; padding: 0; }
  .table.bill-items td[data-label="Price"] { grid-area: price; justify-content: flex-start; color: var(--muted); }
  .table.bill-items td[data-label="Price"]::after { content: "\00a0 each"; font-size: 12px; }
  .table.bill-items td[data-label="Qty"] { grid-area: qty; }
  .table.bill-items td[data-label="Total"] { grid-area: total; min-width: 64px; }
  .table.bill-items td[data-label=""] { grid-area: del; }
}

/* Phones */
@media (max-width: 640px) {
  .topbar { padding: 0 16px; gap: 10px; }
  .topbar .search { display: none; }
  .user-chip { padding: 3px; }
  .user-chip .meta { display: none; }

  .content { padding: 20px 16px; }
  .page-head h1 { font-size: 21px; }
  .page-head .btn-group, .page-head > .btn { width: 100%; }
  .page-head .btn-group .btn { flex: 1; }
  .page-head > .btn { width: 100%; }

  .stats { gap: 12px; }
  .stat { padding: 14px; flex-direction: column-reverse; }
  .stat .value { font-size: 21px; }
  .stat-icon { width: 38px; height: 38px; }

  .grid { gap: 16px; }
  .quick-actions { gap: 10px; }
  .quick { padding: 12px; font-size: 13px; }

  .card-head, .card-body, .toolbar { padding-left: 16px; padding-right: 16px; }
  .toolbar .search { max-width: none; min-width: 100%; }
  .toolbar select.form-control { flex: 1; }
  .toolbar .count { margin-left: 0; width: 100%; }

  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .report-filter { grid-template-columns: minmax(0, 1fr); }
  .add-item { grid-template-columns: minmax(0, 1fr) 80px; padding: 14px 16px; }
  .add-item .btn { grid-column: 1 / -1; }

  .chart { height: 220px; grid-template-columns: 32px minmax(0, 1fr); }
  .bar { max-width: 28px; }

  .modal { padding: 0; align-items: flex-end; }
  .modal-box { max-height: 92vh; border-radius: 16px 16px 0 0; }
  .modal-foot { border-radius: 0; }
  .modal-foot .btn { flex: 1; }

  .tab-list { width: 100%; }
  .tab-list label { flex: 1; justify-content: center; padding: 8px 10px; }

  .status { flex-wrap: wrap; }
  .card-foot { justify-content: center; }
}

/* Very small phones */
@media (max-width: 380px) {
  .stats { grid-template-columns: minmax(0, 1fr); }
  .quick-actions { grid-template-columns: minmax(0, 1fr); }
}

/* Print: only the content / receipt */
@media print {
  .sidebar, .topbar, .page-head .btn-group, .no-print { display: none !important; }
  .app { display: block; }
  .content { padding: 0; }
  .card { box-shadow: none; }
}

/* =========================================================
   Script-driven UI: toasts, errors, empty states, printing
   ========================================================= */
[hidden] { display: none !important; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }
.check:disabled, .switch:disabled { opacity: .45; cursor: not-allowed; }

.form-control.is-invalid { border-color: var(--danger); }
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px var(--danger-soft); }
.form-error { margin-top: 5px; font-size: 12px; font-weight: 500; color: var(--danger); }

.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
}
.alert.danger { background: var(--danger-soft); color: var(--danger); }
.alert.info { background: var(--accent-soft); color: var(--accent-dark); }
.alert .icon { width: 16px; height: 16px; }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 36px 16px;
  color: var(--muted);
  text-align: center;
}
.empty .icon { width: 28px; height: 28px; color: #cbd5e1; }
.table .empty-row td { white-space: normal; }
.table .empty-row:hover { background: none; }

.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: calc(100vw - 40px);
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  max-width: 380px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: #fff;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in .2s ease-out;
  transition: opacity .3s, transform .3s;
}
.toast .icon { width: 18px; height: 18px; flex-shrink: 0; }
.toast.success .icon { color: #4ade80; }
.toast.error .icon { color: #f87171; }
.toast.info .icon { color: #93c5fd; }
.toast.hide { opacity: 0; transform: translateY(8px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.demo-hint {
  margin-top: 18px;
  padding: 10px 12px;
  border: 1px dashed var(--accent-line);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  font-size: 12px;
  color: var(--accent-dark);
  text-align: center;
}

.pass-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  border-radius: 6px;
}
.pass-toggle:hover { color: var(--accent); }

#print-area { display: none; }
@media print {
  body.printing > *:not(#print-area) { display: none !important; }
  body.printing #print-area { display: block !important; }
  body.printing .receipt { border: 0; max-width: 58mm; padding: 0; margin: 0; font-size: 11px; }
}

@media (max-width: 640px) {
  .toasts { left: 16px; right: 16px; bottom: 16px; max-width: none; }
  .toast { min-width: 0; max-width: none; }
}

.view-option.is-disabled { cursor: default; opacity: .6; }
.view-option.is-disabled:hover { border-color: var(--border); background: none; }
button.role-card.add { font: inherit; cursor: pointer; width: 100%; }
@media print { .toasts { display: none !important; } }

/* sortable table headings */
.th-sort {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  cursor: pointer;
}
.th-sort:hover, th.sorted .th-sort { color: var(--accent); }
.th-sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.sort-ic {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
}
.sort-ic::before, .sort-ic::after {
  content: "";
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  opacity: .35;
}
.sort-ic::before { border-bottom: 4px solid currentColor; }
.sort-ic::after { border-top: 4px solid currentColor; }
th[aria-sort="ascending"] .sort-ic::before, th[aria-sort="descending"] .sort-ic::after { opacity: 1; }
th[aria-sort="ascending"] .sort-ic::after, th[aria-sort="descending"] .sort-ic::before { opacity: .15; }
.table th.num .th-sort { flex-direction: row-reverse; }

/* small search box inside a card header */
.card-head .search-sm { width: 220px; max-width: 100%; }
.card-head .search-sm .form-control { height: 36px; }
@media (max-width: 640px) { .card-head .search-sm { width: 100%; } }

/* sort control shown above stacked (card) tables on small screens */
.mobile-sort { display: none; }
@media (max-width: 820px) {
  .mobile-sort { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
  .mobile-sort .form-label { margin: 0; white-space: nowrap; }
  .mobile-sort select { height: 38px; }
}

/* numbered steps (Settings > How to pair) */
.steps { margin: 0; padding-left: 20px; display: grid; gap: 8px; color: var(--text); }
.steps li::marker { color: var(--accent); font-weight: 700; }
.status .dot.off { color: #94a3b8; }
.status .dot.off::before { background: #94a3b8; box-shadow: none; }
