:root {
  --bg: #eef2f6;
  --bg-soft: #f8fafc;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --ink: #101828;
  --muted: #667085;
  --line: #d9e2ec;
  --line-strong: #c8d3df;
  --primary: #047857;
  --primary-dark: #065f46;
  --primary-soft: #e7f8f0;
  --accent: #f59e0b;
  --accent-soft: #fff7e6;
  --info: #2563eb;
  --danger: #dc2626;
  --danger-soft: #fff1f2;
  --good: #16a34a;
  --sidebar: #111827;
  --sidebar-2: #1f2937;
  --shadow: 0 18px 45px rgba(16, 24, 40, 0.10);
  --shadow-soft: 0 8px 20px rgba(16, 24, 40, 0.07);
}

body.theme-blue {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --accent: #0ea5e9;
  --accent-soft: #e0f2fe;
  --info: #1d4ed8;
  --sidebar: #0f172a;
  --sidebar-2: #1e293b;
}

body.theme-red {
  --primary: #dc2626;
  --primary-dark: #b91c1c;
  --primary-soft: #fff1f2;
  --accent: #f97316;
  --accent-soft: #fff7ed;
  --info: #b91c1c;
  --sidebar: #1f1111;
  --sidebar-2: #3f1717;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100%;
  background:
    linear-gradient(180deg, #f8fafc 0, #eef2f6 360px, #eef2f6 100%);
  color: var(--ink);
  font-family: "Segoe UI", Tahoma, sans-serif;
  font-size: 16px;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button,
input,
select {
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.app-shell {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px;
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: #f9fafb;
  box-shadow: 8px 0 28px rgba(17, 24, 39, 0.16);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  padding-bottom: 4px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 8px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 900;
  letter-spacing: 0;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.14), 0 12px 24px rgba(15, 23, 42, 0.18);
}

.brand h1,
.brand p,
.panel h3,
.panel p,
.topbar h2,
.eyebrow {
  margin: 0;
}

.brand h1 {
  font-size: 1.32rem;
  line-height: 1.1;
}

.brand p,
.sync-panel small {
  color: #cbd5e1;
  font-size: 0.86rem;
}

.nav-tabs {
  display: grid;
  gap: 8px;
}

.nav-tab {
  width: 100%;
  min-height: 48px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #dbeafe;
  text-align: left;
  padding: 0 14px;
  font-weight: 800;
}

.nav-tab.active,
.nav-tab:hover {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.16);
  color: #ffffff;
  box-shadow: inset 4px 0 0 var(--accent);
}

.sync-panel {
  margin-top: auto;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.sync-panel strong {
  display: block;
  color: #ffffff;
}

.status-dot {
  width: 13px;
  height: 13px;
  margin-top: 4px;
  border-radius: 999px;
  flex: 0 0 auto;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.18);
}

.status-dot.ready {
  background: var(--good);
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.18);
}

.status-dot.error {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.16);
}

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

.topbar,
.panel-header,
.form-actions,
.scan-row,
.scanner-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar {
  margin-bottom: 20px;
  padding: 4px 2px;
}

.eyebrow {
  color: var(--primary);
  font-weight: 900;
  font-size: 0.82rem;
  text-transform: uppercase;
}

.topbar h2 {
  color: #0f172a;
  font-size: 2.08rem;
  line-height: 1.12;
}

.top-actions {
  display: flex;
  gap: 10px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.sale-grid,
.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1.72fr) minmax(340px, 0.86fr);
  gap: 18px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  padding: 18px;
  min-width: 0;
}

.checkout-panel {
  min-height: 620px;
}

.panel h3 {
  color: #0f172a;
  font-size: 1.23rem;
  line-height: 1.25;
}

.panel p {
  color: var(--muted);
  margin-top: 4px;
}

.scan-row {
  align-items: end;
  margin: 18px 0;
  padding: 14px;
  border: 1px solid #dbe7df;
  border-radius: 8px;
  background: var(--primary-soft);
}

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

.field.wide,
.check-row.wide {
  grid-column: 1 / -1;
}

.field span,
.check-row span {
  color: #475467;
  font-weight: 800;
  font-size: 0.9rem;
}

input,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid #cfd8e3;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 0 13px;
  outline: none;
  box-shadow: inset 0 1px 2px rgba(16, 24, 40, 0.04);
}

input::placeholder {
  color: #98a2b3;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(4, 120, 87, 0.13);
}

.primary-button,
.secondary-button,
.ghost-button,
.checkout-button,
.icon-button,
.danger-button {
  min-height: 48px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 16px;
  font-weight: 900;
  white-space: nowrap;
}

.primary-button,
.checkout-button {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary-dark);
  box-shadow: 0 8px 18px rgba(4, 120, 87, 0.18);
}

.primary-button:hover,
.checkout-button:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.secondary-button,
.icon-button {
  background: #ffffff;
  color: var(--info);
  border-color: color-mix(in srgb, var(--info) 28%, #ffffff);
  box-shadow: 0 5px 14px rgba(37, 99, 235, 0.08);
}

.secondary-button:hover,
.icon-button:hover {
  background: var(--primary-soft);
}

.ghost-button {
  background: #ffffff;
  color: #475467;
  border-color: var(--line);
}

.ghost-button:hover {
  border-color: var(--line-strong);
  background: #f8fafc;
}

.danger-button {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #fecdd3;
}

.icon-button {
  width: 48px;
  padding: 0;
  font-size: 1.35rem;
}

.quick-products {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.quick-product {
  min-height: 82px;
  padding: 12px;
  border: 1px solid #dbe5ef;
  border-radius: 8px;
  background: #ffffff;
  text-align: left;
  box-shadow: 0 5px 14px rgba(16, 24, 40, 0.05);
}

.quick-product:hover {
  border-color: color-mix(in srgb, var(--primary) 38%, #ffffff);
  background: var(--primary-soft);
  transform: translateY(-1px);
}

.quick-product strong,
.quick-product span {
  display: block;
}

.quick-product strong {
  color: #0f172a;
}

.quick-product span {
  margin-top: 5px;
  color: var(--muted);
  font-weight: 700;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

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

th,
td {
  padding: 12px;
  border-bottom: 1px solid #edf1f5;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f8fafc;
  color: #475467;
  font-size: 0.86rem;
  font-weight: 900;
}

tr:last-child td {
  border-bottom: 0;
}

td strong {
  font-size: 1.02rem;
}

.qty-control {
  display: grid;
  grid-template-columns: 38px 56px 38px;
  gap: 6px;
  align-items: center;
}

.qty-control button {
  width: 38px;
  min-height: 38px;
  border: 1px solid #cfd8e3;
  border-radius: 8px;
  background: #ffffff;
  color: #0f172a;
  font-weight: 900;
}

.qty-control button:hover {
  background: var(--primary-soft);
  border-color: color-mix(in srgb, var(--primary) 38%, #ffffff);
}

.qty-control input {
  min-height: 38px;
  padding: 0 6px;
  text-align: center;
  font-weight: 900;
}

.summary-panel {
  display: grid;
  gap: 14px;
  align-self: start;
  border-color: #cfd8e3;
  box-shadow: var(--shadow);
}

.summary-total {
  padding: 18px;
  border-radius: 8px;
  background: #111827;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 -3px 0 var(--accent);
}

.summary-total span,
.summary-total strong {
  display: block;
}

.summary-total span {
  color: #cbd5e1;
  font-weight: 800;
}

.summary-total strong {
  margin-top: 7px;
  font-size: 2.75rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.summary-lines {
  display: grid;
  gap: 8px;
}

.summary-lines div,
.metric {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid #e5eaf0;
  border-radius: 8px;
  background: #f8fafc;
}

.summary-lines strong,
.metric strong {
  font-variant-numeric: tabular-nums;
}

.checkout-button {
  min-height: 60px;
  background: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 82%, #000000);
  color: #ffffff;
  font-size: 1.12rem;
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.18);
}

.checkout-button:hover {
  background: color-mix(in srgb, var(--accent) 82%, #000000);
  color: #ffffff;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.form-actions {
  grid-column: 1 / -1;
  justify-content: flex-start;
}

.compact-search {
  max-width: 220px;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.metric {
  display: grid;
  border-color: #dbe5ef;
  background: #ffffff;
  box-shadow: var(--shadow-soft);
}

.metric span {
  color: var(--muted);
  font-weight: 800;
}

.metric strong {
  color: #0f172a;
  font-size: 1.65rem;
}

.activity-list,
.receipt-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.activity-item,
.receipt-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(16, 24, 40, 0.04);
}

.activity-item strong,
.activity-item span,
.receipt-item strong,
.receipt-item span {
  display: block;
}

.activity-item span,
.receipt-item span {
  margin-top: 3px;
  color: var(--muted);
}

.check-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.check-row input {
  width: 20px;
  min-height: 20px;
}

.setup-list {
  margin: 16px 0 0;
  padding-left: 22px;
  color: var(--muted);
}

.setup-list li {
  margin: 10px 0;
}

.scanner-dialog {
  width: min(680px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.scanner-dialog::backdrop {
  background: rgba(15, 23, 42, 0.62);
}

.video-box {
  position: relative;
  overflow: hidden;
  margin-top: 14px;
  border-radius: 8px;
  background: #0b1210;
  aspect-ratio: 4 / 3;
}

.video-box video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scan-frame {
  position: absolute;
  inset: 28% 12%;
  border: 3px solid var(--accent);
  border-radius: 8px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.22);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 20;
  transform: translateX(-50%) translateY(120px);
  max-width: min(560px, calc(100vw - 28px));
  padding: 13px 16px;
  border-radius: 8px;
  background: #111827;
  color: #ffffff;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.muted {
  color: var(--muted);
}

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

  .sidebar {
    position: static;
    height: auto;
  }

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

  .nav-tab {
    text-align: center;
  }

  .sync-panel {
    margin-top: 0;
  }

  .sale-grid,
  .two-column {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  body {
    font-size: 15px;
    background: #f3f6f9;
  }

  .main,
  .sidebar {
    padding: 14px;
  }

  .sidebar {
    gap: 16px;
  }

  .topbar,
  .panel-header,
  .scan-row,
  .scanner-head {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .form-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .icon-button {
    width: 100%;
  }

  .form-grid,
  .metric-row {
    grid-template-columns: 1fr;
  }

  .nav-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .nav-tab {
    min-height: 44px;
    padding: 0 8px;
    font-size: 0.9rem;
    text-align: center;
  }

  .panel {
    padding: 14px;
  }

  .checkout-panel {
    min-height: auto;
  }

  .topbar h2 {
    font-size: 1.58rem;
  }

  .summary-total strong {
    font-size: 2.22rem;
  }

  .compact-search {
    max-width: none;
  }

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

  table {
    min-width: 560px;
  }
}
