:root {
  --bg: #f4efe8;
  --bg-dark: #1a120b;
  --card: #ffffff;
  --card-soft: #fff8f1;
  --primary: #c67c4e;
  --primary-dark: #a35c32;
  --primary-soft: #f3e0d1;
  --accent: #2f5d50;
  --accent-soft: #e4f0eb;
  --text: #1f1410;
  --muted: #7a6a5f;
  --border: #e8d9cb;
  --success: #2f9e6b;
  --danger: #d64545;
  --warning: #e0a100;
  --shadow: 0 10px 30px rgba(26, 18, 11, 0.08);
  --radius: 18px;
  --sidebar: 260px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "DM Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.boot {
  min-height: 100vh;
  display: grid;
  place-items: center;
  color: var(--muted);
}
.boot-logo { font-size: 42px; margin-bottom: 8px; }

/* Login */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top right, rgba(198, 124, 78, 0.28), transparent 35%),
    linear-gradient(145deg, #1a120b 0%, #3d2415 48%, #c67c4e 120%);
}
.login-card {
  width: min(420px, 100%);
  background: var(--card);
  border-radius: 28px;
  padding: 32px;
  box-shadow: 0 24px 60px rgba(0,0,0,.25);
}
.login-brand {
  text-align: center;
  margin-bottom: 24px;
}
.login-brand .logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 12px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  font-size: 34px;
  background: var(--primary-soft);
}
.login-brand h1 {
  margin: 0;
  font-size: 32px;
  letter-spacing: -0.04em;
}
.login-brand p {
  margin: 6px 0 0;
  color: var(--muted);
}
.field { margin-bottom: 14px; }
.field label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 14px;
}
.field input, .field select, .field textarea {
  width: 100%;
  height: 48px;
  border: 1px solid var(--border);
  background: var(--card-soft);
  border-radius: 12px;
  padding: 0 14px;
  outline: none;
}
.field textarea {
  height: auto;
  min-height: 90px;
  padding: 12px 14px;
  resize: vertical;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(198,124,78,.15);
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 46px;
  padding: 0 18px;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  transition: .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); color: #fff; width: 100%; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-soft { background: var(--primary-soft); color: var(--primary-dark); }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { height: 36px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.alert {
  background: #fdecec;
  color: var(--danger);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 14px;
}
.quick-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }

/* Layout */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--bg-dark);
  color: #f8f1ea;
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 22px;
}
.sidebar-brand .mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.1);
  font-size: 20px;
}
.sidebar-brand strong { display: block; font-size: 18px; }
.sidebar-brand span { color: rgba(248,241,234,.65); font-size: 12px; }
.nav { display: grid; gap: 6px; }
.nav button {
  text-align: left;
  border: none;
  background: transparent;
  color: rgba(248,241,234,.78);
  padding: 12px 14px;
  border-radius: 12px;
  font-weight: 600;
}
.nav button.active,
.nav button:hover {
  background: rgba(198,124,78,.22);
  color: #fff;
}
.sidebar-footer {
  margin-top: auto;
  padding: 14px 10px 0;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-footer .user-name { font-weight: 700; }
.sidebar-footer .user-role { color: rgba(248,241,234,.6); font-size: 13px; margin: 2px 0 12px; }

.content {
  padding: 28px;
}
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.page-head h2 {
  margin: 0;
  font-size: 30px;
  letter-spacing: -0.03em;
}
.page-head p {
  margin: 4px 0 0;
  color: var(--muted);
}

.grid-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.stat-card.dark {
  background: var(--bg-dark);
  color: #fff;
}
.stat-card .label { color: var(--muted); font-weight: 600; font-size: 13px; }
.stat-card.dark .label { color: rgba(255,255,255,.7); }
.stat-card .value {
  margin-top: 10px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.stat-revenue-stack {
  margin-top: 10px;
  display: grid;
  gap: 6px;
}
.stat-revenue-line {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
}
.stat-revenue-stack.is-compact .stat-revenue-line {
  font-size: 18px;
}
.stat-revenue-line.light { color: #fff; }
.stat-revenue-line.muted-line {
  font-size: 18px;
  color: rgba(255,255,255,.55);
  font-weight: 600;
}
.stat-card:not(.dark) .stat-revenue-line.muted-line {
  color: var(--muted);
}
.stat-card .meta { margin-top: 8px; color: var(--muted); font-size: 13px; }
.stat-card.dark .meta { color: rgba(255,255,255,.65); }

.panel-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 16px;
}
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card h3 {
  margin: 0 0 14px;
  font-size: 18px;
}
.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: none; }
.muted { color: var(--muted); }
.rank {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
  font-size: 12px;
  flex: 0 0 auto;
}
.row-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.row-left strong { display: block; }
.row-left span { color: var(--muted); font-size: 13px; }

.card-chart {
  position: relative;
  overflow: hidden;
}
.card-chart::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}
.card-chart-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.card-chart-head h3 { margin: 0; }
.card-chart-head p {
  margin: 4px 0 0;
  font-size: 13px;
}

.pie-chart {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 24px;
  align-items: center;
}
.pie-visual {
  position: relative;
  width: min(100%, 260px);
  margin: 0 auto;
  aspect-ratio: 1;
}
.pie-svg {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 14px 28px rgba(26, 18, 11, 0.1));
}
.pie-track {
  fill: none;
  stroke: #f1e7dc;
  stroke-width: 26;
}
.pie-slice {
  fill: none;
  stroke-linecap: round;
  transform-origin: 100px 100px;
  animation: pieSliceIn 0.9s cubic-bezier(.22, 1, .36, 1) both;
  animation-delay: var(--slice-delay, 0ms);
}
.pie-center {
  position: absolute;
  inset: 28%;
  border-radius: 50%;
  background: var(--card);
  box-shadow:
    inset 0 0 0 1px rgba(232, 217, 203, 0.9),
    0 10px 24px rgba(26, 18, 11, 0.06);
  display: grid;
  place-content: center;
  text-align: center;
  gap: 2px;
  animation: pieCenterIn 0.6s ease both 0.15s;
}
.pie-center strong {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text);
  line-height: 1;
}
.pie-center span {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.pie-legend {
  display: grid;
  gap: 10px;
}
.pie-legend-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: linear-gradient(135deg, #fffaf5 0%, #fff 100%);
  border: 1px solid var(--border);
  animation: legendIn 0.5s ease both;
  animation-delay: var(--delay, 0ms);
  transition: transform .18s ease, box-shadow .18s ease;
}
.pie-legend-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(26, 18, 11, 0.06);
}
.pie-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--slice-color);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--slice-color) 18%, transparent);
}
.pie-legend-copy {
  min-width: 0;
}
.pie-legend-copy strong {
  display: block;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pie-legend-copy span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.pie-legend-value {
  font-size: 14px;
  text-align: right;
}
.pie-legend-values {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.pie-legend-values.is-compact span {
  font-size: 12px;
}
.pie-legend-values span {
  white-space: nowrap;
  font-weight: 800;
}

/* Reports */
.report-toolbar {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
  padding: 16px 18px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.report-dates {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}
.report-date-field {
  display: grid;
  gap: 6px;
  min-width: 160px;
}
.report-date-field span {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.report-date-field input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}
.report-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.report-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 16px;
  margin-top: 16px;
}
.report-stats .value {
  font-size: 34px;
  font-weight: 800;
  line-height: 1.1;
}
.report-empty {
  margin-top: 8px;
}
.report-table-wrap {
  overflow-x: auto;
}
.report-table {
  width: 100%;
  border-collapse: collapse;
}
.report-table th,
.report-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.report-table th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}
.report-money .stack-values {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}
.stack-values {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.stack-values.is-compact span {
  font-size: 12px;
}
.stack-values span {
  white-space: nowrap;
  font-weight: 800;
}
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  min-height: 220px;
  padding: 8px 4px 0;
  overflow-x: auto;
}
.bar-chart.is-dense {
  gap: 6px;
}
.bar-col {
  flex: 1 0 42px;
  min-width: 42px;
  display: grid;
  gap: 8px;
  justify-items: center;
  align-content: end;
}
.bar-chart.is-dense .bar-col {
  flex-basis: 28px;
  min-width: 28px;
}
.bar-value {
  min-height: 16px;
  font-size: 11px;
  font-weight: 800;
  color: var(--accent);
}
.bar-track {
  width: 100%;
  height: 160px;
  display: flex;
  align-items: flex-end;
  background: linear-gradient(180deg, rgba(47, 93, 80, 0.06), transparent);
  border-radius: 12px 12px 4px 4px;
}
.bar-fill {
  width: 100%;
  border-radius: 12px 12px 4px 4px;
  background: linear-gradient(180deg, var(--primary), var(--accent));
  transition: height .35s ease;
}
.bar-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

@media (max-width: 1100px) {
  .report-grid { grid-template-columns: 1fr; }
}

.pie-empty {
  min-height: 220px;
  display: grid;
  place-items: center;
}

@keyframes pieSliceIn {
  from {
    opacity: 0;
    stroke-dasharray: 0 452;
  }
}
@keyframes pieCenterIn {
  from {
    opacity: 0;
    transform: scale(0.88);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
@keyframes legendIn {
  from {
    opacity: 0;
    transform: translateX(8px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar input, .toolbar select {
  height: 42px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 12px;
  padding: 0 12px;
}
.toolbar input { min-width: 240px; }

.sales-filter-panel {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px 14px;
  background: linear-gradient(180deg, #fffdfb 0%, var(--card) 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 4px 18px rgba(26, 18, 11, 0.05);
}
.sales-filter-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.sales-filter-presets {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.sales-pill {
  height: 30px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--card-soft);
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 700;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.sales-pill:hover {
  background: var(--primary-soft);
  border-color: rgba(198, 124, 78, 0.22);
}
.sales-filter-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.sales-nav-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.sales-nav-btn:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: rgba(47, 93, 80, 0.25);
  transform: translateY(-1px);
}
.sales-nav-btn:disabled {
  opacity: .4;
  cursor: not-allowed;
}
.sales-filter-date {
  min-width: 118px;
  text-align: center;
  padding: 0 4px;
}
.sales-filter-date strong {
  display: block;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.2;
}
.sales-filter-date span {
  display: block;
  margin-top: 1px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.sales-filter-range {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid rgba(232, 217, 203, 0.85);
}
.sales-range-field {
  display: grid;
  gap: 4px;
  min-width: 132px;
}
.sales-range-field span {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.sales-range-field input {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  min-width: 0;
}
.sales-range-field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(198, 124, 78, 0.12);
}
.sales-range-sep {
  align-self: flex-end;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}
.sales-range-submit {
  margin-left: auto;
  min-width: 72px;
}
@media (max-width: 760px) {
  .sales-filter-top {
    flex-direction: column;
    align-items: stretch;
  }
  .sales-filter-nav {
    margin-left: 0;
    justify-content: center;
  }
  .sales-filter-presets {
    justify-content: center;
  }
  .sales-range-submit {
    margin-left: 0;
    width: 100%;
  }
}
.sales-report-table .col-date-print-only {
  display: none;
}
.sales-report-table.sales-range-mode .col-date {
  display: table-cell;
}

.table-wrap {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}
th, td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  background: #fbf7f2;
}
td strong { font-weight: 700; }
.badge {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.badge-green { background: #e7f7ef; color: var(--success); }
.badge-blue { background: #e8f0fe; color: #3b82f6; }
.badge-purple { background: #f1e9ff; color: #8b5cf6; }
.badge-orange { background: var(--primary-soft); color: var(--primary-dark); }
.badge-gray { background: #f0ebe6; color: var(--muted); }
.badge-red { background: #fdecec; color: var(--danger); }
.sale-row-cancelled { background: #fff8f8; }
.sale-amount-cancelled {
  text-decoration: line-through;
  color: var(--muted);
}
.sale-cancel-info {
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: #fff5f5;
  border: 1px solid #f5d0d0;
}
.sale-cancel-info p {
  margin: 10px 0 0;
  color: var(--text);
}
.actions { display: flex; gap: 8px; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26,18,11,.45);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 50;
}
.modal {
  width: min(520px, 100%);
  background: var(--card);
  border-radius: 22px;
  padding: 22px;
  box-shadow: 0 24px 60px rgba(0,0,0,.2);
  max-height: calc(100vh - 40px);
  overflow: auto;
}
.modal.modal-wide {
  width: min(860px, 100%);
}
.modal h3 { margin: 0 0 16px; font-size: 22px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}
.image-upload {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
  padding: 14px;
  background: var(--card-soft);
  border: 1px solid var(--border);
  border-radius: 16px;
}
.image-preview-wrap,
#m-image-preview.image-placeholder,
img#m-image-preview {
  width: 120px;
  height: 120px;
  border-radius: 16px;
  object-fit: cover;
  background: #fff;
  border: 1px solid var(--border);
}
.image-placeholder,
#m-image-preview.image-placeholder {
  display: grid;
  place-items: center;
  font-size: 42px;
}
.image-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.image-actions label.btn { cursor: pointer; }
.product-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}
.product-thumb {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--primary-soft);
  flex: 0 0 auto;
}
.product-thumb.placeholder {
  display: grid;
  place-items: center;
  font-size: 20px;
}
.product-name-input {
  text-transform: uppercase;
}
.user-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-avatar,
.avatar-preview {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  object-fit: cover;
  background: var(--primary-soft);
  flex: 0 0 auto;
}
.user-avatar.placeholder,
.avatar-preview.placeholder,
#m-avatar-preview.avatar-preview.placeholder {
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 800;
  color: var(--primary-dark);
}
.avatar-upload .image-preview-wrap,
.avatar-upload img.avatar-preview,
.avatar-upload #m-avatar-preview.avatar-preview {
  width: 96px;
  height: 96px;
  border-radius: 999px;
}
.avatar-upload #m-avatar-preview.avatar-preview.placeholder {
  font-size: 28px;
}
.price-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}
.price-grid .field { margin-bottom: 0; }
.section-label {
  font-weight: 700;
  margin: 4px 0 10px;
  color: var(--text);
}
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 700px) {
  .price-grid,
  .form-grid-2 {
    grid-template-columns: 1fr;
  }
}
.empty {
  padding: 28px;
  text-align: center;
  color: var(--muted);
}
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: var(--bg-dark);
  color: #fff;
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 80;
  animation: fadein .2s ease;
}
@keyframes fadein {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1100px) {
  .grid-stats { grid-template-columns: repeat(2, 1fr); }
  .panel-grid { grid-template-columns: 1fr; }
  .pie-chart { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
  }
  .content { padding: 18px; }
  .page-head { flex-direction: column; }
}

.print-only { display: none; }

.currency-totals {
  margin-top: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.currency-totals h3 {
  margin: 0 0 12px;
  font-size: 16px;
}
.currency-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}
.currency-card {
  border: 1px solid var(--border);
  background: var(--card-soft);
  border-radius: 12px;
  padding: 10px 12px;
  min-width: 0;
}
.currency-card-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 4px;
}
.currency-card-amount {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}
.currency-card-count {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.daily-note-editor {
  margin-top: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.daily-closing-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--warning);
  border-radius: var(--radius);
  background: var(--card);
}
.daily-closing-card.is-processed {
  border-left-color: var(--success);
}
.daily-closing-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-weight: 800;
  color: var(--text);
}
.daily-closing-card p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}
@media (max-width: 620px) {
  .daily-closing-card {
    align-items: stretch;
    flex-direction: column;
  }
}
.daily-note-editor textarea {
  width: 100%;
  min-height: 100px;
  border: 1px solid var(--border);
  background: var(--card-soft);
  border-radius: 12px;
  padding: 12px 14px;
  resize: vertical;
  outline: none;
  font: inherit;
  color: var(--text);
}
.daily-note-editor textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(198,124,78,.15);
}
.daily-note-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}
.daily-note-print {
  display: none;
}

.sale-items-edit {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}
.sale-item-row {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 12px;
  align-items: end;
  padding: 10px 12px;
  background: var(--card-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.sale-item-name {
  font-weight: 700;
  padding-bottom: 10px;
}
table tfoot td {
  background: #fbf7f2;
  font-size: 15px;
}

@page {
  size: A4 portrait;
  margin: 10mm;
}

@media print {
  html, body {
    background: #fff !important;
    color: #000 !important;
    width: 100%;
  }
  .sidebar,
  .no-print,
  .toast {
    display: none !important;
  }
  .shell {
    display: block;
    min-height: auto;
  }
  .content {
    padding: 0 !important;
  }
  .print-only {
    display: block;
  }
  .print-header {
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #222;
  }
  .print-header h2 {
    margin: 0 0 2px;
    font-size: 16px;
  }
  .print-header p {
    margin: 0;
    color: #333;
    font-size: 12px;
  }
  #print-area,
  #reports-print-area {
    display: block;
    width: 100%;
  }
  .bar-chart {
    break-inside: avoid;
    min-height: 180px;
  }
  .pie-chart {
    break-inside: avoid;
  }
  .report-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .table-wrap {
    box-shadow: none !important;
    border: 1px solid #222;
    border-radius: 0;
    overflow: visible !important;
  }
  table.sales-report-table {
    min-width: 0 !important;
    width: 100% !important;
    table-layout: fixed;
    font-size: 11px;
  }
  table.sales-report-table .col-cashier,
  table.sales-report-table .col-time,
  table.sales-report-table .col-actions,
  table.sales-report-table .col-status,
  table.sales-report-table .col-cancel-reason {
    display: none !important;
  }
  table.sales-report-table .col-date,
  table.sales-report-table .col-date-print-only {
    display: table-cell !important;
    width: 14%;
  }
  table.sales-report-table .col-no {
    width: 8%;
  }
  table.sales-report-table .col-products {
    width: 44%;
  }
  table.sales-report-table .col-payment {
    width: 17%;
  }
  table.sales-report-table .col-amount {
    width: 17%;
  }
  table.sales-report-table tfoot .col-products {
    text-align: left;
  }
  table.expenses-report-table {
    min-width: 0 !important;
    width: 100% !important;
    table-layout: fixed;
    font-size: 11px;
  }
  table.expenses-report-table .col-cashier,
  table.expenses-report-table .col-time,
  table.expenses-report-table .col-actions,
  table.expenses-report-table .col-note,
  table.expenses-report-table .col-invoice {
    display: none !important;
  }
  table.expenses-report-table .col-no {
    width: 10%;
  }
  table.expenses-report-table .col-title {
    width: 60%;
  }
  table.expenses-report-table .col-amount {
    width: 30%;
  }
  th, td {
    padding: 5px 6px !important;
    border-bottom: 1px solid #ccc;
    word-wrap: break-word;
    overflow-wrap: anywhere;
  }
  th {
    background: #f0f0f0 !important;
    color: #000 !important;
    font-size: 10px;
  }
  .badge {
    border: 1px solid #999;
    background: #f5f5f5 !important;
    color: #000 !important;
    font-size: 10px;
    height: auto;
    padding: 1px 6px;
  }
  .currency-totals {
    break-inside: avoid;
    margin-top: 12px !important;
    padding: 8px;
    border: 1px solid #222;
    border-radius: 0;
    background: #fff;
    box-shadow: none;
  }
  .currency-totals h3 {
    margin: 0 0 8px;
    font-size: 12px;
  }
  .currency-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(95px, 1fr));
    gap: 6px;
  }
  .currency-card {
    border: 1px solid #999;
    border-radius: 0;
    background: #fafafa;
    padding: 6px 8px;
  }
  .currency-card-label {
    font-size: 10px;
    color: #333;
  }
  .currency-card-amount {
    font-size: 12px;
    color: #000;
  }
  .currency-card-count {
    font-size: 10px;
    color: #444;
  }
  table tfoot td {
    background: #fff !important;
    border-top: 2px solid #000;
    font-size: 11px;
  }
  .daily-note-print {
    display: block !important;
    break-inside: avoid;
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid #222;
  }
  .daily-note-print h3 {
    margin: 0 0 6px;
    font-size: 12px;
  }
  .daily-note-print p {
    margin: 0;
    font-size: 11px;
    line-height: 1.45;
    white-space: pre-wrap;
  }
}
