:root {
  --bg: #0c0d0f;
  --bg-soft: #15171b;
  --panel: #181a1f;
  --panel-2: #20232a;
  --panel-3: #262a31;
  --text: #f7f7f8;
  --muted: #a8abb2;
  --line: rgba(255, 255, 255, 0.12);
  --brand: #d71920;
  --brand-dark: #8f1016;
  --gold: #ffffff;
  --ink: #09090a;
  --danger: #e33a43;
  --warn: #c8ccd4;
  --ok: #f7f7f8;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

button {
  border: 0;
  cursor: pointer;
  color: var(--ink);
  background: var(--brand);
  color: white;
  padding: 12px 16px;
  border-radius: 8px;
  font-weight: 850;
  min-height: 42px;
}

button:hover { filter: brightness(1.04); }
button:disabled { opacity: .55; cursor: wait; }
button.secondary {
  background: #f1f2f4;
  color: #111318;
}
button.ghost, .icon-btn {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

input, select, textarea {
  width: 100%;
  color: var(--text);
  background: #0a1714;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  outline: none;
}

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

input:focus, select:focus, textarea:focus {
  border-color: rgba(215, 25, 32, 0.86);
  box-shadow: 0 0 0 3px rgba(215, 25, 32, 0.14);
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.hidden { display: none !important; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(90deg, rgba(12, 13, 15, .96), rgba(12, 13, 15, .68)),
    url("https://images.unsplash.com/photo-1580273916550-e323be2ae537?auto=format&fit=crop&w=1800&q=80") center / cover;
}

.login-panel {
  width: min(470px, 100%);
  background: rgba(24, 26, 31, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 30px;
  box-shadow: var(--shadow);
}

.brand-lockup, .sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--brand), #111318);
  color: white;
  border-radius: 8px;
  font-weight: 950;
  letter-spacing: 0;
  overflow: hidden;
}

.brand-mark.small {
  width: 46px;
  height: 46px;
}

.login-panel .brand-mark {
  width: 104px;
  height: 104px;
}

.logo-mark {
  background: #ffffff;
  border: 1px solid rgba(255,255,255,.16);
}

.logo-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 0;
}

.login-panel h1 { margin: 2px 0 0; font-size: 32px; }
.login-panel p { margin: 22px 0; color: var(--muted); line-height: 1.5; }
.login-panel button { width: 100%; margin-top: 14px; }
.login-panel small { display: block; min-height: 20px; color: var(--danger); margin-top: 10px; }

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: #0a0b0d;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

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

nav {
  display: grid;
  gap: 7px;
}

.nav {
  width: 100%;
  color: var(--muted);
  background: transparent;
  text-align: left;
  padding: 11px 13px;
}

.nav.active {
  color: var(--text);
  background: linear-gradient(90deg, rgba(215, 25, 32, .24), rgba(255, 255, 255, .05));
  box-shadow: inset 3px 0 0 var(--brand);
}

.sidebar .ghost { margin-top: auto; }

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

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

.eyebrow {
  color: var(--gold);
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 950;
}

.topbar h2 { margin: 4px 0 0; font-size: 29px; }
.view { display: none; }
.view.active { display: grid; gap: 18px; }

.hero-band {
  min-height: 164px;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  padding: 24px;
  border: 1px solid rgba(215, 25, 32, 0.28);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(143, 16, 22, .9), rgba(12, 13, 15, .78)),
    url("https://images.unsplash.com/photo-1600880292203-757bb62b4baf?auto=format&fit=crop&w=1400&q=80") center / cover;
  box-shadow: var(--shadow);
}

.hero-band h3 {
  max-width: 620px;
  margin: 8px 0 0;
  font-size: clamp(26px, 4vw, 44px);
  line-height: 1.04;
}

.hero-stats {
  display: grid;
  gap: 8px;
  min-width: min(260px, 100%);
}

.hero-stats span {
  display: block;
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 8px;
  background: rgba(7, 17, 15, .56);
  font-weight: 800;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

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

.metric {
  min-height: 118px;
  padding: 18px;
  position: relative;
  overflow: hidden;
}

.metric::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: var(--brand);
}

.metric.accent-gold::after { background: var(--gold); }
.metric.accent-green::after { background: var(--ok); }
.metric.accent-red::after { background: var(--danger); }

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

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 29px;
}

.split, .sales-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, .55fr);
  gap: 18px;
}

.panel {
  padding: 18px;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel h3 { margin: 0; }
.panel-head span, .muted { color: var(--muted); }

.bars, .events, .action-list, .rule-grid, .document-list, .account-list {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.bar-track {
  grid-column: 1 / -1;
  height: 9px;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255,255,255,.07);
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), #f7f7f8);
}

.event, .action-list div, .rule-grid div, .document-card, .notice {
  background: rgba(255,255,255,.04);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.event span, .event small, .document-card span, .document-card small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

.document-card {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.document-card em {
  display: block;
  color: var(--gold);
  font-style: normal;
  font-weight: 900;
  text-align: right;
}

.document-card a {
  display: block;
  margin-top: 8px;
  text-align: right;
}

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

.rule-grid span {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 210px 160px 140px;
  gap: 10px;
  align-items: center;
}

.inventory-filters {
  grid-template-columns: minmax(220px, 1fr) 230px 150px;
}

.live-filters {
  grid-template-columns: minmax(220px, 1fr) 180px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.check input { width: auto; }

.table-wrap, .sales-items {
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  max-height: 68vh;
}

.compact-action {
  width: fit-content;
  margin: 0 0 12px;
}

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

.sales-items table { min-width: 760px; }

th, td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
  white-space: nowrap;
}

td input {
  min-width: 86px;
  padding: 9px 10px;
}

th {
  position: sticky;
  top: 0;
  background: #0b1714;
  color: var(--muted);
  z-index: 1;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 8px;
  background: rgba(255,255,255,.08);
  color: var(--text);
  font-weight: 800;
}

.pill.ok { color: #101114; background: var(--ok); }
.pill.warn { color: #17191d; background: var(--warn); }
.pill.bad { color: white; background: var(--danger); }

.download {
  width: fit-content;
  color: #ff4a52;
  text-decoration: none;
  font-weight: 850;
}

.status-card {
  padding: 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
  margin-bottom: 14px;
}

.account-list {
  margin-bottom: 14px;
}

.account-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 62px;
  padding: 12px;
  text-align: left;
  color: var(--text);
  background: rgba(255,255,255,.045);
  border: 1px solid var(--line);
}

.account-card.active {
  border-color: rgba(215, 25, 32, .72);
  background: rgba(215, 25, 32, .16);
}

.account-card span, .account-card em {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.account-card em {
  color: var(--muted);
  font-style: normal;
  font-weight: 550;
}

.account-card small {
  color: #ff4a52;
  font-weight: 900;
}

.button-row, .upload {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

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

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

.product-finder {
  position: relative;
  margin-bottom: 14px;
}

.suggestions {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 8px);
  z-index: 5;
  display: grid;
  gap: 6px;
  max-height: 320px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #081411;
  box-shadow: var(--shadow);
}

.suggestions:empty { display: none; }

.suggestion {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: auto;
  padding: 10px 12px;
  text-align: left;
  color: var(--text);
  background: rgba(255,255,255,.05);
}

.suggestion span, .suggestion em {
  color: var(--muted);
  font-style: normal;
  font-weight: 500;
  white-space: normal;
}

.suggestion.manual {
  color: var(--ink);
  background: #f1f2f4;
  color: #111318;
}

.totals-grid {
  display: grid;
  grid-template-columns: 160px 130px minmax(200px, 1fr) 230px;
  gap: 12px;
  align-items: stretch;
  margin: 14px 0;
}

.totals-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(215,25,32,.18), rgba(255,255,255,.06));
  border: 1px solid rgba(215,25,32,.3);
}

.totals-card span {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
}

.totals-card strong { color: var(--text); }
.totals-card .grand-total {
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: #ff4a52;
  font-size: 17px;
  font-weight: 900;
}

.mini-btn {
  min-height: 34px;
  padding: 7px 10px;
  color: var(--text);
  background: rgba(255,255,255,.08);
}

.mini-btn.danger {
  background: rgba(223, 75, 95, .24);
  color: #ffdce2;
}

.notice {
  margin-bottom: 14px;
  color: #f5f5f5;
  background: rgba(215, 25, 32, .12);
}

@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
  }
  .sidebar {
    height: auto;
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  nav {
    grid-template-columns: repeat(7, minmax(112px, 1fr));
    overflow-x: auto;
  }
  .nav {
    text-align: center;
    white-space: nowrap;
  }
  .metric-grid, .split, .sales-layout, .rule-grid, .form-grid, .totals-grid {
    grid-template-columns: 1fr;
  }
  .filters, .inventory-filters, .upload {
    grid-template-columns: 1fr;
  }
  .hero-band {
    align-items: start;
    flex-direction: column;
  }
  .main {
    padding: 16px;
  }
  .topbar h2 {
    font-size: 24px;
  }
}
