:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-subtle: #fafbfd;
  --chip-bg: #f1f2f6;
  --border: #e2e6f0;
  --border-strong: #cdd5e0;
  --text: #1f2430;
  --text-muted: #6b7280;
  --primary: #2c5c8c;
  --primary-hover: #234c74;
  --accent: #c7791a;
  --accent-bg: #fbecd6;
  --ok: #2e7d57;
  --ok-bg: #d6efe2;
  --warn: #b7791f;
  --warn-bg: #fbecd6;
  --danger: #bf4238;
  --danger-bg: #f7ddda;
  --radius: 10px;
  --shadow: rgba(15, 18, 30, 0.08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1721; --surface: #17222f; --surface-subtle: #1e2b39; --chip-bg: #22303f;
    --border: #263644; --border-strong: #37495a; --text: #e6ecf2; --text-muted: #93a1ae;
    --primary: #6ea3d2; --primary-hover: #8bb8de; --accent: #e0a23c; --accent-bg: #3a2e18;
    --ok: #52b487; --ok-bg: #163a2b; --warn: #e0a23c; --warn-bg: #3a2e18;
    --danger: #e0685e; --danger-bg: #3a211e; --shadow: rgba(0, 0, 0, 0.35);
  }
}
:root[data-theme="dark"] {
  --bg: #0f1721; --surface: #17222f; --surface-subtle: #1e2b39; --chip-bg: #22303f;
  --border: #263644; --border-strong: #37495a; --text: #e6ecf2; --text-muted: #93a1ae;
  --primary: #6ea3d2; --primary-hover: #8bb8de; --accent: #e0a23c; --accent-bg: #3a2e18;
  --ok: #52b487; --ok-bg: #163a2b; --warn: #e0a23c; --warn-bg: #3a2e18;
  --danger: #e0685e; --danger-bg: #3a211e; --shadow: rgba(0, 0, 0, 0.35);
}
:root[data-theme="light"] {
  --bg: #f4f6fb; --surface: #ffffff; --surface-subtle: #fafbfd; --chip-bg: #f1f2f6;
  --border: #e2e6f0; --border-strong: #cdd5e0; --text: #1f2430; --text-muted: #6b7280;
  --primary: #2c5c8c; --primary-hover: #234c74; --accent: #c7791a; --accent-bg: #fbecd6;
  --ok: #2e7d57; --ok-bg: #d6efe2; --warn: #b7791f; --warn-bg: #fbecd6;
  --danger: #bf4238; --danger-bg: #f7ddda; --shadow: rgba(15, 18, 30, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 4px 0; }
h3 { margin: 0 0 8px; }
.muted { color: var(--text-muted); }
.small { font-size: 13px; }
.mono { font-family: "Cascadia Mono", Consolas, ui-monospace, monospace; font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.ok-text { color: var(--ok); }
.danger-text { color: var(--danger); }

/* ---- navbar ---- */
.navbar {
  display: flex; align-items: center; gap: 24px;
  padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.navbar-brand a { font-weight: 700; font-size: 17px; color: var(--text); }
.navbar-links { display: flex; gap: 18px; flex: 1; }
.navbar-links a { color: var(--text-muted); font-weight: 500; }
.navbar-user { display: flex; align-items: center; gap: 12px; color: var(--text-muted); font-size: 14px; }
.role-tag {
  display: inline-block; background: var(--accent-bg); color: var(--accent);
  font-size: 10px; font-weight: 700; text-transform: uppercase; padding: 2px 6px; border-radius: 999px;
}
.theme-toggle, .link-button {
  background: none; border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; color: var(--text-muted); padding: 5px 9px; font-size: 14px;
}
.theme-toggle:hover, .link-button:hover { background: var(--chip-bg); }

/* ---- shell unificado: barra superior (sistemas) + sidebar (módulo) ---- */
.topbar { display: flex; align-items: center; gap: 20px; padding: 10px 20px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; flex-wrap: wrap; }
.topbar-brand { font-weight: 700; font-size: 16px; white-space: nowrap; }
.topbar-sys { display: flex; gap: 6px; flex-wrap: wrap; }
.topbar-sys a { padding: 7px 14px; border-radius: 8px; color: var(--text-muted); font-weight: 600; }
.topbar-sys a:hover { background: var(--chip-bg); text-decoration: none; }
.topbar-sys a.active { background: var(--primary); color: #fff; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--text-muted); font-size: 14px; }
.topbar-link { color: var(--text-muted); font-weight: 600; }
.topbar-user { white-space: nowrap; }

.shell { display: flex; align-items: flex-start; }
.sidebar { flex: 0 0 210px; width: 210px; background: var(--surface); border-right: 1px solid var(--border);
  padding: 16px 10px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 57px; align-self: stretch;
  min-height: calc(100vh - 57px); }
.sidebar a { padding: 9px 12px; border-radius: 8px; color: var(--text); font-weight: 500; }
.sidebar a:hover { background: var(--chip-bg); text-decoration: none; }
.content { flex: 1; min-width: 0; max-width: 1200px; padding: 24px 28px; }

@media (max-width: 768px) {
  .topbar { gap: 10px; padding: 8px 12px; }
  .topbar-user { display: none; }
  .shell { flex-direction: column; }
  .sidebar { position: static; width: auto; flex: none; min-height: 0; flex-flow: row wrap;
    border-right: none; border-bottom: 1px solid var(--border); padding: 8px 12px; gap: 6px; }
  .sidebar a { white-space: nowrap; }
  .content { padding: 16px 12px; max-width: none; width: 100%; }
}

/* ---- layout ---- */
.container { max-width: 1080px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { margin: 2px 0; }
.back-link { font-size: 13px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: 0 1px 2px var(--shadow); margin-bottom: 16px;
}

/* ---- botones ---- */
.btn {
  display: inline-block; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-weight: 600; font-size: 14px; cursor: pointer;
}
.btn:hover { text-decoration: none; background: var(--chip-bg); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary[disabled] { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ---- forms ---- */
.form label, .form-inline label, .compact { display: flex; flex-direction: column; gap: 5px; font-size: 14px; font-weight: 600; margin-bottom: 14px; }
.form input, .form select, .form-inline input, .compact select, select, input[type="text"], input[type="password"], input[type="file"] {
  font: inherit; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface-subtle); color: var(--text); font-weight: 400;
}
.form input:focus, .form select:focus, select:focus, input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.form-inline { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.form-inline label { margin-bottom: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 16px; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }
fieldset.radio-set { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin: 0 0 16px; }
fieldset.radio-set legend { font-weight: 600; font-size: 13px; padding: 0 6px; }
.radio { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; margin-bottom: 8px; }
.radio input { margin-top: 4px; }
.field-label { font-size: 13px; font-weight: 600; }
.inline-check { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; font-weight: 600; }

/* ---- auth ---- */
.auth-card {
  max-width: 380px; margin: 8vh auto; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 32px; box-shadow: 0 8px 30px var(--shadow); text-align: center;
}
.auth-card h1 { font-size: 22px; }
.auth-card .form { text-align: left; margin-top: 18px; }
.auth-card .btn { width: 100%; }

/* ---- alerts ---- */
.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; border: 1px solid transparent; }
.alert-success { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.alert-error { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.alert-warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }

/* ---- badges ---- */
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .02em; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-danger { background: var(--danger-bg); color: var(--danger); text-transform: none; letter-spacing: 0; font-weight: 600; }
.badge-muted { background: var(--chip-bg); color: var(--text-muted); }
.badge-accent { background: var(--accent-bg); color: var(--accent); }

/* ---- obras ---- */
.obra-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.obra-card { display: block; }
.obra-card:hover { text-decoration: none; border-color: var(--primary); }
.obra-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.obra-card h3 { color: var(--text); font-size: 16px; }
.obra-card-metric { display: flex; justify-content: space-between; align-items: baseline; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.obra-card-metric strong { font-size: 18px; font-variant-numeric: tabular-nums; }
details.newobra { padding: 0; }
details.newobra summary { cursor: pointer; padding: 14px 18px; font-weight: 600; }
details.newobra[open] summary { border-bottom: 1px solid var(--border); }
details.newobra .form, details.newobra .form-inline { padding: 16px 18px; }

/* ---- kpi row ---- */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
@media (max-width: 720px) { .kpi-row { grid-template-columns: repeat(2, 1fr); } }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.kpi-k { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 600; }
.kpi-v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12px; color: var(--text-muted); }
.kpi:first-child { border-top: 3px solid var(--primary); }

/* ---- tablas ---- */
.table-wrap { overflow-x: auto; padding: 0; }
.data-table { border-collapse: collapse; width: 100%; font-size: 14px; }
.data-table th, .data-table td { padding: 9px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table th.num, .data-table td.num { text-align: right; }
.data-table thead th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); background: var(--surface-subtle); }
.data-table tbody tr:hover { background: var(--surface-subtle); }
.data-table tfoot td { font-weight: 700; background: var(--surface-subtle); border-top: 2px solid var(--border-strong); font-variant-numeric: tabular-nums; }
.data-table.mini { margin: 12px 0; font-size: 13px; }
.data-table.mini th, .data-table.mini td { padding: 5px 10px; }
.row-bad { background: var(--danger-bg) !important; }
.row-bad td { color: var(--text); }

/* ---- grupos del informe (original / extras) ---- */
.group-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: 0 1px 2px var(--shadow); margin-bottom: 16px; }
.group-card .table-wrap { overflow-x: auto; }
/* Cabecera plegable (details/summary): click para ocultar/mostrar los materiales. */
.group-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--border); cursor: pointer; user-select: none; list-style: none; }
.group-head::-webkit-details-marker { display: none; }
.group-head:hover { background: var(--surface-subtle); }
details.group-card:not([open]) .group-head { border-bottom: none; }
.group-head h3 { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 16px; }
.group-caret { display: inline-block; color: var(--text-muted); font-size: 13px; transition: transform 0.15s ease; }
details.group-card[open] .group-caret { transform: rotate(90deg); }
.group-sub { color: var(--text-muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.group-sub strong { color: var(--text); }
.group-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 14px; }
.grand-total { display: flex; gap: 28px; justify-content: flex-end; align-items: baseline; flex-wrap: wrap; }
.grand-total strong { font-variant-numeric: tabular-nums; margin-left: 6px; }
.grand-total .gt-total strong { font-size: 18px; color: var(--primary); }

/* ---- edición de líneas ---- */
.cell-input { width: 120px; padding: 5px 8px; font: inherit; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface-subtle); color: var(--text); }
.cell-input.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

/* ---- documentos de la obra ---- */
.docs h3 { margin: 0 0 12px; }
.doc-list { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.doc-list li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--border); }
.doc-list li:last-child { border-bottom: none; }
.doc-tipo { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; padding: 2px 8px; border-radius: 999px; background: var(--chip-bg); color: var(--text-muted); }
.doc-oc_cliente { background: var(--accent-bg); color: var(--accent); }
.doc-contrato { background: var(--ok-bg); color: var(--ok); }
.doc-upload { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.doc-upload select, .doc-upload input[type="file"] { padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface-subtle); color: var(--text); font: inherit; }
.inline-form { display: inline; margin: 0; }
.inline-form .link-button { padding: 2px 8px; }

/* ---- wizard ---- */
.wizard-steps { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.wizard-steps .step { font-size: 13px; padding: 5px 12px; border-radius: 999px; background: var(--chip-bg); color: var(--text-muted); font-weight: 600; }
.wizard-steps .step.active { background: var(--primary); color: #fff; }
.wizard-steps .step.done { background: var(--ok-bg); color: var(--ok); }
.summary-bar { display: flex; flex-wrap: wrap; gap: 22px; padding: 14px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; }
.summary-bar > div { display: flex; flex-direction: column; }
.summary-bar strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.confirm-bar { display: flex; justify-content: flex-end; gap: 10px; align-items: center; margin-top: 4px; }

/* ---- chips ---- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--chip-bg); padding: 5px 10px; border-radius: 999px; font-size: 13px; font-weight: 500; cursor: pointer; }

/* ---- user list ---- */
.user-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.user-card { display: flex; flex-direction: column; gap: 12px; }
.user-card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.user-card-head .mono { margin-left: 8px; }
.user-card-body { display: flex; flex-direction: column; gap: 8px; }
.user-card-foot { display: flex; justify-content: flex-end; }
.compact { margin-bottom: 0; }

/* ---- empty ---- */
.empty-state { text-align: center; padding: 40px 20px; }
.empty-state h1, .empty-state h3 { margin-bottom: 8px; }
.empty-state .btn { margin-top: 14px; }

code { background: var(--chip-bg); padding: 1px 5px; border-radius: 4px; font-size: 13px; }

/* ================= Pedidos ================= */
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.btn-lg { padding: 13px 22px; font-size: 16px; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(0.94); }
.row-muted { opacity: 0.55; }
.card-title { margin: 0 0 12px; font-size: 16px; }
.callout { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; font-size: 14px; }

/* filtros por estado */
.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.filter-chips .chip { text-decoration: none; color: var(--text-muted); border: 1px solid transparent; }
.filter-chips .chip-on { background: var(--primary); color: #fff; }
.chip-n { background: rgba(0,0,0,0.12); border-radius: 999px; padding: 0 7px; font-size: 12px; font-weight: 700; }
.chip-on .chip-n { background: rgba(255,255,255,0.28); }

/* listado de pedidos */
.pedido-list { display: flex; flex-direction: column; gap: 10px; }
.pedido-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 1px 2px var(--shadow); }
.pedido-row:hover { border-color: var(--border-strong); }
.pedido-row-top { display: flex; align-items: center; gap: 10px; margin-bottom: 3px; }
.pedido-row-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-size: 14px; color: var(--text-muted); white-space: nowrap; }
.pedido-row-meta strong { color: var(--text); font-variant-numeric: tabular-nums; }

/* formulario de nuevo pedido (mobile-first) */
.pedido-form { padding-bottom: 84px; }
.pedido-search { position: sticky; top: 0; z-index: 5; padding: 10px 0; background: var(--bg); }
.pedido-search input { width: 100%; padding: 12px 14px; font-size: 16px; border: 1px solid var(--border-strong);
  border-radius: 10px; background: var(--surface); color: var(--text); }
.pick-group { margin-bottom: 18px; }
.pick-group-title { font-size: 14px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); margin: 0 0 8px; }
.pick-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 8px; }
.pick-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pick-name { font-weight: 600; }
.pick-row.has-qty { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }

/* stepper +/- */
.stepper { display: flex; align-items: center; gap: 0; flex: 0 0 auto; }
.stepper-btn { width: 40px; height: 40px; font-size: 22px; line-height: 1; border: 1px solid var(--border-strong);
  background: var(--surface-subtle); color: var(--text); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.stepper-btn:first-child { border-radius: 10px 0 0 10px; }
.stepper-btn:last-child { border-radius: 0 10px 10px 0; }
.stepper-input { width: 58px; height: 40px; text-align: center; font-size: 16px; border: 1px solid var(--border-strong);
  border-left: 0; border-right: 0; background: var(--surface); color: var(--text); font-variant-numeric: tabular-nums; }
.stepper-input::-webkit-outer-spin-button, .stepper-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper-input { -moz-appearance: textfield; }

.pedido-nota { margin-top: 6px; }
.pedido-nota label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.pedido-nota textarea { width: 100%; padding: 10px 12px; font: inherit; border: 1px solid var(--border-strong);
  border-radius: 10px; background: var(--surface-subtle); color: var(--text); }
.no-results { text-align: center; padding: 16px; }

/* barra fija de envío */
.pedido-submitbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; align-items: center;
  justify-content: space-between; gap: 14px; padding: 12px 18px; background: var(--surface); border-top: 1px solid var(--border);
  box-shadow: 0 -2px 10px var(--shadow); }
.submitbar-count { font-size: 14px; color: var(--text-muted); }
.pedido-submitbar .btn { flex: 0 0 auto; }

/* paneles de acción del detalle */
.panel-action { border-left: 3px solid var(--primary); }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; font-size: 13px; font-weight: 600; }
.field input, .field select, .field textarea, .inline-panel input, .inline-panel select {
  font: inherit; font-weight: 400; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface-subtle); color: var(--text); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { margin-top: 14px; display: flex; gap: 10px; justify-content: flex-end; }
.data-table tfoot td { border-top: 2px solid var(--border-strong); font-variant-numeric: tabular-nums; }

/* nota de venta (bloque dentro del detalle) */
.nota-venta { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 14px; }
.nota-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.nota-head .badge { margin-left: 8px; }
.nota-files { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.inline-panel { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }

/* filas de entrega (con adjunto de salida contable) */
.entrega-row { padding: 12px 0; border-top: 1px solid var(--border); }
.entrega-row:first-of-type { border-top: none; }
.entrega-row-head { margin-bottom: 8px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.entrega-row-fields { display: grid; grid-template-columns: 160px 1fr; gap: 12px; align-items: end; }
.entrega-row-fields .field { margin-bottom: 0; }
@media (max-width: 560px) { .entrega-row-fields { grid-template-columns: 1fr; } }

.grupo-title { margin: 22px 0 10px; font-size: 17px; }
.accent-text { color: var(--accent); font-variant-numeric: tabular-nums; }
.pick-row.sin-saldo { opacity: 0.5; }
.kpi-saldo .kpi-v { color: var(--accent); }
.kpi-perdida .kpi-v { color: var(--danger); }

/* drag & drop de archivos */
.dropzone { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; min-height: 68px; padding: 12px 14px; border: 2px dashed var(--border-strong); border-radius: 10px;
  background: var(--surface-subtle); color: var(--text-muted); cursor: pointer; text-align: center; font-size: 14px; }
.dropzone:hover { border-color: var(--primary); }
.dropzone.dz-over { border-color: var(--primary); background: var(--accent-bg); color: var(--text); }
.dropzone.has-file { border-style: solid; border-color: var(--ok); background: var(--ok-bg); }
.dz-native { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dz-info::before { content: '📎 '; }
.dropzone.has-file .dz-info { display: none; }
.dz-name { display: none; font-weight: 600; color: var(--text); word-break: break-all; }
.dropzone.has-file .dz-name { display: block; }
.dropzone.has-file .dz-name::before { content: '✓ '; color: var(--ok); }

/* matriz de permisos */
.perm-table th.perm-col, .perm-table td.perm-cell { text-align: center; white-space: nowrap; }
.perm-table .perm-admin { color: var(--text-muted); background: var(--surface-subtle); }
.perm-table .perm-cell input { width: 18px; height: 18px; cursor: pointer; }
.perm-group td { background: var(--surface-subtle); font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .pedido-row { flex-direction: row; }
}
