:root {
  --primary: #5B2EFF; --primary-ink: #4520D6; --primary-soft: #EFEAFF;
  --accent: #FFC83D; --green: #0E9F6E; --green-soft: #E4F8EE; --red: #DC2626; --red-soft: #FDECEC;
  --bg: #F5F6FA; --surface: #FFFFFF; --surface-2: #F9FAFC; --line: #E8E9F0;
  --text: #14151C; --muted: #6B6F80; --radius: 16px; --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20,21,28,.04), 0 6px 24px rgba(20,21,28,.06);
  --shadow-lg: 0 20px 60px rgba(20,21,28,.18);
}
@media (prefers-color-scheme: dark) {
  :root:not(.light) {
    --bg: #0E0F14; --surface: #171821; --surface-2: #1D1F2A; --line: #2A2C39; --text: #F1F2F7; --muted: #9A9DB0;
    --primary-soft: #251C4D; --green-soft: #0F2E24; --red-soft: #3A1717;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 24px rgba(0,0,0,.25);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: 'Plus Jakarta Sans', system-ui, -apple-system, Segoe UI, Roboto, sans-serif; background: var(--bg); color: var(--text); font-size: 14.5px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.01em; }
img { max-width: 100%; display: block; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.strike { text-decoration: line-through; color: var(--muted); }
.row { display: flex; align-items: center; } .row.gap { gap: 10px; } .row.end { justify-content: flex-end; } .row.between { justify-content: space-between; } .row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.hidden { display: none !important; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; cursor: pointer; font: inherit; font-weight: 700;
  padding: 10px 16px; border-radius: 12px; background: var(--primary); color: #fff; transition: transform .08s, background .15s, opacity .15s; white-space: nowrap; }
.btn:hover { background: var(--primary-ink); } .btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); } .btn.ghost:hover { background: var(--surface-2); }
.btn.soft { background: var(--primary-soft); color: var(--primary); } .btn.soft:hover { filter: brightness(.97); }
.btn.green { background: var(--green); } .btn.green:hover { filter: brightness(.93); }
.btn.danger { background: var(--red); } .btn.danger:hover { filter: brightness(.93); }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 9px; }
.btn.lg { padding: 14px 20px; font-size: 16px; border-radius: 14px; }
.btn.block { width: 100%; }
.icon-btn { border: 0; background: var(--surface-2); color: var(--text); width: 38px; height: 38px; border-radius: 11px; cursor: pointer; font-size: 17px; display: inline-grid; place-items: center; }

label.f { display: block; font-size: 12.5px; font-weight: 700; color: var(--muted); margin-bottom: 12px; }
label.f > span { display: block; margin-bottom: 5px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1.5px solid var(--line); border-radius: 11px; padding: 10px 12px; width: 100%; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--primary); }
.switch { position: relative; width: 44px; height: 26px; display: inline-block; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; background: var(--line); border-radius: 99px; transition: .2s; cursor: pointer; }
.switch i::after { content: ''; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch input:checked + i { background: var(--green); } .switch input:checked + i::after { transform: translateX(18px); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.pad { padding: 18px; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 700; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }

#toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 9999; display: grid; gap: 8px; pointer-events: none; }
.toast { background: #14151C; color: #fff; padding: 11px 18px; border-radius: 12px; font-weight: 600; box-shadow: var(--shadow-lg); animation: tin .25s ease; transition: .3s; max-width: 90vw; }
.toast.err { background: var(--red); } .toast.out { opacity: 0; transform: translateY(8px); }
@keyframes tin { from { opacity: 0; transform: translateY(10px); } }

.modal-wrap { position: fixed; inset: 0; background: rgba(12,12,20,.5); backdrop-filter: blur(3px); z-index: 1000; display: grid; place-items: center; padding: 16px; animation: fin .18s; }
.modal-wrap.out { opacity: 0; transition: .18s; }
.modal { position: relative; background: var(--surface); border-radius: 20px; padding: 24px; width: 100%; max-width: 440px; max-height: 90vh; overflow: auto; box-shadow: var(--shadow-lg); animation: min .22s cubic-bezier(.2,.9,.3,1.2); }
.modal.wide { max-width: 760px; }
.modal-x { position: absolute; right: 14px; top: 14px; border: 0; background: var(--surface-2); width: 32px; height: 32px; border-radius: 50%; cursor: pointer; color: var(--muted); font-size: 14px; }
@keyframes fin { from { opacity: 0; } } @keyframes min { from { opacity: 0; transform: translateY(16px) scale(.98); } }

.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 12px; }
@keyframes sk { to { background-position: -200% 0; } }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); } .empty .big { font-size: 46px; margin-bottom: 8px; }

/* ---------- Panel layout (admin / branch) ---------- */
.panel { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 18px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; padding: 4px 8px 18px; }
.brand .logo { width: 36px; height: 36px; border-radius: 11px; background: linear-gradient(135deg, var(--primary), #9B6BFF); display: grid; place-items: center; color: #fff; font-size: 18px; }
.brand small { display: block; font-size: 11px; color: var(--muted); font-weight: 600; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 11px; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.on { background: var(--primary-soft); color: var(--primary); }
.nav a .ico { width: 22px; text-align: center; font-size: 16px; }
.nav a .badge { margin-left: auto; background: var(--red); color: #fff; font-size: 11px; padding: 1px 7px; border-radius: 99px; }
.side .foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.main { padding: 22px 28px 60px; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.topbar h1 { font-size: 23px; font-weight: 800; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); display: inline-block; }
.live-dot.on { background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { padding: 16px 18px; }
.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.kpi .val { font-size: 26px; font-weight: 800; margin-top: 6px; letter-spacing: -.02em; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.grid2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 14px; margin-bottom: 18px; }
.chart { width: 100%; height: 230px; display: block; }
.section-title { font-weight: 800; font-size: 15.5px; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar input, .toolbar select { width: auto; min-width: 160px; }
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: 11px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.click { cursor: pointer; } .tbl tr.click:hover td { background: var(--surface-2); }
.thumb { width: 40px; height: 40px; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center; font-size: 22px; overflow: hidden; flex-shrink: 0; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.list-item:last-child { border-bottom: 0; }
.mobile-top { display: none; }

/* Kanban for live orders */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(230px, 1fr)); gap: 14px; overflow-x: auto; padding-bottom: 6px; }
.col { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; min-height: 300px; }
.col h4 { font-size: 13px; display: flex; justify-content: space-between; margin-bottom: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.ocard { background: var(--surface); border: 1px solid var(--line); border-radius: 13px; padding: 12px; margin-bottom: 10px; cursor: pointer; transition: .15s; box-shadow: var(--shadow); }
.ocard:hover { border-color: var(--primary); }
.ocard.new { animation: pulse 1.2s ease 3; border-color: var(--primary); }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px var(--primary-soft); } }
.timer { font-weight: 800; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--green-soft); color: var(--green); }
.timer.warn { background: #FFF4DF; color: #B45309; } .timer.late { background: var(--red-soft); color: var(--red); }

/* Login screen */
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 10% -10%, #E9E2FF, transparent), radial-gradient(900px 500px at 110% 110%, #FFF1C9, transparent), var(--bg); }
.login-card { width: 100%; max-width: 400px; padding: 30px; }

@media (max-width: 900px) {
  .panel { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; z-index: 500; width: 260px; transform: translateX(-100%); transition: transform .22s; box-shadow: var(--shadow-lg); }
  .side.open { transform: none; }
  .mobile-top { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 400; font-weight: 800; }
  .main { padding: 16px 14px 60px; }
  .grid2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .kanban { grid-template-columns: repeat(4, 82vw); }
}
.ocard .row.between { gap: 6px; align-items: flex-start; }
.ocard > .row.between:first-child b { font-size: 13px; word-break: break-all; }
