:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #667085;
  --line: #e6eaf2;
  --green: #0f9f6e;
  --green-dark: #067a52;
  --yellow: #f5a524;
  --red: #ee4d4d;
  --blue: #3468ff;
  --navy: #101828;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 264px;
  background: linear-gradient(180deg, #0b1220, #15213a);
  color: white;
  padding: 24px 18px;
  position: sticky;
  top: 0;
  min-height: 100vh;
}
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 28px; }
.brand-mark {
  width: 46px; height: 46px; border-radius: 16px;
  display: grid; place-items: center;
  color: #0b1220; font-weight: 900;
  background: linear-gradient(135deg, #39d98a, #ffd166);
}
.brand-logo {
  width: 72px; height: 50px; object-fit: contain; border-radius: 12px; background: white; padding: 4px;
}
.brand span, .sidebar-card small { display: block; color: #b8c2d8; font-size: 12px; }
nav { display: grid; gap: 7px; }
nav a {
  color: #d9e2f2; text-decoration: none; padding: 12px 14px;
  border-radius: 14px; font-weight: 650;
}
nav a.active, nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.sidebar-card {
  margin-top: 30px; padding: 16px; border-radius: 18px;
  background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.12);
}
.app-shell { flex: 1; padding: 28px; max-width: 1500px; margin: 0 auto; }
.topbar, .panel-title, .top-actions, .pay-row, .table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
h1, h2, p { margin: 0; }
h1 { font-size: 30px; letter-spacing: -0.04em; }
h2 { font-size: 20px; letter-spacing: -0.025em; }
.eyebrow { color: var(--green-dark); text-transform: uppercase; font-size: 12px; font-weight: 800; letter-spacing: .09em; margin-bottom: 4px; }
button { border: 0; border-radius: 13px; padding: 11px 16px; font-weight: 800; cursor: pointer; }
.primary, .checkout { background: var(--green); color: white; box-shadow: 0 12px 24px rgba(15,159,110,.22); }
.ghost { background: #eef3fb; color: #25324a; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin: 24px 0; }
.stat-card, .panel { background: var(--panel); border: 1px solid var(--line); border-radius: 24px; box-shadow: 0 18px 45px rgba(16,24,40,.06); }
.stat-card { padding: 20px; position: relative; overflow: hidden; }
.stat-card:after { content: ""; position: absolute; right: -25px; top: -25px; width: 90px; height: 90px; border-radius: 999px; opacity: .14; background: currentColor; }
.stat-card span, .pay-row span, label { color: var(--muted); font-weight: 700; }
.stat-card strong { display: block; margin: 8px 0 4px; font-size: 26px; }
.stat-card small { color: var(--muted); }
.green { color: var(--green); }.yellow { color: var(--yellow); }.red { color: var(--red); }.blue { color: var(--blue); }
.pos-layout { display: grid; grid-template-columns: minmax(0, 1.7fr) 390px; gap: 18px; align-items: start; }
.panel { padding: 22px; }
.scan-box { display: grid; grid-template-columns: 1fr auto; gap: 12px; margin: 18px 0; }
input, select { width: 100%; border: 1px solid var(--line); background: #fbfcff; padding: 13px 14px; border-radius: 14px; font-size: 15px; outline: none; }
.scan-box input { font-size: 24px; font-weight: 850; letter-spacing: .04em; }
.quick-cats { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 18px; }
.quick-cats button, .payment-methods button { background: #f0f4f9; color: #344054; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .07em; }
th, td { padding: 13px 10px; border-bottom: 1px solid var(--line); }
td { font-weight: 650; }
.payment-panel { position: sticky; top: 20px; }
.payment-panel h2 { margin-bottom: 18px; }
.pay-row { padding: 12px 0; border-bottom: 1px dashed var(--line); }
.pay-row.total b { font-size: 24px; color: var(--green-dark); }
.payment-methods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0 16px; }
.payment-methods .active { background: #dcfce7; color: var(--green-dark); }
.money-input { font-size: 24px; font-weight: 850; margin: 8px 0 14px; }
.change-box { background: #101828; color: white; border-radius: 18px; padding: 16px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.change-box span { color: #b8c2d8; }
.change-box strong { font-size: 24px; }
.checkout { width: 100%; font-size: 16px; padding: 15px; }
.product-panel { margin-top: 18px; }
.table-toolbar { margin: 18px 0; }
.table-toolbar input { flex: 1.5; }
.pill { padding: 6px 10px; border-radius: 999px; font-size: 12px; font-weight: 850; }
.pill.live, .pill.ok { background: #dcfce7; color: #067a52; }
.pill.warn { background: #fff4d6; color: #a15c00; }
@media (max-width: 1100px) {
  body { display: block; }
  .sidebar { width: auto; min-height: auto; position: static; }
  nav { grid-template-columns: repeat(4, 1fr); }
  .stats-grid, .pos-layout { grid-template-columns: 1fr; }
  .payment-panel { position: static; }
}
@media (max-width: 680px) {
  .app-shell { padding: 16px; }
  nav { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: 1fr; }
  .topbar, .panel-title, .table-toolbar { align-items: stretch; flex-direction: column; }
}

.muted { color: var(--muted); }
.suggestions { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; margin: 0 0 16px; }
.suggestions button { text-align: left; background: #f8fbff; border: 1px solid var(--line); color: var(--ink); }
.suggestions button span { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }
.qty-btn, .remove-btn { padding: 5px 9px; border-radius: 9px; background: #eef3fb; color: #25324a; }
.remove-btn { background: #ffe9e9; color: #b42318; }
.cart-table small { display: block; margin-top: 3px; color: var(--muted); font-weight: 600; }
@media (max-width: 900px) { .suggestions { grid-template-columns: 1fr; } }

.login-screen {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: radial-gradient(circle at top left, rgba(57,217,138,.25), transparent 30%), linear-gradient(135deg, #0b1220, #15213a 58%, #0f9f6e);
  padding: 20px;
}
.login-card {
  width: min(420px, 100%); background: #fff; border-radius: 28px; padding: 28px;
  box-shadow: 0 30px 80px rgba(0,0,0,.25); text-align: center;
}
.login-logo { width: 210px; max-width: 100%; margin-bottom: 16px; }
.login-roles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 20px 0 12px; }
.login-roles button { background: #eef3fb; color: #25324a; border: 2px solid transparent; }
.login-roles button.active { background: #dcfce7; color: #067a52; border-color: #0f9f6e; }
.login-card input { margin-bottom: 12px; text-align: center; font-size: 20px; font-weight: 800; }
.login-error { color: #b42318; min-height: 20px; font-weight: 700; margin-top: 10px; }
body.locked .sidebar, body.locked .app-shell { display: none !important; }

.login-card h2 { font-size: 28px; margin-bottom: 6px; color: var(--navy); }
.login-card .eyebrow { margin-top: 4px; }
.login-screen[style*="none"] { display: none !important; }

/* loginfix2-hardening */
body.locked .sidebar, body.locked .app-shell { display: none !important; }
#loginScreen.login-screen {
  position: fixed !important;
  inset: 0 !important;
  z-index: 99999 !important;
  display: grid;
  place-items: center;
  min-height: 100dvh;
  overflow-y: auto;
  background: radial-gradient(circle at top left, rgba(57,217,138,.25), transparent 30%), linear-gradient(135deg, #0b1220, #15213a 58%, #0f9f6e) !important;
  padding: 18px;
}
body:not(.locked) #loginScreen { display: none !important; }
.login-card { margin: auto; }
@media (max-width: 520px) {
  #loginScreen.login-screen { place-items: start center; padding: 16px 12px; }
  .login-card { width: 100%; border-radius: 22px; padding: 20px 16px; margin-top: 12px; }
  .login-logo { width: 180px; margin-bottom: 10px; }
  .login-card h2 { font-size: 24px; }
  .login-card input { font-size: 18px; padding: 14px; }
  .login-roles button { padding: 11px 12px; }
}

/* rolefix1: strict role pages */
body.role-cashier .admin-only { display: none !important; }
body.role-admin .cashier-only { display: none !important; }
body.role-cashier .sidebar nav { grid-template-columns: 1fr !important; }
body.role-cashier .app-shell { max-width: 980px; }
body.role-cashier .top-actions { justify-content: flex-start; }
body.role-cashier .pos-layout { grid-template-columns: minmax(0, 1fr); }
body.role-cashier .payment-panel { position: static; }
body.role-admin .sidebar-card { display: none; }
body.role-admin .app-shell { max-width: 1280px; }
@media (max-width: 1100px) {
  body.role-cashier nav { grid-template-columns: 1fr !important; }
  body.role-admin nav { grid-template-columns: repeat(2, 1fr); }
}

/* scanner1 */
.scanner-help {
  margin: 14px 0 10px;
  padding: 12px 14px;
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
  color: #067a52;
  border-radius: 14px;
  font-weight: 700;
  line-height: 1.45;
}
.scan-box input:focus {
  border-color: #0f9f6e;
  box-shadow: 0 0 0 4px rgba(15,159,110,.13);
  background: #fff;
}
.pill.scanning, #scannerStatus.scanning { background: #dbeafe; color: #1d4ed8; }
.pill.error, #scannerStatus.error { background: #fee2e2; color: #b42318; }

/* scanner2 */
.last-scan {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 13px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  color: #475569;
  font-weight: 700;
  font-size: 13px;
}
.last-scan.ok { background: #ecfdf5; border-color: #86efac; color: #067a52; }
.last-scan.error { background: #fef2f2; border-color: #fecaca; color: #b42318; }
