
:root {
  --cream: #f8f1e6;
  --paper: #fffaf2;
  --ink: #38251d;
  --brown: #693d2b;
  --orange: #f0a34a;
  --green: #647b50;
  --muted: #82756a;
  --line: #e8ddcd;
  --danger: #b83d3d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: "DM Sans", Arial, sans-serif;
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 245px;
  background: var(--ink);
  color: white;
  padding: 28px 18px;
  display: flex;
  flex-direction: column;
  z-index: 5;
}

.brand {
  font-size: 1.55rem;
  font-weight: 800;
  text-decoration: none;
  color: white;
  padding: 4px 10px 30px;
}

.brand span { color: var(--orange); }

.side-label, .eyebrow {
  font-size: .68rem;
  letter-spacing: .13em;
  font-weight: 800;
}

.side-label {
  color: #cbb7a5;
  padding: 0 10px;
}

.sidebar nav {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.nav-btn {
  text-align: left;
  padding: 13px;
  color: #f7eade;
  background: transparent;
  border: 0;
  border-radius: 10px;
  font-weight: 600;
}

.nav-btn:hover, .nav-btn.active {
  background: var(--orange);
  color: var(--ink);
}

.back-link {
  margin-top: auto;
  padding: 13px 10px;
  color: #f7eade;
  text-decoration: none;
  font-size: .88rem;
}

.main {
  margin-left: 245px;
  padding: 30px clamp(18px, 4vw, 48px);
  max-width: 1700px;
}

.topbar, .welcome, .panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar { margin-bottom: 28px; }

.topbar h1 {
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  margin: 5px 0;
}

.eyebrow { color: #a66c39; margin: 0; }

.admin-badge {
  background: white;
  border: 1px solid var(--line);
  padding: 10px 15px;
  border-radius: 999px;
  font-weight: 700;
  font-size: .85rem;
}

.view { display: none; }
.view.active { display: block; }

.welcome {
  background: var(--brown);
  color: white;
  padding: 24px;
  border-radius: 18px;
  margin-bottom: 22px;
}

.welcome h2 { margin: 0 0 6px; }
.welcome p { margin: 0; color: #f0ddcc; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 15px;
  margin-bottom: 22px;
}

.stat-card, .panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 20px;
  min-width: 0;
}

.stat-card span, .stat-card small {
  display: block;
  color: var(--muted);
  font-size: .82rem;
}

.stat-card strong {
  display: block;
  font-size: clamp(1.25rem, 2.3vw, 1.8rem);
  overflow-wrap: anywhere;
  margin: 12px 0 6px;
}

.panel { margin-bottom: 22px; }
.panel h2 { margin: 0 0 7px; font-size: 1.15rem; }
.panel > p, .panel-heading p {
  color: var(--muted);
  font-size: .84rem;
  margin: 0 0 14px;
}

.primary, .secondary {
  border: 0;
  border-radius: 9px;
  padding: 11px 15px;
  font-weight: 700;
}

.primary {
  background: var(--ink);
  color: white;
}

.primary:hover { background: var(--brown); }

.secondary {
  background: var(--cream);
  color: var(--ink);
  border: 1px solid var(--line);
}

.full { width: 100%; margin-top: 14px; }

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.toolbar input { flex: 1; min-width: 170px; }
.toolbar select { min-width: 180px; }

input, select {
  width: 100%;
  padding: 11px 12px;
  background: white;
  color: var(--ink);
  border: 1px solid #ddcdbb;
  border-radius: 8px;
}

input:focus, select:focus {
  outline: 2px solid #f0a34a66;
  border-color: var(--orange);
}

label {
  display: block;
  margin: 14px 0 6px;
  font-size: .83rem;
  font-weight: 700;
}

.table-panel { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
th, td {
  padding: 13px 11px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
th { background: #faf3e8; }
td { background: white; }
.table-action {
  border: 1px solid var(--line);
  background: white;
  padding: 7px 9px;
  border-radius: 7px;
  margin: 2px;
}
.table-action.delete { color: var(--danger); }
.low { color: var(--danger); font-weight: 800; }
.empty {
  text-align: center;
  color: var(--muted);
  padding: 25px 10px;
}

.sales-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.sale-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-size: .86rem;
}

.sale-line button {
  border: 0;
  background: #f8e6df;
  border-radius: 6px;
  padding: 5px 8px;
  margin-left: 6px;
}

.sale-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 18px;
  margin-top: 10px;
  border-top: 1px solid var(--line);
}

.sale-total strong { font-size: 1.5rem; }
.help { font-size: .75rem; color: var(--muted); }

dialog {
  border: 1px solid var(--line);
  border-radius: 16px;
  width: min(520px, calc(100% - 24px));
  max-height: 90vh;
  overflow-y: auto;
  padding: 25px;
  background: var(--paper);
  color: var(--ink);
}

dialog::backdrop { background: #24181099; }

.dialog-heading, .dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dialog-heading h2 { margin: 0; font-size: 1.35rem; }

.close-btn {
  border: 0;
  background: transparent;
  font-size: 1.8rem;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.dialog-actions { margin-top: 24px; justify-content: flex-end; }

.notice {
  position: fixed;
  bottom: 20px;
  right: 20px;
  max-width: calc(100% - 40px);
  padding: 13px 18px;
  background: var(--ink);
  color: white;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: .2s;
  z-index: 10;
}

.notice.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .sidebar {
    position: static;
    width: 100%;
    padding: 15px;
  }

  .brand { padding: 0 5px 12px; }
  .side-label { padding: 0 5px; }
  .sidebar nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nav-btn { font-size: .8rem; padding: 11px 8px; }
  .back-link { margin-top: 10px; padding: 10px 5px; }
  .main { margin: 0; padding: 20px 14px; }
  .topbar { align-items: flex-start; }
  .admin-badge { font-size: .72rem; }
  .welcome { align-items: flex-start; flex-direction: column; }
  .sales-layout { grid-template-columns: 1fr; }
  .panel { padding: 15px; }
  .toolbar { flex-direction: column; }
  .toolbar button { width: 100%; }
}

@media (max-width: 420px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 9px; }
  .stat-card { padding: 13px; }
  .stat-card span, .stat-card small { font-size: .72rem; }
  .form-grid { grid-template-columns: 1fr; gap: 0; }
}
