:root {
  font-family: "Segoe UI", Arial, sans-serif;
  color: #203449;
  background: #f4f7fb;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --navy: #102a43;
  --muted: #75859a;
  --line: #e6ebf1;
  --blue: #2768d8;
  --blue-soft: #edf4ff;
  --green: #16835d;
  --green-soft: #e9f7f1;
  --red: #c74949;
  --red-soft: #fff0ef;
  --amber: #a96b12;
  --amber-soft: #fff6e6;
  --shadow: 0 6px 24px rgba(27, 52, 79, .055);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input, select { font: inherit; }
button, .button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 250px; background: var(--navy); color: #fff; padding: 27px 17px 18px; display: flex; flex-direction: column; z-index: 5; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 36px; }
.brand-mark { width: 39px; height: 39px; border-radius: 12px; background: #48c9a0; color: #0f3547; display: grid; place-items: center; font-weight: 800; font-size: 14px; }
.brand strong, .brand small, .local-status strong, .local-status small { display: block; }
.brand strong { font-size: 16px; letter-spacing: -.4px; }
.brand small { margin-top: 3px; color: #a8bbce; font-size: 11px; }
.nav-caption { padding: 0 11px 12px; color: #8298ad; font-size: 10px; font-weight: 700; letter-spacing: 1px; }
.navigation, .sidebar-bottom { display: grid; gap: 5px; }
.sidebar-bottom { margin-top: auto; }
.nav-link { width: 100%; border: 0; background: transparent; color: #becbd7; border-radius: 9px; padding: 11px 12px; display: flex; align-items: center; gap: 12px; text-align: left; font-size: 13px; font-weight: 500; transition: .15s; }
.nav-link:hover { background: #ffffff10; color: #fff; }
.nav-link.active { background: #ffffff18; color: #fff; font-weight: 700; }
.nav-icon { width: 18px; text-align: center; font-size: 18px; line-height: 1; }
.local-status { display: flex; align-items: flex-start; gap: 10px; padding: 14px 10px 18px; border-top: 1px solid #ffffff1a; margin-bottom: 5px; }
.local-status strong { font-size: 11px; }
.local-status small { margin-top: 4px; color: #a8bbce; font-size: 10px; line-height: 1.5; }
.status-dot { width: 8px; height: 8px; background: #48c9a0; border-radius: 50%; display: inline-block; flex: none; margin-top: 3px; }
.backup-link { font-size: 12px; padding: 9px 10px; }
.import-label { cursor: pointer; }
.main-content { margin-left: 250px; max-width: 1600px; min-height: 100vh; padding: 0 36px 20px; }
.topbar { min-height: 108px; display: flex; align-items: center; gap: 18px; border-bottom: 1px solid var(--line); margin-bottom: 26px; }
.eyebrow { font-size: 10px; color: var(--muted); font-weight: 700; letter-spacing: .9px; text-transform: uppercase; }
.topbar h1 { font-size: 25px; color: var(--navy); letter-spacing: -.7px; margin: 6px 0 0; }
.topbar-actions { display: flex; align-items: center; gap: 18px; margin-left: auto; }
.sidebar-toggle { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--navy); font-size: 19px; }
.sidebar-toggle:hover { background: var(--blue-soft); border-color: #c8d9f3; }
.offline-badge { display: flex; align-items: center; gap: 7px; color: #60758a; font-size: 11px; }
.offline-badge .status-dot { width: 7px; height: 7px; }
.button { border: 0; border-radius: 8px; padding: 10px 14px; font-weight: 700; font-size: 12px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; transition: background .15s, transform .15s; }
.button:active { transform: translateY(1px); }
.button-primary { background: var(--blue); color: #fff; }
.button-primary:hover { background: #1d57bb; }
.button-primary:disabled { opacity: .5; cursor: not-allowed; }
.button-secondary { background: #eef2f6; color: #41546a; }
.button-secondary:hover { background: #e2e8ef; }
.button-small { padding: 7px 10px; font-size: 11px; }
.app-footer { padding: 32px 0 4px; color: #8b9aac; font-size: 10px; }
.app-footer span { padding: 0 5px; color: #bcc7d1; }
.page-intro { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 19px; }
.page-intro h2 { margin: 0; color: var(--navy); font-size: 16px; }
.page-intro p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin-bottom: 20px; }
.stat-card, .panel, .summary-card { background: #fff; border: 1px solid #edf0f4; border-radius: 11px; box-shadow: var(--shadow); }
.stat-card { padding: 16px 17px; }
.stat-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 11px; }
.stat-icon { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 9px; background: var(--blue-soft); color: var(--blue); font-size: 16px; }
.stat-value { margin-top: 13px; color: var(--navy); font-size: 20px; font-weight: 800; letter-spacing: -.7px; }
.stat-note { margin-top: 5px; color: #91a0b0; font-size: 10px; }
.positive .stat-icon { background: var(--green-soft); color: var(--green); }
.negative .stat-icon { background: var(--red-soft); color: var(--red); }
.warning .stat-icon { background: var(--amber-soft); color: var(--amber); }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(265px, .85fr); gap: 16px; }
.dashboard-grid > * { min-width: 0; }
.panel { padding: 18px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 15px; gap: 12px; }
.panel-heading h3, .form-card h3 { margin: 0; color: var(--navy); font-size: 13px; }
.panel-heading p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.text-link { color: var(--blue); font-size: 11px; font-weight: 700; background: none; border: 0; padding: 5px; }
.table-wrap { overflow: auto; }
table { border-collapse: collapse; width: 100%; white-space: nowrap; }
th { text-align: left; color: #8795a5; font-size: 9px; text-transform: uppercase; letter-spacing: .55px; font-weight: 700; padding: 10px 9px; border-bottom: 1px solid var(--line); }
td { padding: 11px 9px; border-bottom: 1px solid #f0f3f6; color: #40546a; font-size: 11px; }
tbody tr:last-child td { border-bottom: 0; }
.table-primary { color: var(--navy); font-weight: 700; }
.table-secondary { display: block; color: #9aa7b5; font-size: 9px; margin-top: 3px; }
.text-right { text-align: right; }
.empty-state { text-align: center; padding: 28px 12px; color: #8a99a9; font-size: 11px; white-space: normal; }
.empty-state strong { display: block; color: #52667c; margin-bottom: 5px; font-size: 12px; }
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.quick-action { border: 1px solid var(--line); background: #fff; text-align: left; border-radius: 9px; padding: 12px; color: #384f65; font-size: 11px; font-weight: 700; }
.quick-action:hover { border-color: #b9cdef; background: #f9fbff; }
.quick-action span { display: block; color: var(--blue); font-size: 19px; margin-bottom: 7px; }
.stock-alert-list { display: grid; gap: 10px; }
.stock-alert { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 9px; border-bottom: 1px solid #f0f3f6; }
.stock-alert:last-child { padding-bottom: 0; border: 0; }
.stock-alert strong { display: block; color: #34495e; font-size: 11px; }
.stock-alert small { display: block; color: #98a5b3; font-size: 9px; margin-top: 3px; }
.badge { display: inline-flex; align-items: center; white-space: nowrap; border-radius: 20px; padding: 4px 8px; font-size: 9px; font-weight: 700; }
.badge-low { background: var(--amber-soft); color: var(--amber); }
.badge-good { background: var(--green-soft); color: var(--green); }
.badge-sale { background: var(--blue-soft); color: var(--blue); }
.badge-expense { background: var(--red-soft); color: var(--red); }
.badge-neutral { background: #f0f3f6; color: #687b8f; }
.toolbar { display: flex; gap: 9px; align-items: center; margin-bottom: 14px; }
.category-filter { margin-bottom: 12px; }
.search-input, .select-input, .field input, .field select { height: 38px; border: 1px solid #dfe6ed; border-radius: 7px; background: #fff; color: #34495e; padding: 0 11px; outline: none; font-size: 11px; width: 100%; }
.search-input:focus, .select-input:focus, .field input:focus, .field select:focus { border-color: #7ba7eb; box-shadow: 0 0 0 3px #2768d812; }
.search-input { max-width: 290px; }
.select-input { width: auto; min-width: 125px; }
.field { display: grid; gap: 6px; color: #617389; font-size: 10px; font-weight: 700; }
.field input, .field select { font-weight: 400; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.form-card { padding: 18px; }
.form-card h3 { margin-bottom: 15px; }
.form-stack { display: grid; gap: 12px; }
.form-section { display: grid; gap: 11px; padding: 14px; border: 1px solid var(--line); border-radius: 9px; background: #fbfcfe; }
.form-section h4 { margin: 0; color: var(--navy); font-size: 11px; }
.form-section > p:not(.help-text) { margin: -5px 0 0; color: var(--muted); font-size: 10px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 3px; }
.help-text { color: #8d9bab; font-size: 9px; line-height: 1.5; margin: 0; }
.catalog-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.catalog-form { min-width: 0; }
.catalog-item { width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 13px; text-align: left; min-height: 103px; }
.catalog-item:hover { border-color: #9bb9e7; box-shadow: 0 4px 12px #2768d810; }
.catalog-item:disabled { opacity: .55; cursor: not-allowed; }
.catalog-item strong { display: block; color: var(--navy); font-size: 11px; line-height: 1.4; }
.catalog-item small { display: block; color: #8b9aaa; font-size: 9px; margin-top: 5px; }
.catalog-item span { display: block; color: var(--blue); font-weight: 800; font-size: 12px; margin-top: 10px; }
.cashier-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(310px, .8fr); gap: 16px; align-items: start; }
.mobile-cart-shortcut { display: none; }
.cart-panel { position: sticky; top: 15px; }
.service-entry { gap: 9px; padding: 12px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 9px; background: #fbfcfe; }
.service-entry > strong { color: var(--navy); font-size: 11px; }
.service-entry .button { width: 100%; }
.cart-list { display: grid; gap: 0; max-height: 340px; overflow: auto; }
.cart-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 11px 0; border-bottom: 1px solid #f0f3f6; }
.cart-row strong { display: block; color: #34495e; font-size: 10px; }
.cart-row small { display: block; color: #8d9bab; font-size: 9px; margin-top: 4px; }
.cart-controls { display: flex; align-items: center; gap: 7px; }
.qty-value { min-width: 15px; text-align: center; font-size: 10px; font-weight: 700; }
.remove-button { border: 0; background: none; color: #b27676; font-size: 16px; padding: 3px; }
.cart-empty { text-align: center; padding: 24px 12px; color: #93a0ae; font-size: 10px; }
.cart-empty span { display: block; font-size: 24px; margin-bottom: 7px; }
.cart-summary { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.summary-line { display: flex; justify-content: space-between; color: #77879a; font-size: 10px; margin: 8px 0; }
.summary-line.total { font-size: 13px; color: var(--navy); font-weight: 800; padding-top: 10px; border-top: 1px dashed var(--line); }
.checkout-button { width: 100%; margin-top: 8px; padding: 12px; }
.finance-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 16px 0; }
.summary-card { padding: 17px; }
.summary-card span { color: #8190a0; font-size: 10px; }
.summary-card strong { display: block; color: var(--navy); font-size: 18px; margin-top: 8px; }
.summary-card.income strong, .money-income { color: var(--green); }
.summary-card.expense strong, .money-expense { color: var(--red); }
.summary-card.profit strong { color: var(--blue); }
.report-filters { display: flex; align-items: end; gap: 10px; flex-wrap: wrap; }
.report-filters .field { min-width: 150px; }
.filter-panel { margin-bottom: 15px; }
.finance-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, .8fr); gap: 16px; align-items: start; }
.report-note { margin-top: 12px; }
.inventory-tools { display: grid; grid-template-columns: minmax(0, 1fr); gap: 13px; margin-bottom: 16px; align-items: start; }
.inventory-list { margin-top: 16px; }
.flash-stack { display: grid; gap: 8px; margin: -10px 0 18px; }
.flash { border-radius: 8px; padding: 11px 14px; font-size: 11px; }
.flash.success { background: var(--green-soft); color: #126a4c; }
.flash.error { background: var(--red-soft); color: #a33a3a; }
.sidebar-backdrop { display: none; }
.receipt-actions { display: flex; justify-content: center; gap: 9px; margin-bottom: 16px; }
.thermal-receipt { width: min(100%, 340px); margin: 0 auto; padding: 22px 18px; background: #fff; color: #111; border: 1px solid var(--line); box-shadow: var(--shadow); font-family: "Courier New", monospace; font-size: 11px; }
.receipt-header { text-align: center; }
.receipt-header h2 { margin: 0; font-size: 19px; letter-spacing: 1px; }
.receipt-header p { margin: 4px 0 0; font-size: 10px; }
.receipt-divider { border-top: 1px dashed #555; margin: 12px 0; }
.receipt-meta { display: grid; gap: 4px; margin: 0; }
.receipt-meta div, .receipt-item > div, .receipt-total { display: flex; justify-content: space-between; gap: 8px; }
.receipt-meta dt, .receipt-meta dd { margin: 0; }
.receipt-items { display: grid; gap: 9px; }
.receipt-item strong { display: block; font-size: 11px; font-weight: 400; }
.receipt-item > div { margin-top: 3px; font-size: 10px; }
.receipt-total { align-items: baseline; font-weight: 700; }
.receipt-total strong { font-size: 15px; }
.receipt-footer { margin-top: 15px; text-align: center; font-size: 9px; }
.receipt-footer p { margin: 4px 0; }
@media print {
  @page { size: 58mm auto; margin: 3mm; }
  body { min-width: 0; background: #fff; }
  .sidebar, .topbar, .app-footer, .flash-stack, .receipt-actions { display: none !important; }
  .main-content { max-width: none; min-height: 0; margin: 0; padding: 0; }
  .thermal-receipt { width: 52mm; max-width: 52mm; margin: 0; padding: 0; border: 0; box-shadow: none; font-size: 9pt; }
  .receipt-header h2 { font-size: 14pt; }
  .receipt-header p, .receipt-item strong { font-size: 9pt; }
  .receipt-meta, .receipt-item > div { font-size: 8pt; }
  .receipt-total strong { font-size: 11pt; }
  .receipt-footer { font-size: 7pt; }
}

@media (max-width: 1150px) {
  .main-content { padding: 0 25px 20px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: minmax(0, 1.3fr) minmax(240px, .8fr); }
  .catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 850px) {
  .sidebar { width: 205px; padding-left: 12px; padding-right: 12px; }
  .main-content { margin-left: 205px; padding: 0 18px 18px; }
  .dashboard-grid, .cashier-layout, .finance-layout { grid-template-columns: minmax(0, 1fr); }
  .cart-panel { position: static; }
  .cart-list { max-height: 260px; }
  .inventory-tools { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(280px, 85vw); padding: 16px 13px; overflow-y: auto; transform: translateX(-105%); transition: transform .2s ease; z-index: 20; }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; width: 100%; height: 100%; border: 0; background: #102a4370; z-index: 19; }
  .brand { padding: 0 6px 13px; }
  .nav-caption { padding-top: 12px; }
  .sidebar-bottom { display: grid; margin-top: auto; }
  .navigation { grid-template-columns: 1fr; gap: 5px; }
  .nav-link { justify-content: flex-start; flex-direction: row; gap: 10px; padding: 10px; font-size: 11px; }
  .nav-icon { font-size: 16px; }
  .main-content { margin: 0; padding: 0 13px 15px; }
  .topbar { min-height: 76px; margin-bottom: 18px; }
  .topbar h1 { font-size: 20px; }
  .topbar-actions { gap: 8px; }
  .offline-badge { display: none; }
  .page-intro { align-items: flex-start; }
  .page-intro .button { white-space: nowrap; }
  .cashier-intro { flex-direction: column; gap: 7px; }
  .stats-grid { gap: 8px; }
  .stat-card { padding: 12px; }
  .stat-value { font-size: 16px; }
  .stat-top { font-size: 9px; }
  .finance-cards { gap: 8px; }
  .summary-card { padding: 12px 9px; }
  .summary-card strong { font-size: 13px; }
  .summary-card span { font-size: 9px; }
  .inventory-tools { grid-template-columns: 1fr; }
  .catalog-grid { gap: 8px; }
  .cashier-catalog-panel { min-width: 0; }
  .cashier-catalog-panel .catalog-grid { max-height: 38dvh; min-height: 180px; overflow-y: auto; overscroll-behavior: contain; padding: 2px 3px 2px 0; }
  .mobile-cart-shortcut { position: fixed; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); left: 12px; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 52px; padding: 10px 14px; border-radius: 12px; background: var(--navy); color: #fff; box-shadow: 0 6px 22px #102a4350; font-size: 11px; }
  .mobile-cart-shortcut strong { margin-left: auto; color: #fff; font-size: 12px; }
  .mobile-cart-shortcut.is-hidden { display: none; }
  .toolbar { flex-wrap: wrap; }
  .search-input { max-width: none; flex: 1; min-width: 140px; }
  .select-input { flex: 1; }
  .panel { padding: 13px; }
  .panel-heading { align-items: flex-start; }
  .report-filters { align-items: stretch; }
  .report-filters .field { flex: 1; min-width: 120px; }
  .form-grid { grid-template-columns: 1fr; }
  .app-footer { padding-top: 22px; }
  .dashboard-sales-table { table-layout: fixed; }
  .dashboard-sales-table th, .dashboard-sales-table td { padding-left: 5px; padding-right: 5px; }
  .dashboard-sales-table th:nth-child(3), .dashboard-sales-table td:nth-child(3) { display: none; }
  .dashboard-sales-table th:first-child, .dashboard-sales-table td:first-child { overflow: hidden; text-overflow: ellipsis; }
}

@media (min-width: 621px) {
  body.sidebar-closed .sidebar { display: none; }
  body.sidebar-closed .main-content { margin-left: 0; }
}
