:root {
  --bg: #0b0d0c;
  --bg-2: #101312;
  --surface: #151917;
  --surface-2: #1b201e;
  --border: #262d2a;
  --text: #eef2ef;
  --muted: #8d9a93;
  --gold: #d4a63a;
  --gold-2: #f0cf7a;
  --free: #1fa971;
  --busy: #e0524d;
  --paused: #e5a42f;
  --maint: #78818a;
  --felt: #0f6b45;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --serif: Georgia, 'Times New Roman', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 80% -10%, #14211b 0%, transparent 60%), var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--sans);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
/* iOS Safari zooms the page on focus when a field's font is under 16px */
@media (pointer: coarse) {
  input, select, textarea { font-size: 16px; }
}
h1, h2, h3 { margin: 0; line-height: 1.2; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(11, 13, 12, .85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-in {
  max-width: 1280px; margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; gap: 24px;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.brand img { width: 42px; height: 42px; display: block; filter: drop-shadow(0 2px 6px rgba(212, 166, 58, .35)); }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-name { font: 700 24px/1 var(--serif); letter-spacing: .5px; }
.brand-name b { color: var(--gold); font-weight: 700; }
.brand-sub { font-size: 10.5px; letter-spacing: 1.6px; text-transform: uppercase; color: var(--muted); margin-top: 5px; }

.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  padding: 8px 14px; border-radius: 10px; color: var(--muted); text-decoration: none;
  font-weight: 600; white-space: nowrap; transition: .15s;
}
.nav a:hover { color: var(--text); background: var(--surface); }
.nav a.active { color: #15110a; background: linear-gradient(135deg, var(--gold-2), var(--gold)); }

.langs { display: flex; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.langs button {
  border: 0; background: none; padding: 5px 10px; border-radius: 7px; cursor: pointer;
  font-weight: 700; font-size: 12.5px; color: var(--muted); letter-spacing: .5px;
}
.langs button.active { background: var(--surface-2); color: var(--gold-2); box-shadow: inset 0 0 0 1px var(--border); }

/* ---------- Layout ---------- */
main { max-width: 1280px; margin: 0 auto; padding: 24px 20px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font: 700 26px/1.2 var(--serif); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  padding: 9px 16px; border-radius: 10px; font-weight: 650; cursor: pointer; transition: .15s;
  white-space: nowrap;
}
.btn:hover { border-color: #3a4540; background: #212724; }
.btn:focus-visible, .nav a:focus-visible, .langs button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--gold); outline-offset: 2px;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, var(--gold-2), var(--gold)); color: #15110a; border-color: transparent; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.success { background: var(--free); border-color: transparent; color: #04170f; }
.btn.success:hover { filter: brightness(1.08); }
.btn.danger { background: var(--busy); border-color: transparent; color: #fff; }
.btn.danger:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.warn { background: var(--paused); border-color: transparent; color: #1c1303; }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn svg { width: 16px; height: 16px; }

/* ---------- Stat tiles ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.stat {
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px;
}
.stat .label { color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .8px; font-weight: 600; }
.stat .value { font: 700 26px/1.2 var(--serif); margin-top: 6px; }
.stat .value small { font: 600 13px var(--sans); color: var(--muted); margin-left: 4px; }
.stat.free .value { color: var(--free); }
.stat.busy .value { color: var(--busy); }
.stat.gold .value { color: var(--gold-2); }

/* ---------- Room filter ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  padding: 7px 14px; border-radius: 999px; cursor: pointer; font-weight: 600; transition: .15s;
}
.chip:hover { color: var(--text); }
.chip.active { color: #15110a; background: var(--gold); border-color: var(--gold); }
.chip .n { opacity: .65; margin-left: 6px; font-weight: 500; }

.room-title { display: flex; align-items: baseline; gap: 10px; margin: 26px 0 12px; }
.room-title h2 { font: 700 19px var(--serif); }
.room-title:first-of-type { margin-top: 0; }

/* ---------- Table cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(290px, 100%), 1fr)); gap: 16px; }
.grid > *, .stats > * { min-width: 0; }

.tcard {
  --c: var(--free);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; position: relative;
  transition: border-color .2s, transform .2s;
}
.tcard:hover { transform: translateY(-2px); border-color: #34403a; }
.tcard.st-busy { --c: var(--busy); border-color: color-mix(in srgb, var(--busy) 45%, var(--border)); }
.tcard.st-paused { --c: var(--paused); border-color: color-mix(in srgb, var(--paused) 45%, var(--border)); }
.tcard.st-maint { --c: var(--maint); }
.tcard::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--c); }

.felt-wrap { padding: 18px 18px 6px; }
.felt-wrap svg { width: 100%; height: auto; display: block; filter: drop-shadow(0 8px 14px rgba(0, 0, 0, .45)); }
.felt-wrap .rail { fill: #3a2414; stroke: #5b3a20; stroke-width: 1.5; }
.felt-wrap .felt { fill: var(--c); transition: fill .3s; }
.tcard.st-free .felt { fill: var(--felt); }
.tcard.st-busy .felt { fill: #8a2a28; }
.tcard.st-paused .felt { fill: #8c6212; }
.tcard.st-maint .felt { fill: #4b535a; }
.felt-wrap .pocket { fill: #050505; }
.felt-wrap .cushion { fill: none; stroke: rgba(0, 0, 0, .28); stroke-width: 2; }
.tcard.st-maint .balls { opacity: .25; }
.tcard.st-free .balls { opacity: .95; }

.tbody { padding: 8px 18px 18px; display: flex; flex-direction: column; gap: 12px; flex: 1; }
.thead { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.tname { font: 700 18px var(--serif); }
.tmeta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700;
  padding: 4px 10px; border-radius: 999px; color: var(--c);
  background: color-mix(in srgb, var(--c) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 35%, transparent); white-space: nowrap;
}
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.st-busy .badge::before { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .st-busy .badge::before { animation: none; } .tcard, .btn { transition: none; } }

.live { display: grid; grid-template-columns: auto 1fr; column-gap: 18px; gap: 10px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.live .k { font-size: 11px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); }
.live .v { font: 700 20px/1.25 var(--serif); }
.live .v.cost { color: var(--gold-2); font-size: 18px; white-space: nowrap; }
.live .sub { grid-column: 1 / -1; font-size: 12.5px; color: var(--muted); }
.idle { color: var(--muted); font-size: 13.5px; min-height: 62px; display: flex; align-items: center; }
.price { font: 700 16px var(--serif); color: var(--gold-2); }
.tactions { display: flex; gap: 8px; margin-top: auto; }
.tactions .btn { flex: 1; }

/* ---------- Cards (rooms) ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.card h3 { font: 700 19px var(--serif); }
.card p { margin: 0; color: var(--muted); }
.card .row { display: flex; gap: 8px; margin-top: auto; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12.5px; color: var(--muted); font-weight: 600; }

/* ---------- Table list ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 20px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); gap: 10px; }
.panel-head h2 { font: 700 18px var(--serif); }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { text-align: left; padding: 12px 18px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 650; background: var(--bg-2); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td.r, .tbl th.r { text-align: right; }
.tbl .acts { display: flex; gap: 6px; justify-content: flex-end; }
.tbl tr:hover td { background: rgba(255, 255, 255, .015); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 56px 20px; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.empty img { width: 64px; height: 64px; opacity: .85; margin-bottom: 12px; }
.empty h3 { font: 700 20px var(--serif); margin-bottom: 6px; }
.empty p { color: var(--muted); margin: 0 0 18px; }

/* ---------- Chart ---------- */
.chart { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding: 18px 18px 10px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 100%; min-width: 0; }
.bar .fill { width: 100%; max-width: 54px; background: linear-gradient(180deg, var(--gold-2), #9a7117); border-radius: 6px 6px 2px 2px; min-height: 3px; }
.bar.today .fill { box-shadow: 0 0 0 1px var(--gold-2), 0 0 18px rgba(212, 166, 58, .35); }
.bar .amt { font-size: 11px; color: var(--muted); white-space: nowrap; }
.bar .lbl { font-size: 11.5px; color: var(--muted); text-transform: capitalize; }

.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 3px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 7px; cursor: pointer; color: var(--muted); font-weight: 650; }
.seg button.active { background: var(--surface-2); color: var(--gold-2); box-shadow: inset 0 0 0 1px var(--border); }

/* ---------- Modal ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .65); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .15s;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 460px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; box-shadow: var(--shadow); max-height: calc(100vh - 32px); overflow: auto;
  animation: pop .18s ease-out;
}
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } }
.modal-h { padding: 18px 22px 0; display: flex; justify-content: space-between; align-items: center; }
.modal-h h2 { font: 700 20px var(--serif); }
.x { border: 0; background: none; color: var(--muted); font-size: 24px; line-height: 1; cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.x:hover { color: var(--text); background: var(--surface-2); }
.modal-b { padding: 16px 22px 8px; display: flex; flex-direction: column; gap: 14px; }
.modal-f { padding: 14px 22px 20px; display: flex; gap: 10px; justify-content: flex-end; }
.modal-f .btn { min-width: 100px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12.5px; font-weight: 650; color: var(--muted); }
.field > label i { font-style: normal; font-weight: 500; opacity: .7; }
.field input[type=text], .field input[type=number], .field input[type=password], .field select, .field textarea {
  width: 100%; background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--gold); outline: none; box-shadow: 0 0 0 3px rgba(212, 166, 58, .18); }
.field textarea { resize: vertical; min-height: 70px; }
.field.err input, .field.err select { border-color: var(--busy); }
.field .msg { color: var(--busy); font-size: 12.5px; min-height: 0; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--gold); }

.receipt { background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; padding: 4px 16px; }
.receipt .line { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--border); }
.receipt .line:last-child { border-bottom: 0; }
.receipt .line span:first-child { color: var(--muted); }
.receipt .total { font: 700 24px var(--serif); color: var(--gold-2); padding: 14px 0 10px; }
.receipt .total span:first-child { color: var(--text); font: 700 15px var(--sans); }

/* ---------- Toasts ---------- */
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 80; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px); }
.toast {
  background: var(--surface-2); border: 1px solid var(--border); border-left: 4px solid var(--free);
  padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow); animation: pop .2s ease-out;
}
.toast.error { border-left-color: var(--busy); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .brand-sub { display: none; }
}
@media (max-width: 720px) {
  .topbar-in { flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
  .brand { order: 1; flex: 1; }
  .langs { order: 2; }
  .nav { order: 3; flex-basis: 100%; }
  main { padding: 18px 14px 50px; }
  .page-head h1 { font-size: 22px; }
  .stat .value { font-size: 21px; }
  .tbl th, .tbl td { padding: 10px 12px; }
  .hide-sm { display: none; }
  .modal-f { flex-direction: column-reverse; }
  .modal-f .btn { width: 100%; }
  .table-wrap { overflow-x: auto; }
}

/* ============================================================
   v2: auth, roles, timed games, statistics, settings
   ============================================================ */
[hidden] { display: none !important; }
.btn.lg { padding: 12px 18px; font-size: 16px; border-radius: 12px; }
.btn.icon { padding: 7px 9px; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; position: relative; }
.auth-lang { position: absolute; top: 16px; right: 16px; }
.auth-card {
  width: 100%; max-width: 400px; background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--border); border-radius: 20px; padding: 32px 28px 28px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px;
}
.auth-logo { width: 72px; height: 72px; margin: 0 auto; filter: drop-shadow(0 4px 14px rgba(212, 166, 58, .4)); }
.auth-brand { text-align: center; font: 700 30px/1 var(--serif); letter-spacing: .5px; }
.auth-brand b { color: var(--gold); }
.auth-card h1 { font: 700 20px var(--serif); text-align: center; margin-top: 6px; }
.auth-card p { text-align: center; margin: -6px 0 4px; font-size: 14px; }
.form-error { color: var(--busy); font-size: 13.5px; min-height: 18px; text-align: center; }

/* ---------- User chip / roles ---------- */
.me { display: flex; align-items: center; gap: 8px; }
.me-text { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; line-height: 1.1; font-size: 13px; }
.role-badge { display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; }
.role-badge.admin { color: var(--gold-2); background: rgba(212, 166, 58, .14); border: 1px solid rgba(212, 166, 58, .35); }
.role-badge.manager { color: #7cc4ff; background: rgba(80, 160, 240, .12); border: 1px solid rgba(80, 160, 240, .3); }

/* ---------- Start dialog ---------- */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode {
  text-align: left; background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px;
  cursor: pointer; display: flex; flex-direction: column; gap: 3px; transition: .15s;
}
.mode b { display: flex; align-items: center; gap: 6px; font-size: 15px; }
.mode b svg { width: 16px; height: 16px; }
.mode span { font-size: 12.5px; color: var(--muted); }
.mode:hover { border-color: #3a4540; }
.mode.active { border-color: var(--gold); background: rgba(212, 166, 58, .08); box-shadow: 0 0 0 3px rgba(212, 166, 58, .12); }
.chips.tight { margin: 0; gap: 6px; }
.chips.tight .chip { padding: 6px 12px; }
.price-line { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 14px; margin-top: 4px; background: var(--bg-2); border: 1px dashed var(--border); border-radius: 10px; }
.price-line span { color: var(--muted); }
.price-line b { font: 700 20px var(--serif); color: var(--gold-2); }

/* ---------- Timed cards ---------- */
.live .progress { grid-column: 1 / -1; height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.live .progress i { display: block; height: 100%; width: 0; background: var(--gold); border-radius: 99px; transition: width 1s linear; }
.live.over .v:first-child, .live.over [data-f=clock] { color: var(--busy); }
.live.over .progress i { background: var(--busy); }
.tcard.expired { --c: var(--busy); animation: alarm 1.2s ease-in-out infinite; }
.tcard.expired .felt { fill: #b0302c !important; }
@keyframes alarm { 50% { box-shadow: 0 0 0 3px rgba(224, 82, 77, .55), 0 0 28px rgba(224, 82, 77, .35); } }
@media (prefers-reduced-motion: reduce) { .tcard.expired { animation: none; box-shadow: 0 0 0 3px rgba(224, 82, 77, .55); } }
.tactions { flex-wrap: wrap; }
.tactions .btn { min-width: 0; }

/* ---------- Layout helpers ---------- */
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.two-col > * { min-width: 0; }
.pad { padding: 18px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.sub-h { font: 700 15px var(--serif); margin: 20px 0 0; padding-top: 18px; border-top: 1px solid var(--border); }
.tbl tr.dim td { opacity: .55; }
.foot-hint { padding: 0 18px 14px; font-size: 12.5px; }

/* ---------- Charts ---------- */
.chart.dense { gap: 3px; }
.chart.dense .bar .fill { max-width: none; border-radius: 3px 3px 1px 1px; }
.chart.hours { gap: 3px; height: 140px; padding-bottom: 6px; }
.chart.hours .bar .fill { max-width: none; border-radius: 3px 3px 1px 1px; }
.chart .bar { cursor: default; }

.hbars { display: flex; flex-direction: column; gap: 16px; }
.hb-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; margin-bottom: 6px; }
.hb-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-val { white-space: nowrap; font-size: 13.5px; }
.hb-val i { font-style: normal; color: var(--muted); margin-left: 6px; }
.hb-track { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.hb-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, #9a7117, var(--gold-2)); }
.hb-sub { margin-top: 5px; font-size: 12px; color: var(--muted); }

.split-wrap { padding: 22px 18px; display: flex; flex-direction: column; gap: 18px; }
.split { display: flex; height: 16px; border-radius: 99px; overflow: hidden; background: var(--surface-2); }
.split i { display: block; height: 100%; }
.split .a, .sw.a { background: var(--gold); }
.split .b, .sw.b { background: #4fa3e8; }
.legend { display: flex; flex-direction: column; gap: 10px; }
.legend > div { display: grid; grid-template-columns: 14px 1fr auto auto; gap: 10px; align-items: baseline; }
.legend small { color: var(--muted); min-width: 70px; text-align: right; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }

/* ---------- Settings ---------- */
.profile { display: flex; align-items: center; gap: 14px; }
.avatar { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font: 700 20px var(--serif); color: #15110a; background: linear-gradient(135deg, var(--gold-2), var(--gold)); }
.linkbox { background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; overflow-x: auto; }
.linkbox code { font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--gold-2); white-space: nowrap; }

@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
  .me-text { display: none; }
}
@media (max-width: 720px) {
  .modes { grid-template-columns: 1fr; }
  .me { order: 2; }
  .brand { flex: 1; }
  .langs { order: 2; }
  .stats[style] { grid-template-columns: repeat(2, 1fr) !important; }
}

a.btn { text-decoration: none; }
.field input[type=password]:-webkit-autofill { -webkit-text-fill-color: var(--text); box-shadow: 0 0 0 100px var(--bg-2) inset; }

.tactions .btn.wide { flex-basis: 100%; }

/* nav fits 7 items + user chip on a 1280px screen */
.nav a { padding: 8px 11px; }
.topbar-in { gap: 18px; }
@media (max-width: 1400px) { .brand-sub { display: none; } }

/* ============================================================
   v3: products, POS, bill lines
   ============================================================ */
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.tactions .btn.half { flex: 1 1 40%; }
.items-line { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--gold-2); }
.items-line svg { width: 15px; height: 15px; flex: none; }
.pill.bad { color: var(--busy); border-color: rgba(224, 82, 77, .4); }
.pill.warn { color: var(--paused); border-color: rgba(229, 164, 47, .4); }
.split .c, .sw.c { background: #8fd18b; }
.top-h { font: 700 14px var(--serif); margin-top: 4px; padding-top: 16px; border-top: 1px solid var(--border); }
.empty.small { padding: 28px 16px; }

.modal.wide { max-width: 860px; }
.pos { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(250px, 1fr); gap: 18px; min-height: 380px; }
.pos-search { width: 100%; background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.pos-search:focus { border-color: var(--gold); outline: none; box-shadow: 0 0 0 3px rgba(212, 166, 58, .18); }
#pos-grid { max-height: 52vh; overflow-y: auto; padding-right: 4px; }
.pos-cat { font-size: 11.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 700; margin: 12px 0 8px; }
.pos-cat:first-child { margin-top: 2px; }
.pos-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.pos-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: left; cursor: pointer;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; transition: .12s; min-height: 78px;
}
.pos-item:hover:not(:disabled) { border-color: var(--gold); background: rgba(212, 166, 58, .07); }
.pos-item:active:not(:disabled) { transform: scale(.97); }
.pos-item:disabled { opacity: .45; cursor: not-allowed; }
.pi-name { font-weight: 650; line-height: 1.2; }
.pi-price { color: var(--gold-2); font: 700 14px var(--serif); margin-top: auto; }
.pi-stock { font-size: 11.5px; color: var(--muted); }
.pi-stock.warn { color: var(--paused); }
.pi-stock.bad { color: var(--busy); font-weight: 700; }

.pos-cart { background: var(--bg-2); border: 1px solid var(--border); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.pos-cart h3 { display: flex; align-items: center; gap: 8px; font: 700 16px var(--serif); }
.pos-cart h3 svg { width: 18px; height: 18px; }
#pos-lines { flex: 1; display: flex; flex-direction: column; gap: 8px; max-height: 34vh; overflow-y: auto; }
.pos-empty { padding: 26px 0; text-align: center; }
.pos-line { display: grid; grid-template-columns: 1fr auto auto; gap: 6px 10px; align-items: center; padding-bottom: 8px; border-bottom: 1px dashed var(--border); position: relative; }
.pl-name { display: flex; flex-direction: column; min-width: 0; }
.pl-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-name span { font-size: 12.5px; }
.pl-sum { grid-column: 1 / 3; font-size: 14px; color: var(--gold-2); }
.pos-line .x { grid-column: 3; grid-row: 2; justify-self: end; font-size: 20px; padding: 0 8px; }
.stepper { display: inline-flex; align-items: center; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.stepper button { width: 34px; height: 32px; border: 0; background: none; color: var(--text); font-size: 18px; cursor: pointer; }
.stepper button:hover:not(:disabled) { background: rgba(255, 255, 255, .08); }
.stepper span { min-width: 28px; text-align: center; font-weight: 700; }
.pos-total { display: flex; justify-content: space-between; align-items: baseline; padding-top: 6px; }
.pos-total span { color: var(--muted); }
.pos-total b { font: 700 24px var(--serif); color: var(--gold-2); }
.pos-note { width: 100%; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; }
.pos-hint { font-size: 12.5px; margin: 0; }
@media (max-width: 720px) {
  .pos { grid-template-columns: 1fr; }
  #pos-grid { max-height: 32vh; }
  #pos-lines { max-height: 24vh; }
}
.tactions .br { flex-basis: 100%; height: 0; }

/* Product pictures */
.thumb { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; flex: none; background: var(--bg-2); border: 1px solid var(--border); }
.thumb.none { display: inline-block; }
.thumb.lg { width: 72px; height: 72px; border-radius: 14px; }
.pname { display: flex; align-items: center; gap: 12px; }
.photo-pick { display: flex; align-items: center; gap: 14px; }
.photo-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.pi-img { width: 100%; height: 72px; object-fit: cover; border-radius: 8px; margin-bottom: 4px; }
