/* ============================================================
   Canteen Management System — Design System
   Palette: Indigo (#4f46e5) / Blue (#2563eb) primary,
            Emerald/Teal accent, soft gray surfaces.
   Font: Inter (Google Fonts)
   ============================================================ */

:root {
  --indigo: #4f46e5;
  --indigo-600: #4f46e5;
  --indigo-700: #4338ca;
  --blue: #2563eb;
  --violet: #7c3aed;
  --emerald: #10b981;
  --teal: #14b8a6;
  --amber: #f59e0b;
  --red: #ef4444;

  --bg: #f1f5f9;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;

  --grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  --grad-soft: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);

  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
  --shadow: 0 4px 6px -1px rgba(15, 23, 42, .08), 0 10px 25px -5px rgba(15, 23, 42, .08);
  --shadow-lg: 0 20px 40px -12px rgba(79, 70, 229, .25);
  --ease: cubic-bezier(.4, 0, .2, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

a { color: var(--indigo); text-decoration: none; }
a:hover { color: var(--indigo-700); }

h1, h2, h3, h4 { margin: 0 0 .4em; font-weight: 700; letter-spacing: -.02em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.4rem; }
p { margin: 0 0 1rem; }

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------------- Topbar (public) ---------------- */
.topbar {
  background: var(--grad);
  color: #fff;
  box-shadow: var(--shadow);
}
.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -.02em;
}
.brand:hover { color: #fff; }
.brand .logo {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .18);
  border-radius: 12px;
  font-size: 1.25rem;
  backdrop-filter: blur(6px);
}
.topbar-nav a {
  color: rgba(255, 255, 255, .9);
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 999px;
  transition: background .2s var(--ease);
}
.topbar-nav a:hover { background: rgba(255, 255, 255, .15); color: #fff; }

.main { padding: 36px 0 60px; }

/* ---------------- Cards ---------------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
  padding: 26px;
}
.card + .card { margin-top: 22px; }
.card-title {
  font-size: 1.15rem;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: .95rem;
  font-weight: 600;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .15s var(--ease), box-shadow .2s var(--ease), background .2s var(--ease), opacity .2s;
  text-decoration: none;
  line-height: 1;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 6px 14px -4px rgba(79, 70, 229, .5);
}
.btn-primary:hover { color: #fff; box-shadow: 0 10px 20px -4px rgba(79, 70, 229, .55); }
.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  box-shadow: 0 6px 14px -4px rgba(16, 185, 129, .5);
}
.btn-success:hover { color: #fff; }
.btn-ghost {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}
.btn-ghost:hover { background: #f8fafc; color: var(--ink); }
.btn-sm { padding: 7px 13px; font-size: .82rem; }
.btn-lg { padding: 15px 28px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn-danger { background: linear-gradient(135deg, #ef4444, #dc2626); color: #fff; }
.btn-danger:hover { color: #fff; }

/* ---------------- Forms ---------------- */
.field { margin-bottom: 16px; }
label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}
.input, select.input, input[type="text"], input[type="password"],
input[type="number"], input[type="search"] {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.input:focus, input:focus, select:focus {
  outline: none;
  border-color: var(--indigo);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, .14);
}
.input-xl { font-size: 1.5rem; padding: 18px 18px; text-align: center; letter-spacing: .04em; }
.hint { font-size: .8rem; color: var(--muted); margin-top: 6px; }
.error-text { color: var(--red); font-size: .82rem; margin-top: 6px; font-weight: 600; }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.form-row > .field { flex: 1; min-width: 140px; margin-bottom: 0; }

/* ---------------- Alerts ---------------- */
.alert {
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-bottom: 20px;
  font-weight: 600;
  font-size: .92rem;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
}
.alert-error { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.alert-success { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.alert-warn { background: #fffbeb; color: #b45309; border-color: #fde68a; }

/* ---------------- Badges ---------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  text-transform: capitalize;
  letter-spacing: .01em;
}
.badge-generated { background: #dbeafe; color: #1d4ed8; }
.badge-served    { background: #d1fae5; color: #047857; }
.badge-verified  { background: #ede9fe; color: #6d28d9; }
.badge-active    { background: #d1fae5; color: #047857; }
.badge-inactive  { background: #f1f5f9; color: #64748b; }
.badge-available { background: #d1fae5; color: #047857; }
.badge-hidden    { background: #f1f5f9; color: #64748b; }

/* ---------------- Tables ---------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
}
table.tbl th {
  text-align: left;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  font-weight: 700;
  padding: 12px 14px;
  border-bottom: 2px solid var(--line);
  white-space: nowrap;
}
table.tbl td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.tbl tbody tr { transition: background .15s var(--ease); }
table.tbl tbody tr:hover { background: #f8fafc; }
table.tbl tbody tr:last-child td { border-bottom: none; }
.mono { font-variant-numeric: tabular-nums; font-weight: 700; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}
.empty-state .ico { font-size: 2.5rem; display: block; margin-bottom: 8px; }

/* ============================================================
   HOME / LANDING
   ============================================================ */
.hero {
  background: var(--grad);
  color: #fff;
  text-align: center;
  padding: 80px 20px 120px;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 20%, rgba(255, 255, 255, .15), transparent 40%),
              radial-gradient(circle at 80% 0%, rgba(20, 184, 166, .25), transparent 45%);
  pointer-events: none;
}
.hero h1 { font-size: 3rem; margin-bottom: .3em; position: relative; }
.hero .lead { font-size: 1.2rem; opacity: .92; max-width: 620px; margin: 0 auto; position: relative; }
.hero .eyebrow {
  display: inline-block;
  background: rgba(255, 255, 255, .16);
  padding: 6px 16px;
  border-radius: 999px;
  font-weight: 600;
  font-size: .82rem;
  letter-spacing: .04em;
  margin-bottom: 18px;
  position: relative;
}

.tiles {
  max-width: 980px;
  margin: -70px auto 60px;
  padding: 0 20px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  position: relative;
  z-index: 2;
}
.tile {
  background: #fff;
  border-radius: var(--radius);
  padding: 32px 26px;
  box-shadow: var(--shadow);
  text-align: center;
  color: var(--ink);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
  border: 1px solid var(--line);
  display: block;
}
.tile:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
  color: var(--ink);
}
.tile .tile-ico {
  width: 64px; height: 64px;
  margin: 0 auto 18px;
  display: grid; place-items: center;
  border-radius: 18px;
  font-size: 2rem;
  background: var(--grad-soft);
  color: #fff;
  box-shadow: 0 8px 18px -6px rgba(99, 102, 241, .6);
}
.tile h3 { font-size: 1.3rem; margin-bottom: 6px; }
.tile p { color: var(--muted); font-size: .92rem; margin: 0; }

/* ============================================================
   ADMIN SHELL
   ============================================================ */
.admin-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  padding: 22px 22px 18px;
  border-bottom: 1px solid var(--line);
}
.sidebar-brand .brand-row {
  display: flex; align-items: center; gap: 11px;
  font-weight: 800; font-size: 1.05rem; color: var(--ink);
  letter-spacing: -.02em;
}
.sidebar-brand .logo {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: var(--grad);
  color: #fff;
  border-radius: 11px;
  font-size: 1.2rem;
}
.sidebar-brand small { color: var(--muted); font-size: .72rem; font-weight: 600; letter-spacing: .04em; }
.nav { padding: 16px 12px; flex: 1; overflow-y: auto; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 600;
  font-size: .94rem;
  margin-bottom: 4px;
  transition: background .18s var(--ease), color .18s var(--ease);
}
.nav-link .ico { font-size: 1.15rem; width: 22px; text-align: center; }
.nav-link:hover { background: #f1f5f9; color: var(--ink); }
.nav-link.active {
  background: var(--grad-soft);
  color: #fff;
  box-shadow: 0 6px 14px -6px rgba(99, 102, 241, .7);
}
.nav-link.active:hover { color: #fff; }

.sidebar-foot {
  border-top: 1px solid var(--line);
  padding: 16px;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 12px;
}
.user-chip .avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--grad);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
}
.user-chip .uname { font-weight: 700; font-size: .9rem; line-height: 1.1; }
.user-chip .urole { font-size: .75rem; color: var(--muted); text-transform: capitalize; }

.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.admin-header {
  padding: 24px 32px 0;
}
.admin-header h1 { font-size: 1.6rem; margin: 0; }
.admin-header .sub { color: var(--muted); font-size: .92rem; margin-top: 2px; }
.admin-content { padding: 24px 32px 48px; flex: 1; }

/* mobile admin topbar (shown < 900px) */
.admin-mobilebar { display: none; }

/* ============================================================
   DASHBOARD
   ============================================================ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 20px;
  margin-bottom: 26px;
}
.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.stat .stat-ico {
  width: 46px; height: 46px;
  border-radius: 13px;
  display: grid; place-items: center;
  font-size: 1.4rem;
  margin-bottom: 14px;
}
.stat-ico.i-indigo  { background: #ede9fe; }
.stat-ico.i-emerald { background: #d1fae5; }
.stat-ico.i-violet  { background: #f3e8ff; }
.stat-ico.i-amber   { background: #fef3c7; }
.stat-ico.i-blue    { background: #dbeafe; }
.stat .stat-num { font-size: 2rem; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.stat .stat-label { color: var(--muted); font-size: .85rem; font-weight: 600; margin-top: 6px; }

.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 22px;
}
.chart-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow-sm); }
.chart-card canvas { max-height: 300px; }

/* ============================================================
   KIOSK
   ============================================================ */
.kiosk-wrap { max-width: 720px; margin: 0 auto; }
.greet { margin-bottom: 6px; }
.emp-meta { color: var(--muted); font-weight: 600; margin-bottom: 22px; }
.emp-meta .pill {
  background: #eef2ff; color: var(--indigo-700);
  padding: 3px 12px; border-radius: 999px; font-size: .8rem; margin-right: 6px;
}

.cat-group { margin-bottom: 22px; }
.cat-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 1.05rem; font-weight: 700; margin-bottom: 12px;
  padding-bottom: 8px; border-bottom: 2px solid var(--line);
}
.cat-head .cat-emoji { font-size: 1.2rem; }
.item-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color .18s var(--ease), background .18s var(--ease);
  min-height: 56px;
}
.item-row:hover { border-color: var(--indigo); background: #fafaff; }
.item-row input[type="checkbox"] {
  width: 22px; height: 22px;
  accent-color: var(--indigo);
  cursor: pointer;
  flex-shrink: 0;
}
.item-row .item-name { font-weight: 600; flex: 1; }
.item-row .item-price { font-weight: 700; color: var(--emerald); font-variant-numeric: tabular-nums; }

/* ----- Ticket ----- */
.ticket {
  max-width: 420px;
  margin: 0 auto;
  background: #fff;
  border-radius: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid var(--line);
}
.ticket-top {
  background: var(--grad);
  color: #fff;
  text-align: center;
  padding: 26px 20px 22px;
}
.ticket-top .label { font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; opacity: .85; }
.ticket-top .token-no { font-size: 2.6rem; font-weight: 800; letter-spacing: .02em; margin-top: 4px; }
.ticket-perf {
  height: 22px;
  background: var(--bg);
  position: relative;
}
.ticket-perf::before, .ticket-perf::after {
  content: ""; position: absolute; top: -11px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--bg);
}
.ticket-perf::before { left: -11px; }
.ticket-perf::after { right: -11px; }
.ticket-body { padding: 24px; }
.meta-table { width: 100%; border-collapse: collapse; }
.meta-table td { padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: .92rem; }
.meta-table td:first-child { color: var(--muted); font-weight: 600; }
.meta-table td:last-child { text-align: right; font-weight: 600; }
.meta-table tr:last-child td { border-bottom: none; }
.meta-table .total td { font-size: 1.15rem; font-weight: 800; color: var(--emerald); padding-top: 14px; }
.qr-box { display: grid; place-items: center; padding: 22px 0 6px; }
.qr-box #qrcode { padding: 12px; background: #fff; border-radius: 12px; box-shadow: var(--shadow-sm); }
.ticket-actions { display: flex; gap: 12px; padding: 0 24px 24px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  .chart-grid { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: 1fr; margin-top: -40px; }
  .hero h1 { font-size: 2.2rem; }

  .admin-shell { flex-direction: column; }
  .sidebar { display: none; }
  .admin-mobilebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--grad);
    color: #fff;
    padding: 14px 18px;
  }
  .admin-mobilebar .brand-row { display: flex; align-items: center; gap: 9px; color: #fff; font-weight: 700; }
  .admin-mobilebar .m-nav { display: flex; gap: 4px; flex-wrap: wrap; }
  .admin-mobilebar .m-nav a { color: #fff; padding: 6px 10px; border-radius: 8px; font-size: .8rem; background: rgba(255,255,255,.14); }
  .admin-header, .admin-content { padding-left: 18px; padding-right: 18px; }
}

/* ============================================================
   PRINT (ticket)
   ============================================================ */
@media print {
  .topbar, .ticket-actions, .no-print { display: none !important; }
  body { background: #fff; }
  .main { padding: 0; }
  .ticket { box-shadow: none; border: 1px solid #000; margin: 0; max-width: 100%; }
}

/* Counter token input with fixed TKN prefix */
.token-input { display: flex; align-items: stretch; max-width: 320px; }
.token-input .token-prefix {
    display: flex; align-items: center; padding: 0 14px;
    background: #ede9fe; color: #5b21b6; font-weight: 800;
    font-size: 1.25rem; letter-spacing: 1px;
    border: 2px solid #ddd6fe; border-right: none;
    border-radius: 12px 0 0 12px;
}
.token-input .input-xl {
    border-radius: 0 12px 12px 0; margin: 0; flex: 1;
    font-size: 1.5rem; letter-spacing: 2px; font-weight: 700;
}

.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
