:root {
  --bg: #050505;
  --panel: #111113;
  --panel-2: #19191c;
  --panel-3: #2f2f2f;
  --line: transparent;
  --line-red: transparent;
  --text: #f4f4f4;
  --muted: #ababab;
  --red: #b10902;
  --red-dark: #3a0d0b;
  --white: #ffffff;
  --green: #009638;
  --blue: #0462e0;
  --yellow: #d89529;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

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

body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 4px;
  pointer-events: none;
  background: var(--red);
}

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

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

input:focus, select:focus, textarea:focus {
  box-shadow: 0 0 0 3px rgba(177, 9, 2, 0.28);
}

input[type="checkbox"] {
  width: auto;
  min-width: 18px;
  min-height: 18px;
  accent-color: var(--red);
}

textarea { min-height: 84px; resize: vertical; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 550; }
code { color: var(--white); background: #242426; padding: 2px 5px; border-radius: 4px; }

.login-shell {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 16px;
}

.login-panel {
  position: relative;
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line-red);
  border-radius: 8px;
  padding: 22px;
  box-shadow: 0 18px 56px rgba(0,0,0,0.62);
}

.login-logo {
  width: 64px;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line-red);
  margin-bottom: 14px;
}

.brand-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  background: var(--red);
  border-radius: 6px;
  font-weight: 700;
  color: var(--white);
}

.eyebrow {
  color: var(--red);
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.1em;
}

.login-panel h1, .topbar h1 {
  margin: 2px 0 0;
  color: var(--white);
  line-height: 1.05;
  font-size: clamp(27px, 5vw, 38px);
  font-weight: 650;
}

.login-panel p {
  margin: 0 0 20px;
  color: var(--muted);
  line-height: 1.45;
}

.stack { display: grid; gap: 14px; }
.small { font-size: 12px; line-height: 1.45; }
.muted { color: var(--muted); }

.app-shell {
  position: relative;
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 14px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 12px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--red);
  border-radius: 8px;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.topbar-brand img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line-red);
}

.user-box {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

#current-user {
  color: var(--white);
  font-weight: 600;
  padding: 9px 12px;
  background: #0a0a0b;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.module-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px;
  margin-bottom: 14px;
  background: #080809;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--panel-3);
  color: var(--text);
  border-radius: 6px;
  padding: 11px 14px;
  cursor: pointer;
  font-weight: 600;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

.btn-primary, .btn.active {
  background: #48484c;
  color: var(--white);
}
.btn:hover { background: #46464a; }
.btn-danger { background: #3a3a3e; color: var(--white); }
.btn-green { background: #39393d; color: var(--white); }
.btn-blue { background: #343438; color: var(--white); }
.btn-gold { background: #424246; color: var(--white); }
.btn-ghost { background: #242428; color: #e9e9e9; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.view { display: grid; gap: 14px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 0.48fr); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }

.panel {
  background: #191919;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.panel h2, .panel h3 {
  margin: 0 0 12px;
  color: var(--white);
  font-weight: 650;
}

.panel h2 { font-size: clamp(20px, 2vw, 28px); }

#dashboard-view .panel {
  min-height: 176px;
  display: grid;
  align-content: space-between;
  border-left: 4px solid var(--red);
}

#dashboard-view .panel h2 {
  font-size: 29px;
}

.tabs, .subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-roles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.quick-role {
  min-height: 72px;
  display: grid;
  gap: 4px;
  place-items: center;
  text-align: center;
}

.quick-role span {
  color: var(--white);
  font-size: 16px;
}

.quick-role small {
  color: rgba(255,255,255,0.82);
  font-weight: 500;
}

.status-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.metric {
  min-height: 88px;
  padding: 14px;
  background: #333333;
  border: 1px solid var(--line);
  border-left: 4px solid var(--red);
  border-radius: 8px;
}
.metric span { display: block; color: var(--muted); font-size: 12px; font-weight: 550; text-transform: uppercase; }
.metric strong { display: block; margin-top: 5px; font-size: clamp(21px, 2vw, 30px); color: var(--white); font-weight: 700; }

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 10px;
}

.product-btn {
  min-height: 88px;
  display: grid;
  gap: 8px;
  align-content: center;
  text-align: center;
  background: #2f2f2f;
  border: 1px solid var(--line);
  border-left: 4px solid var(--red);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
}
.product-btn:hover { background: #252529; }
.product-btn span { color: #ffffff; font-size: 12px; }
.product-volume {
  color: var(--muted);
  font-size: 0.76em;
  font-weight: 300;
}
.product-price {
  font-weight: 500;
}
.receipt-product-name {
  font-weight: 600;
}

.receipt-items {
  min-height: 160px;
  max-height: 360px;
  overflow: auto;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #070707;
}
.receipt-row, .list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  background: #0b0b0c;
  border: 1px solid var(--line);
  border-radius: 7px;
  margin-bottom: 8px;
}
.qty-controls { display: flex; gap: 6px; align-items: center; }
.icon-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  display: grid;
  place-items: center;
}
.qty-input {
  width: 64px;
  min-width: 64px;
  padding: 7px 8px;
  text-align: center;
  font-weight: 650;
  background: var(--panel-3);
  color: var(--white);
}
.totals {
  background: #070707;
  border: 1px solid var(--line);
  border-left: 4px solid var(--red);
  border-radius: 8px;
  padding: 13px;
}
.total-line { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 6px; color: var(--muted); }
.grand-total {
  font-size: clamp(31px, 4vw, 42px);
  color: var(--white);
  font-weight: 700;
  text-align: right;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}
table { width: 100%; border-collapse: collapse; min-width: 760px; background: #080809; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--white); font-size: 12px; text-transform: uppercase; background: var(--red-dark); }
td { color: #eeeeee; font-size: 14px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.form-grid .full { grid-column: 1 / -1; }
.field-label { color: var(--muted); font-size: 13px; font-weight: 550; margin-bottom: 7px; }
.role-checks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
}
.admin-delete-form {
  margin-top: 16px;
  padding-top: 16px;
  background: #0b0b0c;
}
.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #080809;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  color: var(--text);
}
.ledger-summary { margin-bottom: 12px; }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  background: #2a2a30;
  color: #f2f2f2;
  font-size: 12px;
  font-weight: 600;
}
.badge.ok { background: #15391f; color: #d8ffe5; }
.badge.warn { background: #3d2e10; color: #ffe0a0; }
.badge.bad { background: var(--red-dark); color: #ffd9d6; }

.open-bills-list, .compact-list { display: grid; gap: 8px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.toast {
  position: fixed;
  top: 14px;
  left: 12px;
  right: 12px;
  z-index: 10;
  width: min(460px, calc(100% - 24px));
  margin: 0 auto;
  background: var(--red);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--white);
  font-weight: 650;
  box-shadow: 0 18px 54px rgba(0,0,0,0.6);
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(0,0,0,0.62);
  color: var(--white);
}

.loading-card {
  display: grid;
  gap: 14px;
  justify-items: center;
}

.loading-icon {
  width: min(150px, 42vw);
  height: auto;
  display: block;
  animation: loading-bob 1.15s ease-in-out infinite;
}

.empty-state {
  display: block;
  padding: 18px 20px;
}

body.photo-mode-active { background: #050505; }
body.photo-mode-active .topbar,
body.photo-mode-active .module-nav,
body.photo-mode-active .business-main,
body.photo-mode-active .cash-actions .hide-photo {
  display: none;
}
body.photo-mode-active .grid-2 { display: block; }
body.photo-mode-active .cash-panel { max-width: 420px; margin: 24px auto; }
.photo-return { display: none; }
body.photo-mode-active .photo-return {
  display: block;
  margin-bottom: 14px;
}

input,
select,
textarea,
.login-panel,
.login-logo,
.brand-mark,
.topbar,
.topbar-brand img,
#current-user,
.module-nav,
.btn,
.panel,
#dashboard-view .panel,
.metric,
.product-btn,
.cash-panel,
.receipt-items,
.receipt-row,
.list-row,
.totals,
.grand-total,
.table-wrap,
th,
td,
.check-row,
.toast {
  border: 0 !important;
}

.topbar,
#dashboard-view .panel,
.metric,
.product-btn,
.totals {
  border-left: 4px solid var(--red) !important;
}

@keyframes loading-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}

@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .topbar, .grid-2 { grid-template-columns: 1fr; display: grid; }
  .topbar { align-items: start; }
  .topbar-brand img { width: 50px; height: 50px; }
  .status-row, .grid-3, .form-grid { grid-template-columns: 1fr; }
  .user-box { justify-content: flex-start; }
  .app-shell { padding: 10px; }
  .login-shell { padding: 12px; }
  .login-panel { padding: 18px; }
  .login-logo { width: 58px; }
  .module-nav { padding: 7px; }
  .btn { padding: 10px 12px; }
  .receipt-row, .list-row { grid-template-columns: 1fr; }
  .qty-controls { justify-content: space-between; }
}
