:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-2: #f7f8fa;
  --line: #d9dde3;
  --text: #17191d;
  --muted: #6b7280;
  --soft: #3f4652;
  --brand: #111827;
  --brand-2: #4b5563;
  --brand-3: #111827;
  --good: #0f766e;
  --warn: #b42318;
  --shadow: 0 18px 45px rgba(15, 23, 42, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button, input, select, textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
  background: #ffffff;
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.login-card img {
  width: 160px;
  height: 88px;
  object-fit: contain;
  justify-self: center;
}

.login-card h1 {
  margin: 4px 0 0;
  font-size: 32px;
  line-height: 1;
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: var(--warn);
  font-size: 13px;
  font-weight: 800;
}

.app-shell {
  display: grid;
  grid-template-columns: 286px 1fr;
  min-height: 100vh;
  transition: grid-template-columns .18s ease;
}

body.sidebar-collapsed .app-shell {
  grid-template-columns: 84px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px;
  background: #ffffff;
  border-right: 1px solid var(--line);
  overflow-y: auto;
  z-index: 5;
  transition: width .18s ease, padding .18s ease;
}

.brand {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 12px;
  align-items: center;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

body.sidebar-collapsed .sidebar {
  padding: 14px 12px;
  overflow-x: hidden;
}

body.sidebar-collapsed .brand {
  grid-template-columns: 1fr;
  justify-items: center;
  gap: 0;
}

body.sidebar-collapsed .brand img {
  width: 54px;
  height: 44px;
}

body.sidebar-collapsed .brand div,
body.sidebar-collapsed .nav-button span,
body.sidebar-collapsed .nav-button i:last-child,
body.sidebar-collapsed .shift-card {
  display: none;
}

.brand img {
  width: 86px;
  height: 58px;
  object-fit: contain;
}

.brand strong {
  display: block;
  font-size: 18px;
  line-height: 1;
  color: var(--text);
}

.sidebar .brand span,
.sidebar .eyebrow,
.sidebar .small {
  color: var(--muted);
}

.brand span, .eyebrow, .small, label, .muted {
  color: var(--muted);
}

#nav {
  display: grid;
  gap: 7px;
  padding: 20px 0;
}

.nav-button {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 11px 12px;
  border-radius: 8px;
  color: var(--soft);
  background: transparent;
  text-align: left;
}

body.sidebar-collapsed .nav-button {
  grid-template-columns: 1fr;
  justify-items: center;
  padding: 12px 0;
}

.nav-button:hover, .nav-button.active {
  color: var(--text);
  background: #f3f4f6;
}

.nav-button.active {
  box-shadow: inset 3px 0 0 var(--brand);
}

.shift-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #ffffff;
  color: var(--text);
}

.main {
  min-width: 0;
  padding: 22px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.topbar h1 {
  margin: 3px 0 0;
  font-size: clamp(26px, 4vw, 44px);
  line-height: 1;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 12px;
  font-weight: 800;
}

.top-actions, .row, .toolbar, .dialog-actions, .split-actions, .action-cluster {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.menu-toggle {
  display: inline-flex;
  flex: 0 0 auto;
}

.top-actions {
  justify-content: flex-end;
  max-width: 760px;
}

.action-cluster {
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.action-cluster .ghost,
.action-cluster .primary {
  min-height: 36px;
}

.session-pill,
.clock-pill,
.sync-pill {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--soft);
  font-size: 13px;
  font-weight: 800;
}

.clock-pill {
  min-width: 196px;
  justify-content: center;
  color: var(--text);
}

.sync-pill {
  color: #166534;
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.sync-pill.offline {
  color: #991b1b;
  background: #fef2f2;
  border-color: #fecaca;
}

.primary, .danger, .ghost, .icon-button, .chip, .tab-button {
  min-height: 40px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  color: var(--text);
}

.primary {
  background: var(--brand);
  color: #ffffff;
  box-shadow: 0 14px 30px rgba(17, 24, 39, .18);
}

.danger {
  background: #991b1b;
  color: #ffffff;
}

.ghost, .icon-button, .tab-button {
  background: #ffffff;
  border: 1px solid var(--line);
}

.icon-button {
  width: 40px;
  padding: 0;
}

.chip {
  min-height: 30px;
  padding: 0 10px;
  background: #f3f4f6;
  color: var(--soft);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 800;
}

.grid {
  display: grid;
  gap: 14px;
}

.kpi-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.two-col {
  grid-template-columns: minmax(0, 1.3fr) minmax(360px, .7fr);
}

.three-col {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.panel, .metric, .table-wrap, .form-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel, .form-panel {
  padding: 16px;
}

.metric {
  padding: 16px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 28px;
  line-height: 1;
}

.metric small {
  color: var(--soft);
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.section-title h2, .section-title h3 {
  margin: 0;
  font-size: 19px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.field-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.info-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.info-strip strong,
.info-strip span {
  display: block;
}

.info-strip span {
  color: var(--muted);
  font-size: 13px;
}

.field {
  display: grid;
  gap: 6px;
}

label {
  font-size: 12px;
  font-weight: 800;
}

input, select, textarea {
  width: 100%;
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
  padding: 10px 11px;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 78px;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(17, 24, 39, .12);
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.inventory-table {
  min-width: 1320px;
}

.inventory-table input,
.inventory-table select {
  min-height: 36px;
  padding: 7px 8px;
}

.inventory-table td:first-child {
  min-width: 230px;
}

.inventory-table td:first-child input {
  margin-bottom: 6px;
}

th, td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

tr:hover td {
  background: #f9fafb;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  max-height: 570px;
  overflow: auto;
  padding-right: 4px;
}

.product-tile {
  min-height: 118px;
  padding: 13px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  text-align: left;
  display: grid;
  align-content: space-between;
}

.product-tile strong {
  line-height: 1.15;
}

.product-tile span {
  color: var(--muted);
  font-size: 12px;
}

.brand-preview {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.brand-preview img {
  width: 96px;
  height: 70px;
  object-fit: contain;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid var(--line);
}

.logo-placeholder {
  width: 96px;
  min-height: 70px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.brand-preview strong,
.brand-preview span {
  display: block;
}

.brand-preview strong {
  font-size: 20px;
}

.brand-preview span {
  color: var(--muted);
  margin-top: 4px;
}

.cart {
  position: sticky;
  top: 20px;
}

.cart-line {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.qty {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.qty button {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--line);
}

.totals {
  display: grid;
  gap: 9px;
  margin-top: 12px;
}

.payment-box {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.warning {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-radius: 8px;
  background: #fff1f2;
  color: var(--warn);
  font-weight: 800;
  font-size: 13px;
}

.total-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.grand {
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 22px;
  font-weight: 900;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  overflow-x: auto;
}

.tab-button.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #ffffff;
}

.bar-chart {
  display: grid;
  gap: 10px;
}

.bar {
  display: grid;
  grid-template-columns: 130px 1fr 92px;
  align-items: center;
  gap: 10px;
}

.bar-track {
  height: 13px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand-2), var(--brand-3));
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 9px;
  border: 1px solid var(--line);
  color: var(--soft);
  font-size: 12px;
  font-weight: 800;
}

.low {
  color: var(--warn);
}

.receipt-dialog {
  width: min(620px, 96vw);
  max-height: 92vh;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: var(--panel);
  color: var(--text);
  overflow: auto;
}

.receipt-dialog::backdrop {
  background: rgba(0, 0, 0, .72);
}

.receipt {
  width: min(100%, 440px);
  margin: 0;
  padding: 28px;
  color: #111827;
  background: #ffffff;
  font-size: 15px;
  line-height: 1.32;
}

.receipt h2, .receipt p {
  margin: 0;
}

.receipt h2 {
  font-size: 24px;
  line-height: 1.15;
}

.receipt-header,
.receipt-note,
.receipt-meta,
.receipt-summary {
  text-align: center;
}

.receipt-meta,
.receipt-summary {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.receipt-separator {
  border-top: 1px dashed #9ca3af;
  margin: 12px 0;
}

.receipt-code-box {
  color: #000;
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 1px;
  line-height: 1;
  text-align: center;
  word-break: break-word;
}

.receipt-label-box {
  color: #000;
  font-size: 30px;
  font-weight: 900;
  line-height: 1.05;
  margin-top: 8px;
  text-align: center;
  text-transform: uppercase;
  word-break: break-word;
}

.order-draft {
  display: grid;
  gap: 8px;
}

.order-draft-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.order-draft-line span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.order-channel {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  min-height: 32px;
  margin: 0 0 10px;
  padding: 0 12px;
  border-radius: 8px;
  background: #111827;
  color: #ffffff;
  font-weight: 900;
  letter-spacing: .4px;
}

.order-card {
  position: relative;
}

.kitchen-order-card {
  background: var(--order-bg, #f7f8fa);
  border-color: rgba(17, 24, 39, .18);
}

.kitchen-order-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 7px;
  border-radius: 8px 0 0 8px;
  background: var(--order-accent, #dbeafe);
}

.kitchen-order-card > * {
  position: relative;
}

.order-highlight-wrap {
  display: grid;
  gap: 8px;
  margin: 10px 0;
  padding: 12px;
  border: 2px solid #111827;
  border-radius: 8px;
  background: #fff7ed;
}

.order-code-box,
.order-label-box {
  color: #000;
  font-weight: 950;
  text-align: center;
  text-transform: uppercase;
  word-break: break-word;
}

.order-code-box {
  font-size: clamp(34px, 7vw, 62px);
  line-height: .95;
}

.order-label-box {
  font-size: clamp(30px, 6vw, 54px);
  line-height: 1;
}

.receipt .receipt-line {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
}

.receipt .receipt-line span {
  color: #4b5563;
}

.receipt .receipt-line strong {
  flex: 1 1 100%;
  max-width: 100%;
  text-align: right;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.receipt .receipt-line span + strong {
  flex-basis: 58%;
}

.report-chart {
  margin: 14px 0;
}

.pie-layout {
  display: grid;
  grid-template-columns: minmax(160px, 220px) 1fr;
  gap: 18px;
  align-items: center;
}

.pie-chart {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid var(--line);
}

.line-chart {
  width: 100%;
  height: 240px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.chart-caption {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
}

.receipt-total {
  margin-top: 8px;
  padding-top: 9px !important;
  border-top: 1px solid #111827;
  font-size: 18px;
}

.receipt-table {
  min-width: 0;
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  margin: 0 auto;
}

.receipt-table th,
.receipt-table td {
  padding: 7px 4px;
  border-bottom: 1px solid #e5e7eb;
  color: #111827;
  font-size: 14px;
  vertical-align: top;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.receipt-table th {
  color: #4b5563;
  font-size: 12px;
}

.receipt-table th:first-child,
.receipt-table td:first-child {
  width: 13%;
  text-align: left;
}

.receipt-table th:nth-child(2),
.receipt-table td:nth-child(2) {
  width: 58%;
  text-align: left;
}

.receipt-table th:last-child,
.receipt-table td:last-child {
  width: 29%;
  text-align: right;
}

.dialog-actions {
  justify-content: flex-end;
  padding: 12px;
}

.empty {
  padding: 30px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  margin-bottom: 14px;
}

.mobile-only {
  display: none;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  body.sidebar-collapsed .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    transform: translateX(-105%);
    transition: transform .2s ease;
    width: 286px;
  }

  body.sidebar-collapsed .sidebar {
    padding: 18px;
  }

  body.sidebar-collapsed .brand {
    grid-template-columns: 86px 1fr;
    justify-items: stretch;
    gap: 12px;
  }

  body.sidebar-collapsed .brand img {
    width: 86px;
    height: 58px;
  }

  body.sidebar-collapsed .brand div,
  body.sidebar-collapsed .nav-button span,
  body.sidebar-collapsed .nav-button i:last-child,
  body.sidebar-collapsed .shift-card {
    display: block;
  }

  body.sidebar-collapsed .nav-button {
    grid-template-columns: 22px 1fr auto;
    justify-items: stretch;
    padding: 11px 12px;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .menu-toggle {
    display: inline-flex;
  }

  .kpi-grid, .three-col, .two-col {
    grid-template-columns: 1fr;
  }

  .cart {
    position: static;
  }
}

@media (max-width: 680px) {
  .main {
    padding: 14px;
  }

  .topbar {
    align-items: flex-start;
  }

  .top-actions {
    display: grid;
    width: 100%;
    justify-content: stretch;
  }

  .topbar {
    display: grid;
    grid-template-columns: auto 1fr;
  }

  .top-actions {
    grid-column: 1 / -1;
  }

  .action-cluster {
    width: 100%;
  }

  .action-cluster button,
  .top-actions > button,
  .session-pill,
  .clock-pill {
    width: 100%;
  }

  .session-pill,
  .clock-pill {
    justify-content: center;
  }

  .field-grid, .field-grid.three, .search-row {
    grid-template-columns: 1fr;
  }

  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mobile-only {
    display: inline-flex;
  }
}

@media print {
  @page {
    size: 100mm 148mm;
    margin: 0;
  }

  html,
  body {
    width: 100mm;
    min-height: 148mm;
    min-height: 0;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
  }

  body.printing-receipt * {
    visibility: hidden !important;
    box-shadow: none !important;
  }

  body.printing-receipt #receiptContent,
  body.printing-receipt #receiptContent * {
    visibility: visible !important;
  }

  body.printing-receipt .receipt-dialog {
    position: static !important;
    display: block !important;
    width: 0 !important;
    height: 0 !important;
    max-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    overflow: visible !important;
    background: #ffffff !important;
  }

  body.printing-receipt #receiptContent {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100mm !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
  }

  body.printing-receipt .receipt {
    width: 82mm !important;
    margin: 0 !important;
    padding: 4mm 7mm 4mm 3mm !important;
    color: #000000 !important;
    background: #ffffff !important;
    font-size: 10pt !important;
    line-height: 1.25 !important;
    overflow: hidden !important;
  }

  body.printing-receipt .dialog-actions {
    display: none !important;
  }
}
