/* =====================================================================
   General Store POS — Design System
   One file, CSS variables + small reusable components on top of Bootstrap 5.
   ===================================================================== */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../vendor/inter/InterVariable.woff2") format("woff2");
}

:root {
  /* Brand */
  --brand-900: #073b30;
  --brand-800: #0a5040;
  --brand-700: #0d6b57;      /* primary */
  --brand-600: #12846c;
  --brand-100: #dcf1eb;
  --brand-50:  #eef8f5;
  --accent:    #e5a531;      /* warm saffron, used sparingly */
  --accent-100:#fbefd6;

  /* Neutrals (slightly warm) */
  --ink-900: #17201d;
  --ink-700: #3a4541;
  --ink-500: #67736e;
  --ink-400: #8b9691;
  --line:    #e4e8e6;
  --line-2:  #eef1ef;
  --surface: #ffffff;
  --canvas:  #f5f7f6;

  /* Status */
  --ok:      #198754;
  --warn:    #b7791f;
  --danger:  #c0392b;
  --info:    #2563a6;

  /* Sidebar */
  --side-bg:      #0e1f1b;
  --side-bg-2:    #13302a;
  --side-text:    #b9c9c3;
  --side-muted:   #6f8a82;
  --side-active:  #ffffff;
  --side-width:   248px;

  /* Shape & rhythm */
  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(16, 32, 28, .06);
  --shadow:    0 2px 8px rgba(16, 32, 28, .07), 0 1px 2px rgba(16, 32, 28, .05);
  --topbar-h:  60px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* Bootstrap overrides */
  --bs-body-font-family: var(--font);
  --bs-body-color: var(--ink-900);
  --bs-body-bg: var(--canvas);
  --bs-border-color: var(--line);
  --bs-primary: var(--brand-700);
  --bs-primary-rgb: 13, 107, 87;
  --bs-link-color: var(--brand-700);
  --bs-link-hover-color: var(--brand-800);
  --bs-link-color-rgb: 13, 107, 87;
  --bs-border-radius: var(--radius-sm);
  --bs-secondary-color: var(--ink-500);
}

html { font-size: 15px; }
body.app-body { background: var(--canvas); color: var(--ink-900); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, h5 { font-weight: 650; letter-spacing: -.01em; color: var(--ink-900); }
.text-muted { color: var(--ink-500) !important; }
.tabular { font-variant-numeric: tabular-nums; }

/* ---------- Buttons ---------- */
.btn { font-weight: 550; border-radius: var(--radius-sm); padding: .5rem .9rem; }
.btn-sm { padding: .3rem .65rem; }
.btn-lg { padding: .7rem 1.2rem; }
.btn-primary { --bs-btn-bg: var(--brand-700); --bs-btn-border-color: var(--brand-700);
  --bs-btn-hover-bg: var(--brand-800); --bs-btn-hover-border-color: var(--brand-800);
  --bs-btn-active-bg: var(--brand-900); --bs-btn-active-border-color: var(--brand-900);
  --bs-btn-disabled-bg: var(--brand-600); --bs-btn-disabled-border-color: var(--brand-600); }
.btn-outline-primary { --bs-btn-color: var(--brand-700); --bs-btn-border-color: var(--brand-700);
  --bs-btn-hover-bg: var(--brand-700); --bs-btn-hover-border-color: var(--brand-700);
  --bs-btn-active-bg: var(--brand-800); }
.btn-light { --bs-btn-bg: #fff; --bs-btn-border-color: var(--line); --bs-btn-hover-bg: var(--line-2); --bs-btn-hover-border-color: var(--line); }
.btn-icon { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; padding: 0; border-radius: 10px; font-size: 1.25rem; color: var(--ink-700); }
.btn-icon:hover { background: var(--line-2); }
.btn:focus-visible, .form-control:focus, .form-select:focus, .form-check-input:focus {
  box-shadow: 0 0 0 .2rem rgba(13, 107, 87, .2); border-color: var(--brand-600); }

/* ---------- Forms ---------- */
.form-label { font-weight: 550; font-size: .87rem; color: var(--ink-700); margin-bottom: .3rem; }
.form-control, .form-select { border-radius: var(--radius-sm); border-color: var(--line); padding: .55rem .8rem; min-height: 42px; background-color: #fff; }
.form-control:disabled, .form-select:disabled, .form-control[readonly] { background-color: var(--line-2); }
.form-control::placeholder { color: var(--ink-400); }
.form-text { color: var(--ink-500); font-size: .8rem; }
.form-check-input:checked { background-color: var(--brand-700); border-color: var(--brand-700); }
.required::after { content: " *"; color: var(--danger); }
.input-group-text { background: var(--line-2); border-color: var(--line); color: var(--ink-500); }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.app-sidebar {
  width: var(--side-width); flex: 0 0 var(--side-width);
  background: linear-gradient(180deg, var(--side-bg) 0%, var(--side-bg-2) 100%);
  color: var(--side-text); position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; z-index: 1040;
}
.sidebar-brand { display: flex; align-items: center; gap: .7rem; padding: 1.05rem 1.1rem; border-bottom: 1px solid rgba(255,255,255,.06); }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; background: var(--brand-700); color: #fff;
  display: grid; place-items: center; font-size: 1.15rem; box-shadow: inset 0 -2px 0 rgba(0,0,0,.15); flex-shrink: 0; }
.brand-text { min-width: 0; }
.brand-name { color: #fff; font-weight: 650; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: .72rem; color: var(--side-muted); letter-spacing: .04em; text-transform: uppercase; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: .6rem .6rem 1rem; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.12) transparent; }
.nav-group-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--side-muted); padding: .9rem .7rem .35rem; font-weight: 600; }
.nav-item { display: flex; align-items: center; gap: .7rem; padding: .55rem .7rem; border-radius: 9px;
  color: var(--side-text); text-decoration: none; font-size: .9rem; font-weight: 500; margin-bottom: 2px; min-height: 40px; }
.nav-item i { font-size: 1.05rem; width: 1.2rem; text-align: center; opacity: .9; }
a.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: rgba(18, 132, 108, .28); color: var(--side-active); box-shadow: inset 3px 0 0 var(--accent); }
.nav-item.is-soon { opacity: .45; cursor: default; }
.nav-item.is-soon em { margin-left: auto; font-style: normal; font-size: .65rem; border: 1px solid rgba(255,255,255,.25); border-radius: 6px; padding: 0 .35rem; }
.sidebar-foot { padding: .7rem 1.1rem; font-size: .72rem; color: var(--side-muted); border-top: 1px solid rgba(255,255,255,.06); }
.sidebar-backdrop { display: none; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar { height: var(--topbar-h); background: rgba(255,255,255,.92); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: .75rem;
  padding: 0 1.25rem; position: sticky; top: 0; z-index: 1030; }
.topbar-title { font-weight: 650; font-size: 1.05rem; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
.chip { display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .65rem; border-radius: 999px;
  background: var(--line-2); color: var(--ink-700); font-size: .8rem; font-weight: 550; white-space: nowrap; }
.user-btn { display: flex; align-items: center; gap: .55rem; background: none; border: 1px solid transparent; border-radius: 10px; padding: .25rem .45rem; }
.user-btn:hover { background: var(--line-2); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-100); color: var(--brand-800);
  display: grid; place-items: center; font-weight: 700; font-size: .8rem; }
.user-name { display: block; font-weight: 600; font-size: .86rem; }
.user-role { display: block; font-size: .74rem; color: var(--ink-500); }
.app-content { padding: 1.5rem; max-width: 1440px; width: 100%; }

@media (max-width: 991.98px) {
  .app-sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s ease; }
  .app-shell.sidebar-open .app-sidebar { transform: none; }
  .app-shell.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(10,20,18,.45); z-index: 1035; }
  .app-content { padding: 1rem; }
}

/* ---------- Page header ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem; margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.45rem; margin: 0; }
.page-head .sub { color: var(--ink-500); margin: .2rem 0 0; font-size: .9rem; }

/* ---------- Cards / panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .9rem 1.1rem; border-bottom: 1px solid var(--line-2); }
.panel-head h2, .panel-head h3 { font-size: 1rem; margin: 0; }
.panel-body { padding: 1.1rem; }
.panel-foot { padding: .85rem 1.1rem; border-top: 1px solid var(--line-2); background: #fbfcfb; border-radius: 0 0 var(--radius) var(--radius); }

.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; height: 100%;
  display: flex; gap: .9rem; align-items: flex-start; box-shadow: var(--shadow-sm); }
.stat-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-size: 1.15rem; flex-shrink: 0;
  background: var(--brand-50); color: var(--brand-700); }
.stat-icon.amber { background: var(--accent-100); color: #9a6a12; }
.stat-icon.blue  { background: #e6eef8; color: var(--info); }
.stat-icon.red   { background: #fbeaea; color: var(--danger); }
.stat-label { font-size: .8rem; color: var(--ink-500); font-weight: 550; }
.stat-value { font-size: 1.45rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-note { font-size: .75rem; color: var(--ink-400); margin-top: .15rem; }

/* ---------- Tables ---------- */
.table { --bs-table-color: var(--ink-900); margin-bottom: 0; }
.table > thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-500); font-weight: 600;
  background: #fafbfa; border-bottom: 1px solid var(--line); white-space: nowrap; padding: .65rem .8rem; }
.table > tbody td, .table > tbody th { padding: .7rem .8rem; border-color: var(--line-2); vertical-align: middle; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: #f8faf9; }
.cell-main { font-weight: 600; }
.cell-sub { font-size: .78rem; color: var(--ink-500); }
.filter-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .85rem 1.1rem; border-bottom: 1px solid var(--line-2); }
.filter-bar .form-control, .filter-bar .form-select { min-height: 38px; padding-top: .4rem; padding-bottom: .4rem; }
.filter-bar .search { flex: 1 1 220px; max-width: 360px; }
.filter-bar .form-select.w-auto { min-width: 150px; padding-right: 2.2rem; }

/* ---------- Badges ---------- */
.badge-soft { display: inline-flex; align-items: center; gap: .3rem; font-size: .74rem; font-weight: 600; padding: .25rem .55rem; border-radius: 999px; }
.badge-soft.ok      { background: #e3f4ea; color: #146c43; }
.badge-soft.muted   { background: var(--line-2); color: var(--ink-500); }
.badge-soft.warn    { background: var(--accent-100); color: #8a5a07; }
.badge-soft.danger  { background: #fbe7e5; color: #a5281b; }
.badge-soft.brand   { background: var(--brand-50); color: var(--brand-800); }
.badge-soft.info    { background: #e6eef8; color: #1f4f86; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--ink-500); }
.empty-state .empty-icon { font-size: 2.2rem; color: var(--ink-400); margin-bottom: .5rem; }
.empty-state h2, .empty-state h3 { font-size: 1.1rem; color: var(--ink-900); }

/* ---------- Alerts ---------- */
.alert { border-radius: var(--radius-sm); border-width: 1px; font-size: .92rem; }
.alert-success { background: #ecf7f0; border-color: #cfe9d9; color: #145c38; }
.alert-danger  { background: #fdf0ee; border-color: #f4d3ce; color: #8f2418; }
.alert-warning { background: #fdf6e8; border-color: #f3e2bd; color: #7a5208; }
.alert-info    { background: #eef4fb; border-color: #d5e3f3; color: #1d4a7c; }

/* ---------- Permission matrix ---------- */
.perm-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .75rem; }
.perm-matrix-wrap { border: 1px solid var(--line); border-radius: var(--radius-sm); }
.perm-matrix th, .perm-matrix td { font-size: .85rem; }
.perm-matrix thead th { font-size: .66rem; text-align: center; vertical-align: bottom; white-space: normal; min-width: 58px; padding-left: .3rem; padding-right: .3rem; }
.perm-matrix .perm-module-col { min-width: 175px; text-align: left; font-weight: 600; position: sticky; left: 0; background: #fff; z-index: 1; }
.perm-matrix thead .perm-module-col { background: #fafbfa; }
.perm-box { position: relative; display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; padding: .2rem; }
.perm-box .form-check-input { width: 1.2rem; height: 1.2rem; margin: 0; cursor: pointer; }
.perm-box .form-check-input:disabled { cursor: not-allowed; }
.perm-box.with-label { display: flex; font-size: .82rem; padding: .15rem 0; }
.perm-lock { font-size: .6rem; color: var(--warn); position: absolute; top: -2px; right: -6px; }
.perm-box.with-label .perm-lock { position: static; }
.perm-na { color: var(--line); }
.perm-special { min-width: 240px; }
.perm-box.with-label span { white-space: normal; line-height: 1.3; }
.perm-matrix thead th:last-child { text-align: left; }
.perm-row-toggle { font-size: .72rem; text-decoration: none; }

/* ---------- Auth pages ---------- */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--canvas); }
.auth-aside { background: radial-gradient(1200px 600px at 10% 10%, #145e4d 0%, var(--side-bg) 55%, #0a1714 100%);
  color: #d5e4df; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-aside::after { content: ""; position: absolute; right: -120px; bottom: -120px; width: 380px; height: 380px; border-radius: 50%;
  border: 60px solid rgba(229, 165, 49, .10); }
.auth-aside h1 { color: #fff; font-size: 2rem; max-width: 420px; line-height: 1.2; }
.auth-aside p { color: #a8bfb7; max-width: 420px; }
.auth-feature { display: flex; gap: .7rem; align-items: center; margin-top: .8rem; color: #cfe0da; font-size: .92rem; }
.auth-feature i { color: var(--accent); }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 2rem 1.25rem; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .brand-mark { width: 46px; height: 46px; font-size: 1.35rem; margin-bottom: 1rem; }
.auth-card h2 { font-size: 1.5rem; margin-bottom: .25rem; }
@media (max-width: 860px) { .auth-page { grid-template-columns: 1fr; } .auth-aside { display: none; } }

/* ---------- Install checklist ---------- */
.check-list { list-style: none; padding: 0; margin: 0; }
.check-list li { display: flex; gap: .75rem; padding: .7rem 0; border-bottom: 1px solid var(--line-2); align-items: flex-start; }
.check-list li:last-child { border-bottom: 0; }
.check-list .ci { font-size: 1.1rem; line-height: 1.3; }
.check-list .ci.ok { color: var(--ok); } .check-list .ci.bad { color: var(--danger); } .check-list .ci.warn { color: var(--warn); }
.check-list .ct { font-weight: 600; }
.check-list .cd { font-size: .84rem; color: var(--ink-500); }

/* ---------- Misc ---------- */
.kv { display: grid; grid-template-columns: 140px 1fr; gap: .4rem 1rem; font-size: .9rem; }
.kv dt { color: var(--ink-500); font-weight: 500; }
.kv dd { margin: 0; }
.json-box { background: #f7f9f8; border: 1px solid var(--line-2); border-radius: 8px; padding: .5rem .7rem; font-size: .76rem;
  white-space: pre-wrap; word-break: break-word; max-height: 220px; overflow: auto; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.section-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-500); font-weight: 600; margin: 0 0 .75rem; }
.logo-preview { max-height: 64px; max-width: 200px; border: 1px solid var(--line); border-radius: 8px; padding: 4px; background: #fff; }
.modal-content { border-radius: var(--radius-lg); border: 0; box-shadow: 0 20px 50px rgba(16,32,28,.18); }
.modal-header { border-bottom-color: var(--line-2); }
.modal-footer { border-top-color: var(--line-2); }
.dropdown-menu { border-color: var(--line); border-radius: var(--radius-sm); font-size: .9rem; }
.flash { box-shadow: var(--shadow-sm); }

/* Touch-friendly sizes on tablets */
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .form-control, .form-select { min-height: 46px; }
  .nav-item { min-height: 46px; }
}

/* ---------- Print ---------- */
@media print {
  .app-sidebar, .app-topbar, .btn, .filter-bar, .pagination, .no-print, .alert { display: none !important; }
  .app-content { padding: 0; max-width: none; }
  body.app-body { background: #fff; }
  .panel { border: 0; box-shadow: none; }
}

/* ---------- Phase 2: catalogue ---------- */
.thumb { width: 38px; height: 38px; border-radius: 8px; object-fit: cover; border: 1px solid var(--line); background: #fff; flex-shrink: 0; }
.thumb-lg { width: 72px; height: 72px; }
.thumb-empty { display: inline-grid; place-items: center; color: var(--ink-400); background: var(--line-2); }
.icon-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.icon-picker input { position: absolute; opacity: 0; pointer-events: none; }
.icon-picker span { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-size: 1.05rem; color: var(--ink-700); background: #fff; }
.icon-picker input:checked + span { border-color: var(--brand-700); background: var(--brand-50); color: var(--brand-800); box-shadow: 0 0 0 2px rgba(13,107,87,.15); }
.icon-picker input:focus-visible + span { outline: 2px solid var(--brand-600); }
a.cat-card:hover { border-color: var(--brand-600); box-shadow: var(--shadow); }
.variant-generator { background: var(--brand-50); border: 1px dashed var(--brand-600); border-radius: var(--radius-sm); padding: .9rem 1rem; margin-bottom: 1rem; }
.variant-table .form-control-sm, .variant-table .form-select-sm { min-height: 34px; }
.variant-table td { padding: .35rem .3rem; }
.min-w-0 { min-width: 0; }
.qty-pos { color: var(--ok); font-weight: 600; }
.qty-neg { color: var(--danger); font-weight: 600; }
.search-results { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm);
                  box-shadow: var(--shadow); max-height: 320px; overflow: auto; margin-top: 4px; }
.search-results button { display: flex; width: 100%; text-align: left; gap: .75rem; align-items: center; justify-content: space-between; border: 0; background: none; padding: .55rem .8rem; border-bottom: 1px solid var(--line-2); }
.search-results button:hover, .search-results button.active { background: var(--brand-50); }
