/* Patitas 3D · estilos del portal */
:root {
  --bg: #f4f5f9; --surface: #ffffff; --surface-2: #f1f3f8; --text: #141726; --muted: #697089;
  --border: #e3e6ee; --primary: #6c4cf5; --primary-600: #5b3ce0; --primary-soft: #efeaff;
  --ok: #138a47; --ok-soft: #e5f6ec; --warn: #b45f06; --warn-soft: #fff1dc;
  --danger: #d12f2f; --danger-soft: #fde9e9; --info: #1f63e0; --info-soft: #e7efff;
  --radius: 18px; --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(20, 23, 38, .04), 0 8px 24px rgba(20, 23, 38, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1016; --surface: #161922; --surface-2: #1e2230; --text: #eceef5; --muted: #9097ad;
    --border: #272b39; --primary: #8f78ff; --primary-600: #7d64ff; --primary-soft: #251f45;
    --ok: #3ecf7d; --ok-soft: #10281b; --warn: #f0a43a; --warn-soft: #2c2112;
    --danger: #ff6b6b; --danger-soft: #2e1616; --info: #6ea2ff; --info-soft: #14213d;
    --shadow: 0 1px 0 rgba(255, 255, 255, .03);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.5; background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; letter-spacing: -.02em; line-height: 1.2; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.1rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 600; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.code { font-family: ui-monospace, monospace; font-size: .8rem; background: var(--surface-2); padding: 2px 6px; border-radius: 6px; }

/* ---------- barra superior ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.6) blur(14px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; }
.logo {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; font-size: 18px;
  background: linear-gradient(135deg, #8b5cf6, #6c4cf5 55%, #ec4899); color: #fff;
  box-shadow: 0 4px 14px rgba(108, 76, 245, .35);
}
.who { display: flex; align-items: center; gap: 8px; }
button.avatar { border: 0; cursor: pointer; font: inherit; font-weight: 700; font-size: .85rem; }
button.avatar:hover { box-shadow: 0 0 0 3px var(--primary-soft); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: .85rem;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 20px 16px 72px; }
.hello { margin: 8px 0 20px; }
.hello p { margin: 4px 0 0; }

/* ---------- tarjetas ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.stack { display: grid; gap: 16px; }
/* que tablas largas o filas de botones no ensanchen la página en el celular */
.stack > *, .orders > *, .layout > *, .section-head > * { min-width: 0; }
.section-head > .chips { max-width: 100%; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head > * { min-width: 0; }
.card-head p { margin: 2px 0 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 12px; flex-wrap: wrap; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.kpi .label { font-size: .8rem; color: var(--muted); font-weight: 500; }
.kpi .value { font-size: 1.55rem; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.kpi.accent { background: linear-gradient(135deg, #6c4cf5, #8b5cf6 60%, #a855f7); color: #fff; border-color: transparent; }
.kpi.accent .label, .kpi.accent .sub { color: rgba(255, 255, 255, .82); }
.kpi .value.ok { color: var(--ok); }
button.kpi { text-align: left; font: inherit; color: inherit; cursor: pointer; transition: transform .15s, border-color .15s, box-shadow .15s; }
button.kpi:hover { transform: translateY(-1px); border-color: var(--primary); }
button.kpi.sel { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }

/* ---------- barra de progreso ---------- */
.bar { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin: 12px 0 8px; }
.bar > span {
  display: block; height: 100%; width: 0; border-radius: inherit;
  background: linear-gradient(90deg, #6c4cf5, #a855f7); transition: width .8s cubic-bezier(.2, .8, .2, 1);
}
.bar.done > span { background: linear-gradient(90deg, #16a34a, #22c55e); }

/* ---------- dos columnas ---------- */
.layout { display: grid; gap: 16px; align-items: start; }
@media (min-width: 900px) {
  .layout { grid-template-columns: 380px 1fr; }
  .layout > .sticky { position: sticky; top: 76px; }
}

/* ---------- formularios ---------- */
.field { display: block; margin-bottom: 14px; }
.field > span, .label-txt { display: block; font-size: .82rem; font-weight: 600; margin-bottom: 6px; }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px 13px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 76px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
input[type=file] { display: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { font-size: .8rem; color: var(--muted); margin: -4px 0 16px; }

/* ---------- botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 600;
  font-size: .92rem; padding: 10px 16px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background .15s, transform .05s, border-color .15s, opacity .15s;
}
.btn:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 6px 16px -6px var(--primary); }
.btn-primary:hover { background: var(--primary-600); border-color: var(--primary-600); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { border-color: var(--ok); filter: brightness(1.05); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: transparent; }
.btn-soft-danger { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.btn-soft-danger:hover { border-color: var(--danger); }
.btn-sm { padding: 7px 12px; font-size: .84rem; border-radius: 10px; }
.btn-block { width: 100%; padding: 13px 16px; }
.btn[aria-busy=true] { pointer-events: none; opacity: .75; }
.btn[aria-busy=true]::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor;
  border-right-color: transparent; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- control segmentado ---------- */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button {
  font: inherit; font-size: .86rem; font-weight: 600; border: 0; background: transparent; color: var(--muted);
  padding: 7px 14px; border-radius: 9px; cursor: pointer; transition: background .15s, color .15s;
}
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }
.seg.full { display: flex; }
.seg.full button { flex: 1; }

/* ---------- opciones tipo tarjeta (impresoras) ---------- */
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); gap: 8px; }
.choice { position: relative; display: block; }
.choice input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.choice span {
  display: flex; align-items: center; justify-content: center; text-align: center; min-height: 52px; height: 100%;
  border: 1.5px solid var(--border); border-radius: 12px; padding: 8px 10px; font-size: .84rem; font-weight: 600;
  background: var(--surface); transition: all .15s;
}
.choice input:checked + span { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.choice input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- zona para soltar archivos ---------- */
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center;
  padding: 22px 16px; border: 1.5px dashed color-mix(in srgb, var(--primary) 35%, var(--border)); border-radius: 14px;
  background: color-mix(in srgb, var(--primary-soft) 45%, transparent); cursor: pointer; transition: all .15s;
  margin-bottom: 14px;
}
.drop:hover, .drop.over { border-color: var(--primary); background: var(--primary-soft); }
.drop .ico { font-size: 24px; line-height: 1; margin-bottom: 4px; }
.drop strong { font-size: .9rem; word-break: break-all; }
.drop small { color: var(--muted); font-size: .78rem; }
.drop.has { border-style: solid; border-color: var(--ok); background: var(--ok-soft); }
.drop.compact { padding: 14px; flex-direction: row; gap: 10px; text-align: left; }
.drop.compact .ico { margin: 0; }

/* ---------- estados ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: .76rem; font-weight: 600;
  padding: 4px 10px; border-radius: 99px; white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.warn { --c: var(--warn); --cs: var(--warn-soft); }
.primary { --c: var(--primary); --cs: var(--primary-soft); }
.info { --c: var(--info); --cs: var(--info-soft); }
.ok { --c: var(--ok); --cs: var(--ok-soft); }
.danger { --c: var(--danger); --cs: var(--danger-soft); }
.neutral { --c: var(--text); --cs: var(--surface-2); }
.muted-st { --c: var(--muted); --cs: var(--surface-2); }
.pill { color: var(--c); background: var(--cs); }
.dot { background: var(--c); }

/* ---------- pedidos ---------- */
.orders { display: grid; gap: 12px; }
.order {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); scroll-margin-top: 90px;
}
.order.flash { animation: flash 2s ease; }
@keyframes flash { 0%, 50% { box-shadow: 0 0 0 4px var(--primary-soft); border-color: var(--primary); } }
.order-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.order-title { font-weight: 650; font-size: 1rem; }
.order-title .id { color: var(--muted); font-weight: 500; margin-right: 6px; font-variant-numeric: tabular-nums; }
.meta { display: flex; flex-wrap: wrap; gap: 2px 12px; margin-top: 4px; font-size: .83rem; color: var(--muted); }
.meta .late { color: var(--danger); font-weight: 600; }
.desc { margin: 10px 0 0; font-size: .9rem; }
.steps { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin: 14px 0 2px; }
.steps span { height: 5px; border-radius: 99px; background: var(--surface-2); }
.steps span.on { background: var(--primary); }
.steps.done span.on { background: var(--ok); }
.money { display: grid; grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); gap: 8px; margin-top: 12px; }
.money > div { background: var(--surface-2); border-radius: 12px; padding: 9px 12px; }
.money .label { display: block; font-size: .73rem; color: var(--muted); font-weight: 500; }
.money strong { font-size: 1.02rem; font-variant-numeric: tabular-nums; }
.money .hl { background: var(--ok-soft); }
.money .hl strong { color: var(--ok); }
.money .neg strong { color: var(--danger); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.callout { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 12px; font-size: .86rem; margin-top: 12px; background: var(--cs); }
.callout .tit { font-weight: 650; color: var(--c); }
.callout .row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.callout select { width: auto; padding: 6px 10px; font-size: .84rem; }
.src {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; margin-top: 10px; padding: 6px 10px;
  font-size: .83rem; background: var(--surface-2); border-radius: 10px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.disclosure { margin-top: 12px; border: 1px solid var(--border); border-radius: 14px; }
.disclosure > summary {
  list-style: none; cursor: pointer; padding: 11px 14px; font-weight: 600; font-size: .9rem;
  display: flex; justify-content: space-between; align-items: center;
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary::after { content: "▾"; color: var(--muted); transition: transform .2s; }
.disclosure[open] > summary::after { transform: rotate(180deg); }
.disclosure > .body { padding: 2px 14px 14px; }
.calc { font-size: .86rem; margin: 0 0 12px; }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); border: 1.5px dashed var(--border); border-radius: var(--radius); }
.empty .ico { font-size: 30px; display: block; margin-bottom: 6px; }

/* ---------- carga ---------- */
.skel {
  border-radius: var(--radius); min-height: 90px; border: 0;
  background: linear-gradient(90deg, var(--surface-2) 30%, color-mix(in srgb, var(--surface-2) 40%, var(--surface)) 50%, var(--surface-2) 70%);
  background-size: 300% 100%; animation: shimmer 1.3s infinite linear;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ---------- filtros ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button {
  flex: none; font: inherit; font-size: .84rem; font-weight: 600; padding: 7px 13px; border-radius: 99px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer;
}
.chips button.on { background: var(--text); color: var(--surface); border-color: var(--text); }
.chips .count { opacity: .65; margin-left: 5px; font-variant-numeric: tabular-nums; }

/* ---------- liquidación ---------- */
.rows { margin: 4px 0 14px; }
.rows > div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: .92rem; }
.rows > div span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; }
.rows > div.total { border-bottom: 0; font-size: 1.05rem; }
.rows > div.total span:last-child { color: var(--ok); font-weight: 700; }

/* ---------- impresoras ---------- */
.printer-row { padding: 14px 0; border-bottom: 1px solid var(--border); }
.printer-row:last-child { border-bottom: 0; padding-bottom: 0; }
.printer-row .grid2 { margin-top: 10px; }
.printer-row .field { margin-bottom: 0; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: .86rem; font-weight: 600; cursor: pointer; }
.switch input {
  appearance: none; -webkit-appearance: none; width: 38px; height: 22px; margin: 0; border-radius: 99px;
  background: var(--border); position: relative; cursor: pointer; transition: background .15s; flex: none;
}
.switch input::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
}
.switch input:checked { background: var(--ok); }
.switch input:checked::after { transform: translateX(16px); }

/* ---------- avisos flotantes ---------- */
#toasts {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 100;
  display: grid; gap: 8px; width: min(92vw, 420px); pointer-events: none;
}
.toast {
  padding: 12px 16px; border-radius: 14px; background: #141726; color: #fff; font-size: .9rem; font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25); opacity: 0; transform: translateY(10px); transition: all .25s;
}
.toast.in { opacity: 1; transform: none; }
.toast-ok::before { content: "✓"; color: #4ade80; font-weight: 700; margin-right: 8px; }
.toast-error { background: var(--danger); }

/* ---------- confirmaciones ---------- */
dialog.modal {
  border: 0; border-radius: 20px; padding: 0; width: min(92vw, 400px);
  background: var(--surface); color: var(--text); box-shadow: 0 24px 60px rgba(0, 0, 0, .3);
}
dialog.modal::backdrop { background: rgba(10, 12, 20, .45); backdrop-filter: blur(3px); }
.modal-body { padding: 22px; }
.modal-body p { margin: 0 0 20px; font-size: 1rem; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- login ---------- */
.login-page {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background:
    radial-gradient(1000px 600px at 0% -10%, color-mix(in srgb, #8b5cf6 22%, transparent), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, #ec4899 16%, transparent), transparent 60%),
    var(--bg);
}
.login-card { width: min(100%, 380px); padding: 28px; }
.login-card .logo { width: 52px; height: 52px; font-size: 26px; border-radius: 16px; margin: 0 auto 14px; }
.login-card h1 { text-align: center; font-size: 1.4rem; }
.login-card .muted { text-align: center; margin: 4px 0 22px; }
.error { background: var(--danger-soft); color: var(--danger); padding: 10px 12px; border-radius: 12px; font-size: .88rem; margin-bottom: 14px; font-weight: 500; }

.kpis.compact { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }

/* ---------- seguimiento público ---------- */
.track { display: grid; gap: 2px; margin-top: 6px; }
.track-step { display: flex; align-items: center; gap: 12px; padding: 7px 0; color: var(--muted); font-weight: 500; }
.track-dot {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-size: .8rem; font-weight: 700; background: var(--surface-2); color: var(--muted);
}
.track-step.done { color: var(--text); }
.track-step.done .track-dot { background: var(--ok-soft); color: var(--ok); }
.track-step.now { color: var(--primary); font-weight: 700; }
.track-step.now .track-dot { background: var(--primary); color: #fff; box-shadow: 0 0 0 5px var(--primary-soft); }

/* ---------- miniaturas, menú, cola, estadísticas ---------- */
.order-media { display: flex; gap: 14px; align-items: flex-start; }
.thumb {
  width: 72px; height: 72px; border-radius: 12px; object-fit: cover; flex: none;
  background: var(--surface-2); border: 1px solid var(--border);
}
.menu { position: relative; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px; z-index: 30; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 12px 32px rgba(0, 0, 0, .15);
}
.menu-pop button, .menu-pop a {
  display: block; width: 100%; text-align: left; font: inherit; font-size: .9rem; padding: 9px 12px;
  border: 0; background: none; color: var(--text); border-radius: 9px; cursor: pointer; text-decoration: none;
}
.menu-pop button:hover, .menu-pop a:hover { background: var(--surface-2); text-decoration: none; }
.queue-item { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.queue-item:last-child { border-bottom: 0; }
.tbl { width: 100%; border-collapse: collapse; font-size: .88rem; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { text-align: right; padding: 9px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl th { font-size: .76rem; color: var(--muted); font-weight: 600; }
.scroll-x { overflow-x: auto; }
.minibar { height: 6px; border-radius: 99px; background: var(--primary); opacity: .75; }
.viewer { width: 100%; height: min(70vh, 460px); border-radius: 14px; background: var(--surface-2); display: block; }
dialog.modal.wide { width: min(94vw, 720px); }
.modal-body h3 { margin-bottom: 14px; }
.pay-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

@media (max-width: 520px) {
  h1 { font-size: 1.35rem; }
  .topbar { padding: 10px 14px; }
  .card { padding: 16px; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpis .kpi.accent { grid-column: 1 / -1; }
  .kpi { padding: 14px; }
  .kpi .value { font-size: 1.3rem; }
  .kpis.compact { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .kpis.compact .kpi { padding: 10px 12px; }
  .kpis.compact .label { font-size: .72rem; }
}
