:root {
  --bg: #fff7f0;
  --bg-accent: #ffe8d6;
  --surface: #fffaf6;
  --ink: #2a1a12;
  --muted: #7a5a48;
  --line: #efd5c4;
  --brand: #e85d04;
  --brand-dark: #c2410c;
  --accent: #f48c06;
  --danger: #b42318;
  --ok: #d97706;
  --sidebar: #7c2d12;
  --sidebar-text: #ffedd5;
  --radius: 10px;
  --shadow: 0 10px 30px rgba(194, 65, 12, 0.10);
  --font: "Source Sans 3", "Segoe UI", sans-serif;
  --display: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(232, 93, 4, 0.16), transparent 42%),
    radial-gradient(circle at bottom right, rgba(244, 140, 6, 0.14), transparent 38%),
    linear-gradient(160deg, var(--bg), var(--bg-accent));
  min-height: 100vh;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }

.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, #9a3412, var(--sidebar));
  color: var(--sidebar-text);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.brand {
  font-family: var(--display);
  font-size: 1.75rem;
  letter-spacing: -0.02em;
  padding: 0 0.5rem;
  color: #fff;
}

.brand span {
  display: block;
  font-family: var(--font);
  font-size: 0.75rem;
  opacity: 0.7;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 0.25rem;
}

.nav { display: flex; flex-direction: column; gap: 0.35rem; }
.nav a {
  color: var(--sidebar-text);
  padding: 0.7rem 0.85rem;
  border-radius: 8px;
  opacity: 0.85;
}
.nav a:hover, .nav a.active {
  background: rgba(255,255,255,0.1);
  opacity: 1;
  color: #fff;
}

.sidebar-foot {
  margin-top: auto;
  padding: 0.5rem;
  font-size: 0.9rem;
  opacity: 0.8;
}

.nav-divider {
  margin: 0.75rem 0.5rem 0.35rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.55;
}

.role-tag {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.7;
  margin-top: 0.15rem;
}

.main {
  padding: 1.5rem 1.75rem 2.5rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  gap: 1rem;
}

.topbar h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.85rem;
  letter-spacing: -0.02em;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}

.stat .label {
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat .value {
  font-family: var(--display);
  font-size: 1.6rem;
  margin-top: 0.35rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: none;
  border-radius: 8px;
  padding: 0.55rem 0.95rem;
  font: inherit;
  cursor: pointer;
  background: var(--brand);
  color: #fff;
}
.btn:hover { background: var(--brand-dark); }
.btn-secondary { background: #9a3412; }
.btn-secondary:hover { background: #7c2d12; }
.btn-danger { background: var(--danger); }
.btn-ghost {
  background: transparent;
  color: var(--brand);
  border: 1px solid var(--line);
}
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.9rem; }

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  text-align: left;
  padding: 0.75rem 0.6rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background: #ffedd5;
  color: var(--brand-dark);
}
.badge.running { background: #ffedd5; color: var(--brand); }
.badge.held { background: #fff7ed; color: #9a3412; }
.badge.completed { background: #ffedd5; color: var(--ok); }
.badge.cancelled { background: #fee4e2; color: var(--danger); }
.badge.returned { background: #fee4e2; color: var(--danger); }
.badge.draft, .badge.ordered, .badge.received { background: #ffedd5; color: var(--brand-dark); }

.flash {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}
.flash.success { background: #ffedd5; color: var(--brand-dark); }
.flash.error { background: #fee4e2; color: var(--danger); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.form-group { display: flex; flex-direction: column; gap: 0.35rem; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 0.9rem; color: var(--muted); }
input, select, textarea {
  font: inherit;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(232, 93, 4, 0.28);
  border-color: var(--brand);
}

.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

.barcode-box {
  min-width: 120px;
  max-width: 180px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.35rem 0.4rem;
}
.barcode-box svg { max-width: 100%; height: auto; display: block; }
.barcode-box-lg {
  min-width: 140px;
  max-width: 100%;
  margin: 0.4rem auto 0;
  padding: 0.5rem;
}

.billing-scan {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  margin-bottom: 1rem;
  position: relative;
}
.billing-scan input {
  font-size: 1.25rem;
  padding: 0.9rem 1rem;
}
.billing-scan .search-dropdown {
  left: 0;
  right: 80px;
  top: calc(100% + 4px);
}
.search-result-item.is-active,
.search-result-item:hover { background: #fff7ed; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    linear-gradient(135deg, rgba(124,45,18,0.94), rgba(232,93,4,0.82)),
    url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40"><circle cx="2" cy="2" r="1.5" fill="%23ffffff22"/></svg>');
}
.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border-radius: 14px;
  padding: 2rem;
  box-shadow: var(--shadow);
}
.login-card h1 {
  font-family: var(--display);
  margin: 0 0 0.25rem;
}
.login-card p { color: var(--muted); margin-top: 0; }
.login-card .form-group { margin-bottom: 0.9rem; }
.login-card .btn { width: 100%; margin-top: 0.5rem; }

.muted { color: var(--muted); }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.mt-1 { margin-top: 1rem; }
.mb-1 { margin-bottom: 1rem; }

.search-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 20;
  max-height: 240px;
  overflow-y: auto;
}

.search-result-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 0.65rem 0.85rem;
  font: inherit;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}

.search-result-item:hover { background: #fff7ed; }
.search-result-item.is-active { background: #ffedd5; }
.search-result-item:last-child { border-bottom: none; }

.label-sheet {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}

.label-card {
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 0.75rem;
  text-align: center;
}

.label-name { font-weight: 600; font-size: 0.9rem; margin-top: 0.35rem; }
.label-price { font-family: var(--display); color: var(--brand); margin: 0.15rem 0; }
.label-barcode { font-size: 0.75rem; }

@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot { margin-top: 0; width: 100%; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
}

.stats:has(.stat:nth-child(5)) {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

@media (max-width: 960px) {
  .stats:has(.stat:nth-child(5)) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media print {
  .sidebar, .topbar .actions, .no-print { display: none !important; }
  .app-shell { display: block; }
  .main { padding: 0; }
}

/* Dashboard graphics */
.dash-hero {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.dash-hero-card {
  border-radius: 16px;
  padding: 1.25rem 1.35rem;
  color: #fff;
  background:
    radial-gradient(circle at top right, rgba(255,255,255,0.22), transparent 45%),
    linear-gradient(135deg, #e85d04, #9a3412);
  box-shadow: var(--shadow);
  min-height: 120px;
}
.dash-hero-card.soft {
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(232,93,4,0.12), transparent 50%),
    var(--surface);
  border: 1px solid var(--line);
}
.dash-hero-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.85;
}
.dash-hero-card.soft .dash-hero-label { color: var(--muted); opacity: 1; }
.dash-hero-value {
  font-family: var(--display);
  font-size: 2rem;
  margin-top: 0.45rem;
  letter-spacing: -0.02em;
}
.dash-hero-meta {
  margin-top: 0.35rem;
  font-size: 0.9rem;
  opacity: 0.85;
}
.dash-hero-card.soft .dash-hero-meta { color: var(--muted); opacity: 1; }

.dash-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem;
  margin-bottom: 1.25rem;
}
.dash-stat {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.95rem 1rem;
  box-shadow: var(--shadow);
}
.dash-stat .label {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.dash-stat .value {
  font-family: var(--display);
  font-size: 1.35rem;
  margin-top: 0.15rem;
}
.dash-stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.dash-stat-icon.sales { background: linear-gradient(135deg, #e85d04, #c2410c); }
.dash-stat-icon.bills { background: linear-gradient(135deg, #f48c06, #ea580c); }
.dash-stat-icon.open { background: linear-gradient(135deg, #fb923c, #c2410c); }
.dash-stat-icon.stock { background: linear-gradient(135deg, #b42318, #912018); }

.dash-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.dash-panel-title {
  margin: 0;
  font-family: var(--display);
  font-size: 1.2rem;
}
.chart-wrap {
  position: relative;
  height: 260px;
}
.chart-wrap-sm { height: 240px; }

.top-list { display: flex; flex-direction: column; gap: 0.85rem; }
.top-row { display: flex; gap: 0.75rem; align-items: flex-start; }
.top-rank {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #ffedd5;
  color: var(--brand-dark);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.top-rank.warn { background: #fee4e2; color: var(--danger); }
.top-meta { flex: 1; min-width: 0; }
.top-bar {
  margin-top: 0.4rem;
  height: 8px;
  border-radius: 999px;
  background: #ffe8d6;
  overflow: hidden;
}
.top-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f48c06, #e85d04);
}

.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.quick-card {
  display: block;
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background:
    linear-gradient(160deg, #fff7f0, #fffaf6);
  color: inherit;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.quick-card:hover {
  transform: translateY(-2px);
  border-color: #f0b27a;
  color: inherit;
}
.quick-card strong { display: block; margin-bottom: 0.2rem; }
.quick-card span { color: var(--muted); font-size: 0.9rem; }

@media (max-width: 1100px) {
  .dash-hero, .dash-stats, .dash-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .dash-hero, .dash-stats, .dash-grid, .quick-actions { grid-template-columns: 1fr; }
  .dash-hero-value { font-size: 1.65rem; }
}

