:root {
  --bg: #ececec;
  --ink: #2a2a2a;
  --muted: #6d6d6d;
  --header: #2c2c2f;
  --sidebar: #353538;
  --sidebar-2: #2f2f32;
  --accent: #c5d52b;
  --accent-ink: #1d2200;
  --panel: #fff;
  --line: #ddd;
  --head: #3c3c40;
  --blue: #2d6ca8;
  --blue-2: #24598a;
  --danger: #c0392b;
  --ok: #2e7d32;
  --warn: #b8860b;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  --font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
}
a { color: var(--blue); text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
button, input, select, textarea { font-family: inherit; font-size: 14px; }
h1, h2, h3, p { margin: 0; }

.app-header {
  min-height: 62px;
  background: var(--header);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 8px 16px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  min-width: 210px;
}
.brand-mark {
  width: 36px;
  height: 36px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
  display: grid;
  place-items: center;
  border-radius: 4px;
}
.brand small { display: block; color: #bdbdbd; font-size: 11px; letter-spacing: 0.04em; }
.loc-switch { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 160px; }
.loc-switch select {
  background: #242427;
  color: #fff;
  border: 1px solid #555;
  border-radius: 4px;
  padding: 6px 8px;
  max-width: 280px;
  min-width: 0;
  width: 100%;
}
a.alert-inline, .alert-inline { color: #ffb4b4; font-size: 13px; text-decoration: underline; }
.header-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.icon-btn, .user-chip {
  background: transparent;
  color: #eee;
  border: 0;
  position: relative;
}
.icon-btn { width: 36px; height: 36px; border-radius: 4px; cursor: pointer; }
.icon-btn:hover, .menu:focus-within .icon-btn { background: #45454a; }
.badge {
  position: absolute;
  top: 2px;
  right: 0;
  background: var(--danger);
  color: #fff;
  border-radius: 8px;
  font-size: 10px;
  min-width: 16px;
  padding: 1px 4px;
}
.menu { position: relative; }
.menu-pop {
  display: none;
  position: absolute;
  right: 0;
  top: 40px;
  background: #fff;
  color: var(--ink);
  min-width: 240px;
  border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
  border-radius: 4px;
  z-index: 30;
}
.menu:hover .menu-pop, .menu:focus-within .menu-pop { display: block; }
.menu-pop a, .menu-pop .empty, .menu-pop .menu-link {
  display: block;
  width: 100%;
  margin: 0;
  font: inherit;
  text-align: left;
  padding: 10px 12px;
  color: var(--ink);
  border: 0;
  border-bottom: 1px solid #f0f0f0;
  background: transparent;
  cursor: pointer;
}
.menu-pop form { margin: 0; }
.menu-pop a:hover, .menu-pop .menu-link:hover { background: #f7f7f7; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 4px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 700;
}
.user-chip small { display: block; color: #c8c8c8; font-size: 11px; }

.shell { display: flex; min-height: calc(100vh - 62px); align-items: stretch; }
.sidebar {
  width: 230px;
  background: linear-gradient(#3a3a3e, #2e2e31);
  color: #ddd;
  flex: none;
  padding-top: 12px;
}
.searchbox { padding: 0 12px 12px; }
.searchbox form { display: flex; background: #222; border-radius: 4px; overflow: hidden; }
.searchbox input {
  flex: 1; border: 0; background: transparent; color: #fff; padding: 8px 10px; min-width: 0;
}
.searchbox button { border: 0; background: var(--accent); color: var(--accent-ink); padding: 0 10px; cursor: pointer; font-weight: 700; }
.nav a {
  display: flex; align-items: center; gap: 8px;
  color: #e6e6e6; padding: 11px 16px; border-left: 3px solid transparent;
}
.nav a:hover { background: rgba(255,255,255,.04); }
.nav a.active { background: rgba(197, 213, 43, .14); border-left-color: var(--accent); color: var(--accent); }
.nav .sub a { padding-left: 36px; font-size: 13px; color: #cfcfcf; }
.nav-label { padding: 14px 16px 4px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #9a9a9a; }
.main { flex: 1; padding: 18px 20px 40px; min-width: 0; }
.footer { color: #888; font-size: 12px; padding: 18px 4px; }

.page-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.panel {
  background: var(--panel);
  border: 1px solid #d5d5d5;
  border-radius: 4px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.panel-h {
  background: var(--head);
  color: #fff;
  padding: 10px 14px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.panel-b { padding: 14px; }
.panel-b.flush { padding: 0; overflow-x: auto; }
.stat-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.stat {
  background: var(--panel);
  border: 1px solid #d5d5d5;
  border-radius: 4px;
  min-width: 120px;
  padding: 10px 14px;
  color: inherit;
  box-shadow: var(--shadow);
}
a.stat:hover { border-color: var(--blue); }
.stat strong { display: block; font-size: 22px; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 12px; }
.qty-low { color: var(--warn); font-weight: 700; }
.qty-out { color: var(--danger); font-weight: 700; }
.note {
  background: #e8f4fb;
  border: 1px solid #c5e2f2;
  color: #24596f;
  padding: 10px 12px;
  border-radius: 4px;
  margin-bottom: 12px;
}
.note.warn { background: #fff6e8; border-color: #f0ddb0; color: #7a5b12; }
.flash { padding: 10px 12px; border-radius: 4px; margin-bottom: 12px; }
.flash.ok { background: #e8f6ea; color: #1d6b28; border: 1px solid #b7e0be; }
.flash.err { background: #fdecea; color: #92261c; border: 1px solid #f5c2c0; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid #c8c8c8; background: #f7f7f7; color: #333;
  padding: 7px 12px; border-radius: 3px; cursor: pointer; text-decoration: none;
}
.btn:hover { background: #fff; }
.btn.primary { background: var(--blue); border-color: var(--blue-2); color: #fff; }
.btn.primary:hover { background: var(--blue-2); }
.btn.danger { background: var(--danger); border-color: #962d22; color: #fff; }
.btn.lime { background: var(--accent); border-color: #adba22; color: var(--accent-ink); font-weight: 700; }
.btn.large { padding: 10px 14px; }
.btn.red { background: #d6453d; border-color: #b4332c; color: #fff; }
.btn.small { padding: 4px 8px; font-size: 12px; }
.btn-row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-form { display: grid; grid-template-columns: 220px 1fr; gap: 8px 14px; align-items: start; }
.grid-form label { padding-top: 8px; color: #444; }
.hint { color: #900; font-size: 12px; }
.field, .grid-form input, .grid-form select, .grid-form textarea,
.stack input, .stack select, .stack textarea {
  width: 100%;
  border: 1px solid #ccc;
  border-radius: 3px;
  padding: 8px 10px;
  background: #fff;
}
.stack input[type="checkbox"],
.stack input[type="radio"],
.grid-form input[type="checkbox"],
.grid-form input[type="radio"],
.check input { width: auto; padding: 0; }
textarea { min-height: 90px; resize: vertical; }
.stack { display: grid; gap: 8px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.req { color: #c0392b; }

.edit-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.edit-row input, .edit-row select { width: auto; min-width: 90px; padding: 6px 8px; border: 1px solid #ccc; border-radius: 3px; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: 8px 10px; border-bottom: 1px solid #eee; text-align: left; vertical-align: top; }
table.data th { background: #f6f6f6; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: #555; }
table.data tr:hover td { background: #fafafa; }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.tag {
  display: inline-block; padding: 2px 7px; border-radius: 10px;
  background: #eee; font-size: 12px;
}
.tag.open { background: #e7f1fb; color: #1d4e89; }
.tag.closed { background: #e7f6ea; color: #1e6b32; }
.tag.wait { background: #fff4d6; color: #7a5a00; }

.steps { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.steps span {
  padding: 6px 10px; border-radius: 99px; background: #eee; color: #666; font-size: 12px;
}
.steps span.on { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.wizard-step { display: none; }
.wizard-step.on { display: block; }
.check { display: flex; gap: 8px; align-items: center; }
.service-list, .pick {
  border: 1px solid #ccc; border-radius: 3px; max-height: 280px; overflow: auto; padding: 6px;
  background: #fff;
}
.service-list label, .pick label { display: flex; gap: 8px; padding: 5px 6px; align-items: flex-start; }
.service-list label:hover, .pick label:hover { background: #f6f6f6; }
.price-pill { margin-left: auto; color: #666; }

.summary { display: grid; grid-template-columns: 180px 1fr; gap: 6px 10px; }
.summary .k { color: #666; }
.cards { display: grid; grid-template-columns: 1.2fr .8fr; gap: 16px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.filters input, .filters select { padding: 7px 8px; border: 1px solid #ccc; border-radius: 3px; background: #fff; }

.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: none; align-items: center; justify-content: center; z-index: 50; padding: 16px;
}
.modal.on { display: flex; }
.dialog {
  background: #fff; width: min(720px, 100%); border-radius: 6px; overflow: hidden;
  box-shadow: 0 16px 50px rgba(0,0,0,.25);
}
.dialog h3 { background: var(--head); color: #fff; padding: 12px 14px; }
.dialog .body { padding: 16px; }
.barcode-input {
  font-family: ui-monospace, monospace; font-size: 28px; font-weight: 700;
  text-align: center; letter-spacing: .08em; text-transform: uppercase;
  width: 100%; padding: 12px; border: 0; border-bottom: 2px solid #333;
}
.scan-layout { display: grid; grid-template-columns: 160px 1fr; gap: 12px; align-items: center; }
.scan-visual {
  height: 140px; border: 1px dashed #bbb; border-radius: 6px;
  display: grid; place-items: center; color: #888; background:
    repeating-linear-gradient(90deg, #222 0 2px, transparent 2px 6px, #222 6px 8px, transparent 8px 11px);
}

.login-wrap {
  min-height: 100%; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(circle at top, #fafafa, #e4e4e4 55%);
}
.login-card {
  width: min(420px, 100%); background: #fff; border: 1px solid #ddd;
  border-radius: 6px; box-shadow: 0 10px 30px rgba(0,0,0,.08); padding: 22px;
}
.login-card h1 { font-size: 22px; margin-bottom: 8px; }
.lock {
  width: 54px; height: 54px; border-radius: 50%; background: var(--header); color: var(--accent);
  display: grid; place-items: center; font-size: 22px; margin-bottom: 12px;
}
.login-card .stack { margin-top: 12px; }
.fine { color: #888; font-size: 12px; margin-top: 12px; }

.invoice { max-width: 800px; margin: 20px auto; background: #fff; padding: 28px; border: 1px solid #ddd; }
.invoice-top { display: flex; justify-content: space-between; gap: 20px; border-bottom: 3px solid var(--accent); padding-bottom: 12px; }
.code { font-family: ui-monospace, monospace; font-size: 20px; font-weight: 700; }
.barcode-page { max-width: 520px; margin: 30px auto; background: #fff; padding: 24px; text-align: center; border: 1px solid #ddd; }
.user-block { border: 1px solid #eee; padding: 10px; margin-bottom: 8px; border-radius: 4px; background: #fafafa; }
.hidden { display: none; }
.menu-toggle { display: none; }

@media (max-width: 900px) {
  .grid-2, .cards, .grid-form, .scan-layout, .cols { grid-template-columns: 1fr; }
  .grid-form label { padding-top: 0; }
  .sidebar { display: none; }
  .sidebar.on { display: block; position: fixed; z-index: 40; top: 70px; bottom: 0; }
  .menu-toggle { display: inline-flex; }
  .brand small, .alert-inline { display: none; }
  .loc-switch { flex: 1 1 100%; order: 5; }
  .header-tools { margin-left: auto; }
}
@media print {
  .app-header, .sidebar, .page-actions, .no-print { display: none !important; }
  .main { padding: 0; }
  body { background: #fff; }
  .invoice, .barcode-page { border: 0; margin: 0; }
}
