:root {
  --bg: #f3f5f8; --surface: #fff; --surface-soft: #f7f9fc; --surface-hover: #eef3f9;
  --text: #1f2937; --muted: #6b7280; --border: #d9e0e8;
  --header: #1b2433; --header-text: #f8fafc;
  --accent: #2563eb; --accent-soft: #e0eaff; --danger: #b91c1c; --danger-bg: #fdecec;
  --ok: #15803d; --ok-bg: #e7f6ec; --warn: #b45309; --warn-bg: #fdf3e2;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141d; --surface: #171e2a; --surface-soft: #1d2634; --surface-hover: #263244;
    --text: #e5e7eb; --muted: #aab4c3; --border: #344154; --header: #0b1018;
    --accent: #60a5fa; --accent-soft: #1e3a5f; --danger: #f87171; --danger-bg: #3b1a1a;
    --ok: #4ade80; --ok-bg: #163222; --warn: #fbbf24; --warn-bg: #3a2c12;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 10px 18px;
  padding-top: max(10px, env(safe-area-inset-top)); background: var(--header); color: var(--header-text); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 700; }
.brand-title { font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { color: #d7deea; text-decoration: none; font-weight: 600; padding: 8px 12px; border-radius: 7px; }
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a[aria-current="page"] { background: rgba(255,255,255,.14); color: #fff; }
.tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.icon-btn { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 8px; border: 1px solid #ffffff30;
  background: #ffffff10; color: #fff; cursor: pointer; }
.icon-btn svg, .ibtn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.company-select { width: auto; max-width: 220px; background: #ffffff10; color: #fff; border: 1px solid #ffffff30; padding: 8px 10px; }
.company-select option { color: var(--text); background: var(--surface); }
.photos { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.photos figure { margin: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface-soft); }
.photos img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; cursor: zoom-in; }
.photos figcaption { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 6px 8px; font-size: .82rem; color: var(--muted); }
.photo-slots { display: flex; gap: 12px; flex-wrap: wrap; }
.photo-slot { width: 150px; height: 112px; border: 2px dashed var(--border); border-radius: 10px; display: grid; place-items: center; text-align: center; cursor: pointer; color: var(--muted); font-size: .85rem; position: relative; overflow: hidden; background: var(--surface-soft); }
.photo-slot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-slot input { display: none; }
.item-head .thumb { width: 132px; height: 132px; border: 1px solid var(--border); border-radius: 10px; object-fit: cover; }
.account { position: relative; }
.account summary { list-style: none; cursor: pointer; border: 1px solid #ffffff30; border-radius: 8px; background: #ffffff10; padding: 9px 12px; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account summary::-webkit-details-marker { display: none; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); width: 220px; padding: 6px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); box-shadow: 0 12px 32px #0003; }
.menu-caption { display: block; padding: 8px 10px; font-size: .78rem; color: var(--muted); border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu a, .menu button { display: block; width: 100%; text-align: left; padding: 9px 10px; border: 0; background: none; color: inherit; border-radius: 6px; text-decoration: none; font: inherit; cursor: pointer; }
.menu a:hover, .menu button:hover { background: var(--surface-hover); }
.menu button { color: var(--danger); }
main { max-width: 1200px; margin: 20px auto; padding: 0 16px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
h1 { font-size: 1.45rem; margin: 0 0 6px; }
h2 { font-size: 1.12rem; margin: 22px 0 10px; }
.note { color: var(--muted); font-size: .9rem; margin: 0; }
.credit { max-width: 1200px; margin: 0 auto 24px; padding: 0 16px; text-align: right; font-size: .8rem; color: var(--muted); }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; text-decoration: none; color: inherit; display: block; }
.card:hover { border-color: var(--accent); }
.card b { font-size: 1.05rem; }
.meter { height: 6px; border-radius: 3px; background: var(--surface-hover); margin-top: 10px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }
.toolbar .grow { flex: 1 1 220px; }
.toolbar { position: relative; }
.suggest { position: absolute; z-index: 30; left: 0; right: 0; top: 100%; margin-top: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 12px 32px #0002; max-height: 60vh; overflow: auto; }
.suggest a { display: block; padding: 9px 12px; color: inherit; text-decoration: none; border-bottom: 1px solid var(--border); }
.suggest a:last-child { border-bottom: 0; }
.suggest a:hover, .suggest a.on { background: var(--surface-hover); }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; }
textarea { min-height: 90px; resize: vertical; }
label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 5px; }
.field { margin-bottom: 14px; }
.hint { color: var(--muted); font-size: .82rem; margin-top: 4px; }
.form-grid { display: grid; gap: 0 16px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 8px; padding: 10px 16px; background: var(--accent); color: #fff; font: inherit; font-weight: 650; cursor: pointer; text-decoration: none; }
.btn.secondary { background: var(--surface-soft); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--danger); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.sm { padding: 6px 11px; font-size: .88rem; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-hover); }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 650; background: var(--surface-hover); color: var(--muted); }
.badge.ACTIVO { background: var(--ok-bg); color: var(--ok); }
.badge.REPARACION { background: var(--warn-bg); color: var(--warn); }
.badge.BAJA { background: var(--danger-bg); color: var(--danger); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 18px 0 16px; overflow-x: auto; }
.tabs button { background: none; border: 1px solid transparent; border-bottom: 0; border-radius: 8px 8px 0 0; padding: 9px 14px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; margin-bottom: -1px; white-space: nowrap; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); border-color: var(--border); }
.item-head { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.item-head .qr { width: 132px; height: 132px; border: 1px solid var(--border); border-radius: 10px; background: #fff; padding: 4px; }
.item-head .qr svg { width: 100%; height: 100%; }
.code-big { font-size: 1.6rem; font-weight: 700; letter-spacing: .02em; }
.meta { display: grid; gap: 10px 18px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); margin-top: 12px; }
.meta span { display: block; font-size: .78rem; color: var(--muted); }
.empty { padding: 26px; text-align: center; color: var(--muted); }
.pager { display: flex; gap: 10px; align-items: center; justify-content: flex-end; margin-top: 12px; }
.modal-back { position: fixed; inset: 0; background: rgba(15, 23, 42, .55); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border-radius: 14px; padding: 20px; width: min(560px, 100%); max-height: 92vh; overflow: auto; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.scanner video { width: 100%; border-radius: 10px; background: #000; aspect-ratio: 3 / 4; object-fit: cover; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--header); color: var(--header-text); padding: 11px 18px; border-radius: 10px; z-index: 60; max-width: calc(100% - 32px); }
.secret { font-family: ui-monospace, monospace; font-size: 1.1rem; background: var(--surface-soft); border: 1px dashed var(--border); padding: 10px; border-radius: 8px; word-break: break-all; }
.login { max-width: 380px; margin: 8vh auto; }
.list-cards { display: none; }
@media (max-width: 720px) {
  .topbar { gap: 10px; padding-left: 12px; padding-right: 12px; }
  .brand-title { display: none; }
  .company-select { max-width: 130px; }
  .nav { order: 3; flex-basis: 100%; overflow-x: auto; }
  main { margin-top: 14px; padding: 0 12px; }
  .panel { padding: 14px; }
  .table-wrap { display: none; }
  .list-cards { display: grid; gap: 10px; }
  .list-cards .card { padding: 13px; }
  .code-big { font-size: 1.3rem; }
  .btn { padding: 11px 15px; }
}
@media print {
  .topbar, .credit, .no-print, .tabs { display: none !important; }
  body { background: #fff; }
  .panel { border: 0; box-shadow: none; }
}
.notice { background: var(--warn-bg); color: var(--warn); border-radius: 8px; padding: 10px 12px; font-weight: 600; }
