:root {
  --bg: #0e1116;
  --panel: #161b22;
  --panel-2: #1f2630;
  --border: #2a313c;
  --text: #e6edf3;
  --muted: #8b96a3;
  --accent: #4ea1ff;
  --accent-2: #2563eb;
  --danger: #ef4444;
  --ok: #22c55e;
  --shadow: 0 4px 16px rgba(0,0,0,.4);
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 -apple-system,Segoe UI,Roboto,sans-serif; }
[x-cloak] { display: none !important; }
header {
  display: flex; flex-wrap: wrap; align-items: center; gap: 1rem;
  padding: .75rem 1rem; background: var(--panel); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
header h1 { margin: 0; font-size: 1.15rem; }
nav { display: flex; gap: .5rem; flex-wrap: wrap; margin-left: auto; }
nav a { color: var(--muted); text-decoration: none; padding: .35rem .7rem; border-radius: 8px; }
nav a.active, nav a:hover { color: var(--text); background: var(--panel-2); }
main { padding: 1rem; max-width: 960px; margin: 0 auto; }
section { margin-bottom: 1.5rem; }
h2 { font-size: 1rem; margin: .5rem 0; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.env-badge { font-size: .7rem; padding: .15rem .5rem; border-radius: 999px; background: var(--panel-2); color: var(--muted); margin-left: .5rem; }
.env-development { background: #5a3b1f; color: #ffd28a; }
.env-production { background: #1f3a2a; color: #86efac; }

button, .button {
  display: inline-block; background: var(--accent); color: white; border: 0;
  padding: .55rem .9rem; border-radius: 8px; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none;
}
button:hover, .button:hover { background: var(--accent-2); }
button.secondary { background: var(--panel-2); color: var(--text); }
button.danger { background: var(--danger); }
button:disabled { opacity: .4; cursor: not-allowed; }

input, select, textarea {
  width: 100%; padding: .55rem .7rem; background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; font: inherit;
}
label { display: block; margin: .5rem 0; font-size: .9rem; color: var(--muted); }
label input, label select, label textarea { margin-top: .25rem; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: .75rem; }
legend { padding: 0 .5rem; color: var(--muted); }
.search { margin-bottom: 1rem; }

.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; align-items: center; }
label.inline { display: inline-flex; align-items: center; gap: .35rem; margin: 0; }
label.inline input[type=checkbox] { width: auto; margin: 0; }
.file-btn { background: var(--panel-2); padding: .55rem .9rem; border-radius: 8px; cursor: pointer; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .6rem; }
.tile {
  display: flex; flex-direction: column; gap: .25rem; padding: 1rem .75rem;
  background: var(--panel); color: var(--text); text-align: left; min-height: 80px;
  border: 1px solid var(--border); border-radius: var(--radius);
}
.tile:hover { background: var(--panel-2); }
.tile-name { font-weight: 600; }
.tile-qty { color: var(--muted); font-size: .85rem; }

.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center;
  padding: 1rem; z-index: 100;
}
.modal-body { background: var(--panel); padding: 1.25rem; border-radius: var(--radius); max-width: 500px; width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow); }
.modal-body .actions { display: flex; gap: .5rem; margin-top: 1rem; }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .5rem .6rem; border-bottom: 1px solid var(--border); text-align: left; }
th { color: var(--muted); font-weight: 500; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: .6rem; }
.kpis div { background: var(--panel); padding: .75rem; border-radius: var(--radius); }
.kpis .label { display: block; color: var(--muted); font-size: .8rem; }
.kpis .value { display: block; font-size: 1.4rem; font-weight: 600; }

.active-event { background: #1f3a2a; padding: .6rem 1rem; border-radius: var(--radius); margin-bottom: .5rem; }
.no-event { background: #3a2a1f; padding: .6rem 1rem; border-radius: var(--radius); margin-bottom: .5rem; }
.active-event small, .no-event small { color: var(--muted); display: block; }

.toast { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); background: var(--ok); color: white; padding: .6rem 1rem; border-radius: 8px; box-shadow: var(--shadow); z-index: 200; }
.err { color: var(--danger); }
.ok { color: var(--ok); }
.warn { color: #f59e0b; }
.muted { color: var(--muted); }
.badge-display { display: inline-block; padding: .1rem .4rem; border-radius: 4px; background: #1e3a5f; color: #93c5fd; font-size: .8rem; margin-left: .25rem; }
.badge-damaged { display: inline-block; padding: .1rem .4rem; border-radius: 4px; background: #4a1f1f; color: #fca5a5; font-size: .8rem; margin-left: .25rem; }
.tile-qty { display: flex; flex-wrap: wrap; gap: .25rem; align-items: center; color: var(--muted); font-size: .85rem; }
.badge-cart { display: inline-block; padding: .1rem .4rem; border-radius: 4px; background: #1f3a2a; color: #86efac; font-size: .8rem; margin-left: .25rem; font-weight: 600; }

.cart-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--panel); border-top: 1px solid var(--border);
  padding: .75rem 1rem; display: flex; gap: 1rem; align-items: center; justify-content: space-between;
  box-shadow: 0 -4px 16px rgba(0,0,0,.3); z-index: 50;
}
.cart-summary { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.deal-tag { display: inline-block; background: var(--accent); color: white; padding: .15rem .5rem; border-radius: 4px; font-size: .75rem; font-weight: 700; }
body.has-cart-open { padding-bottom: 0; }
body main { padding-bottom: 5rem; }

.cart-panel {
  position: fixed; bottom: 0; left: 0; right: 0; top: 0;
  background: rgba(0,0,0,.5); z-index: 60; display: flex; align-items: flex-end; justify-content: center;
  padding: 1rem;
}
.cart-panel-body {
  background: var(--panel); border-radius: var(--radius) var(--radius) 0 0;
  padding: 1.25rem; max-width: 700px; width: 100%; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow);
}
.cart-table th, .cart-table td { padding: .35rem .4rem; vertical-align: middle; }
.cart-table .warn-row { background: #3a2a1f; }
.cart-totals { display: flex; gap: 1rem; padding: .75rem 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin: .75rem 0; flex-wrap: wrap; }
.cart-totals div { display: flex; gap: .5rem; align-items: baseline; }
.cart-totals strong { font-size: 1.2rem; }

.pending-order {
  background: var(--panel); border-left: 3px solid var(--accent);
  padding: .75rem 1rem; border-radius: 8px; margin-bottom: .75rem;
}
.pending-order-head { display: flex; gap: 1rem; flex-wrap: wrap; align-items: baseline; margin-bottom: .35rem; }
.pending-order details { margin: .35rem 0; }
.pending-order details summary { cursor: pointer; color: var(--muted); }
.pending-order ul { margin: .35rem 0; padding-left: 1.25rem; }
.pending-order .actions { margin-top: .5rem; display: flex; gap: .5rem; }

body.login { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
body.login main { max-width: 360px; width: 100%; padding: 2rem; background: var(--panel); border-radius: var(--radius); }
body.login h1 { text-align: center; }
body.login button { width: 100%; margin-top: .5rem; }

@media (max-width: 600px) {
  header h1 { font-size: 1rem; width: 100%; }
  nav { width: 100%; overflow-x: auto; }
  .toolbar > * { flex: 1 1 auto; }
}
