* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  max-width: 100vw;
}
html, body, button, input, select, textarea, table {
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Roboto", "Helvetica Neue", Arial, sans-serif;
}
body {
  color: #eee;
  background: #0d0d0f;
  min-height: 100vh;
  min-height: 100dvh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: #ff4500; text-decoration: none; }

.boot { padding: 48px 20px; text-align: center; color: #aaa; }

.login {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: #0d0d0f;
}
.login-card {
  width: min(400px, 100%);
  margin: 0;
  padding: 28px 22px;
  background: #141416;
  border: 1px solid #ff450044;
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}
.login-card h1, .login-card h2 { text-align: center; }
.login-card h1 {
  margin: 0 0 6px;
  color: #ff4500;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
}
.login-card h2 {
  margin: 0 0 18px;
  color: #eee;
  font-size: 1.05rem;
  font-weight: 600;
}
.login-card label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: #eee;
  font-size: 14px;
  font-weight: 600;
}
.login-card .btn { width: 100%; margin-top: 8px; }

.app { min-height: 100vh; min-height: 100dvh; max-width: 100vw; overflow-x: hidden; }
.site-head { position: sticky; top: 0; z-index: 30; max-width: 100%; }
.main, .content { min-width: 0; max-width: 100%; overflow-x: hidden; }
.mhead { display: none; }
#titlebar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  background: #1a1a1a;
  color: #fff;
  padding: 3px 10px;
  font-size: 13px;
  border-bottom: 3px solid #ff4500;
}
#titlebar .ttl {
  background: none;
  border: 0;
  font-weight: 700;
  color: #ff4500;
  white-space: nowrap;
  font-size: 13px;
  padding: 0;
  min-height: 0;
  height: auto;
  width: auto;
}
#tmenu { display: flex; gap: 1px; justify-content: center; flex-wrap: nowrap; min-width: 0; }
#tmenu .mi { font-size: 12.5px; white-space: nowrap; }
#titlebar .tright { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
#titlebar .tu { color: #eee; font-weight: 600; }
#titlebar .tu::first-letter { color: #28a745; }
#titlebar .badge { background: #ff4500; color: #111; border-radius: 10px; padding: 2px 8px; font-size: 10px; font-weight: 800; }
#titlebar .mi, #titlebar .logout-btn {
  background: none;
  border: 0;
  color: #eee;
  padding: 5px 7px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  width: auto;
  height: auto;
  min-height: 0;
  line-height: 1.3;
}
#titlebar .logout-btn,
.drawer-user .logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
#titlebar .logout-btn svg,
.drawer-user .logout-btn svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  display: block;
}
#titlebar .mi small { font-size: 9px; opacity: 0.7; }
#titlebar .mi:hover, #titlebar .dd.open > .mi, #titlebar .logout-btn:hover { background: rgba(255, 255, 255, 0.15); color: #fff; }
.dd { position: relative; }
#titlebar .dd.cur > .mi, #titlebar .dd.cur > .mi:hover, #titlebar .dd.cur.open > .mi { background: #ff4500; color: #111; }
.ddm {
  display: none;
  position: absolute;
  left: 0;
  top: 100%;
  margin-top: 3px;
  min-width: 210px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  padding: 5px 0;
  z-index: 50;
}
.dd.open > .ddm { display: block; }
.ddm button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 8px 16px;
  color: #222;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  min-height: 0;
  height: auto;
  border-radius: 0;
}
.ddm button:hover { background: #fff1eb; color: #000; }
.ddm button.on { font-weight: 700; color: #ff4500; background: #fff1eb; }
#ribbon {
  background: #0d0d0f;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 2px;
  padding: 4px 8px;
  border-bottom: 1px solid #222;
}
#ribbon .rb {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 66px;
  padding: 3px 8px;
  border-radius: 4px;
  color: #ddd;
  border: 1px solid transparent;
  background: none;
  font-size: 12px;
  min-height: 0;
  height: auto;
  width: auto;
}
#ribbon .rb:hover, #ribbon .rb.on { background: #2a140c; border-color: #ff4500; color: #ff4500; }
#ribbon i { font-style: normal; font-size: 18px; line-height: 1; }
#ribbon small { font-size: 11.5px; color: inherit; text-align: center; white-space: nowrap; }
#ribbon .sep { width: 1px; background: #333; margin: 2px 6px; }
#titlebar .clock, .mhead .clock { color: #ccc; font-size: 12px; }
.wordmark {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 0;
  padding: 0;
  color: #fff;
  min-height: 0;
  height: auto;
  width: auto;
}
.wordmark strong { font-size: 17px; font-weight: 700; color: #fff; }
.wordmark span { color: #ff4500; }
.menu-btn {
  display: none;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  background: none;
  border: 0;
  color: #fff;
  padding: 0;
  min-height: 0;
}
.menu-btn svg, .bottom-nav svg { width: 22px; height: 22px; display: block; }
@media (max-width: 1400px) {
  #titlebar .tu, #titlebar .badge { display: none; }
}

.drawer { display: none; }
.scrim { display: none; }

.main { min-width: 0; max-width: 1500px; margin: 0 auto; }
.topbar { padding: 20px 3% 0; }
.topbar h1 {
  margin: 0;
  color: #eee;
  font-size: 1.45rem;
  font-weight: 700;
}
.content { padding: 14px 3% 48px; color: #eee; }
.content > h2, .panel h2 {
  margin: 18px 0 12px;
  color: #eee;
  font-size: 1.25rem;
  font-weight: 700;
}

.cards, .grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
.route-cards {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin: 12px 0 20px;
}
.route-card {
  background: #17171a;
  border: 1px solid #ff450033;
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 160px;
}
.route-card h3 {
  margin: 0;
  color: #eee;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.25;
}
.route-card .pill {
  align-self: flex-start;
}
.route-card-meta {
  margin: 0;
  color: #aaa;
  font-size: 0.85rem;
  line-height: 1.35;
}
.route-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
}
.route-card-actions .btn {
  flex: 1 1 auto;
}
.seller-report {
  width: 100%;
  max-width: 1180px;
}
.seller-pick {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  margin-bottom: 14px;
}
.seller-pick label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: #ccc;
  font-size: 13px;
  font-weight: 600;
  min-width: 0;
}
.seller-pick label:first-child {
  flex: 1 1 260px;
  max-width: 420px;
}
.seller-pick label:nth-child(2) {
  flex: 0 0 120px;
}
.seller-pick select {
  width: 100%;
  margin: 0;
}
.seller-pick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.seller-kpi {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 12px 0 18px;
}
.kpi-card {
  background: #17171a;
  border: 1px solid #ff450033;
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.kpi-label {
  color: #aaa;
  font-size: 0.82rem;
  font-weight: 600;
}
.kpi-value {
  color: #ff4500;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.2;
  word-break: break-word;
}
.kpi-value.kpi-text {
  color: #eee;
  font-size: 1.05rem;
}
.kpi-sub {
  color: #9a9a9a;
  font-size: 0.82rem;
}
.seller-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: start;
}
.seller-report .table-wrap table {
  width: 100%;
}
.seller-report .goal-cell {
  min-width: 110px;
}
.goal-bar {
  margin-top: 6px;
  height: 8px;
  background: #2a2a2e;
  border-radius: 999px;
  overflow: hidden;
}
.goal-bar > span {
  display: block;
  height: 100%;
  background: #ff4500;
  border-radius: 999px;
  max-width: 100%;
}
.card {
  background: #17171a;
  border: 1px solid #ff450033;
  border-radius: 10px;
  padding: 16px;
  text-align: center;
  box-shadow: none;
}
.card h3, .card span {
  display: block;
  margin: 0;
  color: #eee;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}
.card .price, .card strong {
  display: block;
  margin: 10px 0 0;
  color: #ff4500;
  font-size: 1.35rem;
  font-weight: 700;
}
.panel {
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
  margin-top: 8px;
}
.notice, .msg {
  background: #2a1508;
  border: 0;
  border-left: 3px solid #ff4500;
  color: #eee;
  border-radius: 0;
  padding: 10px 12px;
  margin-bottom: 14px;
}

.table-wrap { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; min-width: 0; }
td, th {
  padding: 8px;
  border-bottom: 1px solid #333;
  text-align: left;
  vertical-align: middle;
  color: #eee;
  background: transparent;
}
th { color: #ff4500; font-size: 13px; font-weight: 700; letter-spacing: 0; text-transform: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:hover td { background: #16161a; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

.btn, .cta-new {
  background: #ff4500;
  color: #111;
  border: 0;
  padding: 0 18px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  height: 40px;
  line-height: 1;
  width: auto;
}
.btn:hover { filter: brightness(1.08); }
.cta-new {
  color: #fff;
  border-radius: 12px;
  padding: 0 18px;
  margin: 0 0 14px;
  box-shadow: 0 6px 16px rgba(255, 69, 0, 0.3);
  font-size: 15px;
}
.btn.ghost {
  background: transparent;
  color: #ff4500;
  border: 1px solid #ff4500;
}
.btn.ghost:hover { background: #2a140c; color: #ff4500; }
.btn.danger { background: #dc3545; color: #fff; }
.btn.small { min-height: 32px; height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.stack { display: grid; gap: 12px; }
input, select, textarea,
.toolbar input, .toolbar select, .form-grid input, .form-grid select, .form-grid textarea,
.lines input, .lines select, .stack input, .stack select, .stack textarea {
  width: 100%;
  padding: 9px;
  margin: 4px 0 0;
  background: #1b1b1f;
  color: #eee;
  border: 1px solid #444;
  border-radius: 5px;
  min-height: 40px;
}
textarea { min-height: 80px; }
input::placeholder, textarea::placeholder { color: #8a8a8e; }
select option { background: #1b1b1f; color: #eee; }
input:focus, select:focus, textarea:focus { outline: none; border-color: #ff4500; }
.toolbar input, .toolbar select { width: auto; flex: 1 1 180px; margin: 0; }
.toolbar .btn, .form-actions .btn, .row-actions .btn { width: auto; flex: 0 0 auto; }
.grow { flex: 1; min-width: 180px; }

.pill { display: inline-flex; border-radius: 999px; padding: 3px 8px; font-size: 12px; background: #222; color: #ddd; }
.pill.ok { background: #12301c; color: #3ddc84; }
.pill.bad { background: #3a1212; color: #ff8a8a; }
.pill.warn { background: #3a2a08; color: #ffc14d; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid label, .stack label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: #eee;
  font-weight: 600;
}
.form-grid .wide { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; grid-column: 1 / -1; }
.check { flex-direction: row !important; align-items: center; color: #eee !important; }
.check input { width: auto; min-height: 0; margin: 0; }

.lines { width: 100%; min-width: 0; }
#lines { width: 100%; min-width: 0; }
.line {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 8px 10px;
  border: 1px solid #333;
  border-radius: 12px;
  background: #0d0d0f;
  min-width: 0;
}
.line strong {
  color: #fff;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.line input { margin: 0; }
.line .qty-step { flex: 0 0 auto; }
.line .line-price {
  width: 96px;
  flex: 0 0 96px;
  min-width: 0;
  height: 40px;
  min-height: 40px;
}
.line .line-disc {
  width: 72px;
  flex: 0 0 72px;
  min-width: 0;
  height: 40px;
  min-height: 40px;
}
.line-remove {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  min-height: 32px;
  margin: 0;
  padding: 0;
  border-radius: 8px;
  border: 1px solid #444;
  background: transparent;
  color: #ff4500;
  font-size: 1.2rem;
  line-height: 1;
}
.buy-line {
  grid-template-columns: 1.4fr minmax(140px, 160px) 120px 40px;
}
#buy-lines.lines {
  display: grid;
  gap: 8px;
  margin: 4px 0 8px;
}
.buy-row {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid #2a2a2e;
  border-radius: 12px;
  background: #101012;
}
.buy-row-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.buy-row-top strong {
  color: #fff;
  font-size: 0.95rem;
  line-height: 1.3;
  flex: 1;
  min-width: 0;
}
.buy-remove {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  min-height: 32px;
  border-radius: 8px;
  border: 1px solid #444;
  background: transparent;
  color: #ff4500;
  font-size: 1.2rem;
  line-height: 1;
  padding: 0;
}
.buy-row-controls {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: end;
}
.buy-cost {
  display: grid;
  gap: 4px;
  margin: 0;
  color: #9a9a9a;
  font-size: 0.75rem;
}
.buy-cost input {
  margin: 0;
  height: 40px;
  min-height: 40px;
}
.qty-step {
  display: inline-grid;
  grid-template-columns: 40px minmax(48px, 64px) 40px;
  gap: 0;
  align-items: center;
  border: 1px solid #333;
  border-radius: 10px;
  overflow: hidden;
  background: #17171a;
  width: max-content;
}
.qty-step input {
  text-align: center;
  min-width: 0;
  width: 100%;
  height: 40px;
  min-height: 40px;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: #0d0d0f;
  color: #fff;
}
.qty-step button {
  width: 40px;
  min-width: 40px;
  height: 40px;
  min-height: 40px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #17171a;
  color: #ff4500;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
}
.qty-step button + input,
.qty-step input + button {
  border-left: 1px solid #333;
}
.purchase-form .muted { color: #9a9a9a; margin: 8px 0; }
.purchase-form .form-grid { padding: 0; }
.purchase-form .hits {
  max-height: 160px;
  overflow: auto;
  margin: 0 0 8px;
  padding: 0;
  border: 0;
  background: transparent;
}
.purchase-form .hit {
  min-height: 44px;
  padding: 8px 10px;
  border-radius: 10px;
  border-color: #2a2a2e;
}
.totals { margin-left: auto; width: min(320px, 100%); }
.totals div { display: flex; justify-content: space-between; padding: 4px 0; }
.totals .grand { font-size: 1.6rem; font-weight: 700; border-top: 2px solid #ff4500; margin-top: 6px; padding-top: 8px; color: #ff4500; }

.modules { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.mod, .hit {
  background: #17171a;
  border: 1px solid #333;
  border-radius: 12px;
  color: #eee;
  font-weight: 600;
  min-height: 44px;
}
.mod { padding: 14px 10px; }
.mod:hover, .hit:hover { border-color: #ff4500; color: #fff; }
.hits { display: grid; gap: 6px; margin: 8px 0 12px; }
/* En celular las filas van en display:block; hace falta !important para ocultar el filtro. */
.table-wrap tbody tr.search-miss,
.table-wrap tbody tr[hidden],
tr.search-miss {
  display: none !important;
}
.hit {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  text-align: left;
  padding: 10px 12px;
  width: 100%;
  height: auto;
}
.hit small { display: block; color: #aaa; font-weight: 500; font-size: 13px; }
.hit b { white-space: nowrap; color: #ff4500; }
.print-actions { display: grid; gap: 8px; }
.print-actions .btn { width: 100%; }
.print-actions p, .print-actions a { font-size: 14px; }
.receipt-preview {
  padding: 8px 20px 4px;
  display: grid;
  gap: 8px;
}
.receipt-preview h3 {
  margin: 8px 0 0;
  color: #ff4500;
  font-size: 1rem;
}
.receipt-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding: 8px 0;
  border-bottom: 1px solid #2a2a2a;
}
.receipt-row strong { color: #fff; white-space: nowrap; }
.receipt-row.grand {
  border-bottom: 0;
  border-top: 2px solid #ff4500;
  margin-top: 4px;
  padding-top: 12px;
  color: #ff4500;
}
.receipt-row.grand strong { color: #ff4500; font-size: 1.2rem; }
.receipt-row small { color: #aaa; }
.modal-error {
  margin: 0 20px 8px;
  padding: 10px 12px;
  background: #3a1212;
  border-left: 3px solid #dc3545;
  color: #ffb4b4;
  border-radius: 0 8px 8px 0;
  font-size: 14px;
}
.stops { display: grid; gap: 10px; }
.stop {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border-radius: 12px;
  background: #17171a;
  border: 1px solid #ff450033;
  text-align: left;
}
.stop strong { display: block; color: #fff; }
.stop span { color: #aaa; font-size: 14px; }
.lede { color: #aaa; }

#modal[hidden] { display: none !important; }
#modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 48px;
}
.modal-back { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.72); }
.modal-card {
  position: relative;
  z-index: 1;
  width: min(720px, calc(100vw - 96px));
  margin: 0;
  background: #141416;
  color: #eee;
  border: 1px solid #ff4500;
  border-radius: 18px;
  padding: 8px 12px 16px;
  max-height: min(84vh, 860px);
  overflow: auto;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  animation: modal-pop 0.2s ease;
}
@keyframes modal-pop {
  from { transform: translateY(12px) scale(0.98); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes modal-up {
  from { transform: translateY(28px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.modal-card h2 {
  margin: 0;
  padding: 16px 20px 0;
  background: transparent;
  color: #ff4500;
  font-size: 1.25rem;
  border: 0;
}
.modal-card form, .modal-card .stack, .modal-card > p, .modal-card .print-actions { padding: 16px 20px 20px; }
.modal-card .form-actions { padding-bottom: 0; }
.modal-card.modal-wide { width: min(1080px, calc(100vw - 48px)); }
.modal-card.modal-user {
  max-height: min(94vh, 820px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 4px 8px 10px;
}
.modal-card.modal-user h2 {
  padding: 10px 16px 0;
  font-size: 1.15rem;
  flex: 0 0 auto;
}
.modal-card.modal-user .user-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 16px 12px;
  min-height: 0;
  overflow: hidden;
  flex: 1 1 auto;
}
.user-fields {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr 0.9fr auto;
  gap: 8px 10px;
  align-items: end;
  flex: 0 0 auto;
}
.user-fields label {
  display: grid;
  gap: 4px;
  color: #cfcfcf;
  font-size: 0.82rem;
  margin: 0;
}
.user-fields input,
.user-fields select {
  height: 36px;
  min-height: 36px;
  border-radius: 8px;
  font-size: 0.92rem;
}
.user-fields .user-active {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding-bottom: 2px;
  white-space: nowrap;
}
.perm-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 0;
  flex: 0 0 auto;
}
.perm-title {
  color: #ff4500;
  font-weight: 700;
  margin-right: 4px;
  font-size: 0.95rem;
}
.perm-toolbar .btn.small {
  height: 30px;
  min-height: 30px;
  padding: 0 10px;
  font-size: 0.8rem;
}
.perm-list {
  margin: 0;
  padding: 8px 10px;
  overflow: hidden;
  border: 1px solid #2a2a2e;
  border-radius: 10px;
  background: #0d0d0f;
  display: grid;
  grid-template-columns: 1.15fr 1.15fr 0.7fr;
  gap: 8px 14px;
  flex: 1 1 auto;
  min-height: 0;
  align-content: start;
}
.perm-group {
  min-width: 0;
}
.perm-group h3 {
  margin: 0 0 4px;
  color: #ff4500;
  font-size: 0.82rem;
  font-weight: 700;
}
.perm-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 2px 0;
  border: 0;
  color: #eee;
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1.25;
  min-height: 0;
}
.perm-item input {
  margin: 0;
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
}
.perm-item span {
  line-height: 1.25;
}
.modal-card.modal-user .form-actions {
  margin-top: 2px;
  padding: 0;
  flex: 0 0 auto;
}
@media (max-height: 760px) and (min-width: 801px) {
  .modal-card.modal-user h2 { padding-top: 6px; font-size: 1.05rem; }
  .modal-card.modal-user .user-form { padding-top: 6px; gap: 6px; }
  .user-fields input,
  .user-fields select { height: 32px; min-height: 32px; }
  .perm-item { font-size: 0.74rem; padding: 1px 0; }
  .perm-group h3 { font-size: 0.76rem; margin-bottom: 2px; }
  .perm-list { padding: 6px 8px; gap: 6px 10px; }
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: #141416;
  color: #fff;
  border: 1px solid #ff4500;
  padding: 12px 16px;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
  z-index: 120;
  max-width: min(520px, calc(100vw - 24px));
  text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.bad { background: #3a1212; border-color: #dc3545; }

.bottom-nav { display: none; }

@media (max-width: 1400px) {
  .route-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 1100px) {
  .cards, .grid { grid-template-columns: 1fr 1fr; }
  .route-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .seller-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .seller-split { grid-template-columns: 1fr; }
}

@media (max-width: 800px) {
  .route-cards { grid-template-columns: 1fr 1fr; }
  .seller-kpi { grid-template-columns: 1fr 1fr; }
  .seller-split { grid-template-columns: 1fr; }
  .seller-pick label:first-child,
  .seller-pick label:nth-child(2) {
    flex: 1 1 100%;
    max-width: none;
  }
  .seller-pick-actions {
    width: 100%;
  }
  .seller-pick-actions .btn {
    flex: 1 1 auto;
  }

  .pc-menu { display: none; }
  .mhead {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 8px;
    background: #1a1a1a;
    color: #fff;
    padding: 8px 12px;
    min-height: 48px;
    border-bottom: 2px solid #ff4500;
  }
  .menu-btn { display: inline-flex; }
  .wordmark strong { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; max-width: 52vw; }
  .mhead .clock { font-size: 11px; white-space: nowrap; }
  .topbar, .content { padding-left: 12px; padding-right: 12px; }
  .content { padding-bottom: 110px; }
  .topbar { padding-top: 14px; }
  .topbar h1 { font-size: 1.25rem; overflow-wrap: anywhere; }
  .cards, .grid, .modules { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .cta-new { display: flex; width: 100%; height: 48px; border-radius: 12px; font-size: 17px; }
  .toolbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    align-items: stretch;
  }
  .toolbar input, .toolbar select, .toolbar .grow {
    width: 100%;
    min-width: 0;
    flex: none;
  }
  .toolbar .btn, .content > .btn, .panel .btn, .row-actions .btn {
    width: 100%;
    min-height: 44px;
    height: 44px;
    border-radius: 12px;
    font-size: 15px;
  }
  .toolbar .btn.small, .row-actions .btn.small {
    min-height: 40px;
    height: 40px;
  }
  .form-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .form-actions .btn { width: 100%; min-height: 48px; height: 48px; border-radius: 12px; }
  .row-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    justify-content: stretch;
    width: 100%;
  }
  .line {
    gap: 6px;
    padding: 8px;
  }
  .line .line-price {
    width: 80px;
    flex: 0 0 80px;
  }
  .line .line-disc {
    width: 56px;
    flex: 0 0 56px;
  }
  .line-remove {
    width: 36px;
    height: 36px;
    min-height: 36px;
  }
  .buy-row {
    padding: 10px;
    margin: 0;
    border: 1px solid #2a2a2e;
    border-radius: 12px;
    box-shadow: none;
  }
  .buy-row-controls {
    grid-template-columns: auto 1fr;
    gap: 8px;
  }
  .buy-remove {
    width: 36px;
    height: 36px;
    min-height: 36px;
  }
  .qty-step {
    grid-template-columns: 44px minmax(52px, 70px) 44px;
  }
  .qty-step input,
  .qty-step button {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
  }
  .qty-step input { width: 100%; min-width: 52px; }
  .purchase-form .hit {
    display: flex;
    width: 100%;
  }
  .modal-card.modal-wide .purchase-form {
    padding-left: 12px;
    padding-right: 12px;
  }
  .purchase-form #buy-lines {
    padding: 0;
    border: 0;
    background: transparent;
  }
  .totals { width: 100%; margin-left: 0; }
  .stop { flex-direction: column; align-items: stretch; }
  .stop .row-actions { margin-top: 8px; }
  .table-wrap { overflow: visible; }
  .table-wrap table,
  .table-wrap thead,
  .table-wrap tbody,
  .table-wrap th,
  .table-wrap td,
  .table-wrap tr { display: block; width: 100%; min-width: 0; }
  .table-wrap thead { display: none; }
  .table-wrap tbody tr {
    background: #17171a;
    border: 1px solid #ff450033;
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 10px;
  }
  .table-wrap tbody tr.search-miss,
  .table-wrap tbody tr[hidden] {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
  }
  .hits { margin-bottom: 16px; }
  .hit {
    min-height: 52px;
    padding: 12px 14px;
    -webkit-tap-highlight-color: transparent;
  }
  .table-wrap tbody tr:hover td { background: transparent; }
  .table-wrap td {
    border: 0;
    padding: 5px 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    text-align: right;
    overflow-wrap: anywhere;
  }
  .table-wrap td::before {
    content: attr(data-label);
    color: #aaa;
    font-weight: 600;
    text-align: left;
    flex: 0 1 42%;
  }
  .table-wrap td:empty { display: none; }
  .table-wrap td.num { text-align: right; }
  .table-wrap .row-actions {
    display: grid;
    width: 100%;
  }
  .table-wrap td:has(.row-actions),
  .table-wrap td:has(.btn) {
    display: block;
    text-align: left;
  }
  .table-wrap td:has(.row-actions)::before,
  .table-wrap td:has(.btn)::before { display: none; }
  .hit b { white-space: normal; }
  .card { min-width: 0; }
  .card .price, .card strong { font-size: 1.15rem; overflow-wrap: anywhere; }
  .drawer {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 50;
    padding: max(12px, env(safe-area-inset-top)) 8px calc(66px + env(safe-area-inset-bottom));
    background: rgba(0, 0, 0, 0.6);
    border: 0;
    transform: none;
    width: auto;
    height: auto;
  }
  .drawer.open { display: block; }
  .drawer-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 100%;
    background: #1a1a1a;
    color: #eee;
    border: 1px solid #ff4500;
    border-radius: 16px;
    padding: 12px;
    overflow: hidden;
  }
  .scrim { display: none !important; }
  .drawer-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2px 4px 12px;
    border-bottom: 1px solid #333;
    flex-shrink: 0;
  }
  .drawer-top strong { font-size: 18px; color: #fff; font-weight: 700; }
  .drawer-close {
    background: transparent;
    border: 1px solid #ff4500;
    color: #ff4500;
    width: 36px;
    height: 36px;
    min-height: 36px;
    padding: 0;
    border-radius: 999px;
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
  }
  .drawer .nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    overflow: auto;
    align-content: start;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 10px 0 8px;
    flex: 1;
  }
  .drawer .group {
    grid-column: 1 / -1;
    margin: 6px 2px 0;
    color: #ff4500;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
  }
  .drawer .group:first-child { margin-top: 0; }
  .drawer .nav button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: #222;
    color: #eee;
    text-align: center;
    border: 1px solid #333;
    border-radius: 12px;
    padding: 12px 8px;
    min-height: 78px;
    height: auto;
    width: auto;
    font-size: 14px;
    font-weight: 600;
  }
  .drawer .nav button i { font-style: normal; font-size: 24px; line-height: 1; }
  .drawer .nav button span { line-height: 1.2; }
  .drawer .nav button.active { color: #ff4500; border-color: #ff4500; }
  .drawer-user {
    margin-top: auto;
    padding: 12px 4px 2px;
    border-top: 1px solid #ff4500;
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
  }
  .drawer-user b { color: #fff; }
  .drawer-user small { display: block; color: #9a9a9a; }
  .drawer-user .logout-btn {
    color: #ff4500;
    background: transparent;
    border: 1px solid #ff4500;
    border-radius: 999px;
    min-height: 36px;
    height: 36px;
    padding: 0 14px;
    width: auto;
  }
  .bottom-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: #1a1a1a;
    border-top: 2px solid #ff4500;
    z-index: 20;
    padding: 4px 2px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: transparent;
    border: 0;
    color: #aaa;
    padding: 6px 2px;
    min-height: 54px;
    height: auto;
    width: auto;
    font-size: 11px;
    font-weight: 600;
    border-radius: 0;
  }
  .bottom-nav button i { font-style: normal; font-size: 20px; line-height: 1; }
  .bottom-nav button.active { color: #ff4500; }
  #toast { bottom: 84px; left: 12px; right: 12px; width: auto; transform: translateY(20px); }
  #toast.show { transform: translateY(0); }
  #modal { align-items: flex-end; padding: 0; }
  .modal-card {
    width: 100%;
    max-width: 100%;
    max-height: min(92vh, 860px);
    border-radius: 18px 18px 0 0;
    padding: 6px 4px calc(12px + env(safe-area-inset-bottom));
    animation: modal-up 0.22s ease;
  }
  .modal-card input:not([type=checkbox]), .modal-card select { height: 46px; min-height: 46px; border-radius: 10px; }
  .modal-card textarea { min-height: 96px; border-radius: 10px; }
  .modal-card .form-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .modal-card .print-actions { display: grid; grid-template-columns: 1fr; gap: 10px; }
  .modal-card .form-actions .btn, .modal-card .print-actions .btn { width: 100%; height: 48px; min-height: 48px; border-radius: 12px; }
  .modal-card h2 { padding: 14px 16px 0; font-size: 1.15rem; }
  .modal-card form, .modal-card .stack, .modal-card > p, .modal-card .print-actions { padding: 12px 16px 16px; }
  .modal-card.modal-wide,
  .modal-card.modal-user { width: 100%; max-width: 100%; }
  .modal-card.modal-user {
    max-height: min(92vh, 860px);
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }
  .modal-card.modal-user .user-form { padding: 8px 14px 12px; gap: 8px; }
  .user-fields {
    grid-template-columns: 1fr 1fr;
  }
  .user-fields label:nth-child(3),
  .user-fields label:nth-child(4) { grid-column: span 1; }
  .user-fields .user-active {
    grid-column: 1 / -1;
    height: auto;
    min-height: 40px;
  }
  .user-fields input,
  .user-fields select { height: 42px; min-height: 42px; }
  .perm-list {
    grid-template-columns: 1fr 1fr;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    max-height: none;
  }
  .perm-group:last-child { grid-column: 1 / -1; }
  .perm-item { min-height: 34px; font-size: 0.84rem; }
  .perm-item input { width: 16px; height: 16px; }
}

@media (max-width: 520px) {
  .seller-kpi { grid-template-columns: 1fr; }
}
