:root {
  --navy: #1c1c1c;
  --navy-2: #2b2b2b;
  --ink: #141414;
  --brick: #c15a32;
  --brick-d: #9a4526;
  --sky: #e8d5c8;
  --bg: #f6f1eb;
  --card: #fff;
  --line: #e6d9cf;
  --muted: #6d5e55;
  --text: #1c1c1c;
  --danger: #d64545;
  --warn: #c98912;
  --ok: #1dab28;
  --shadow: 0 10px 28px rgba(28,28,28,.10);
  --radius: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif; min-height: 100dvh;
  touch-action: manipulation; }
button {
  font: inherit; cursor: pointer; -webkit-appearance: none; appearance: none;
}
button, .list-item, .chip, .stat, .icon-btn, .bottom button {
  transition: transform .08s ease, filter .08s ease, background .08s ease, color .08s ease;
}
button:active, .list-item:active, .chip:active, .stat:active, .icon-btn:active,
button.pressed, .list-item.pressed, .chip.pressed, .stat.pressed, .icon-btn.pressed {
  transform: scale(0.97);
  filter: brightness(0.92);
}
.list-item:active, .list-item.pressed { background: #efe6dc; }
.btn:active, .btn.pressed { filter: brightness(0.86); transform: scale(0.97); }
.chip:active, .chip.pressed { background: var(--sky); }
.stat:active, .stat.pressed { background: #efe6dc; }
.bottom button:active, .bottom button.pressed { color: var(--brick); transform: scale(0.94); }
#busy {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(246, 241, 235, .55);
  display: flex; align-items: center; justify-content: center;
}
#busy[hidden] { display: none; }
.busy-box {
  background: #fff; border-radius: 18px; padding: 18px 22px 14px;
  box-shadow: var(--shadow); display: flex; flex-direction: column;
  align-items: center; gap: 10px; min-width: 140px;
  border: 1px solid var(--line);
}
.busy-ball {
  width: 34px; height: 34px;
  border: 3px solid #eadfd6;
  border-top-color: var(--brick);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.busy-box p { margin: 0; font-size: .85rem; font-weight: 700; color: var(--navy); }
@keyframes spin { to { transform: rotate(360deg); } }
.app-shell { min-height: 100dvh; padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px)); }
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(180deg, var(--navy-2), var(--navy)); color: #fff;
  padding: calc(12px + env(safe-area-inset-top,0)) 16px 14px;
  display: flex; align-items: center; gap: 10px;
}
.topbar .titles { flex: 1; min-width: 0; }
.login-card .brand-name {
  text-align: center; font-weight: 800; letter-spacing: .18em; text-transform: uppercase;
  font-size: .78rem; color: var(--brick); margin: 0 0 6px;
}
.topbar h1 { margin: 0; font-size: 1.05rem; }
.topbar p { margin: 2px 0 0; font-size: .78rem; color: var(--sky); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { border: 0; background: rgba(255,255,255,.12); color: #fff; width: 40px; height: 40px; border-radius: 12px; font-size: 1.2rem; }
.page { padding: 16px; max-width: 920px; margin: 0 auto; }
.page h2 { margin: 0 0 6px; font-size: 1.25rem; color: var(--navy); }
.lead { color: var(--muted); margin: 0 0 16px; line-height: 1.45; font-size: .95rem; }
.login {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
  background: radial-gradient(700px 280px at 90% -10%, #c15a32 0%, transparent 50%),
              linear-gradient(180deg, #2b2b2b 0%, #1c1c1c 70%);
}
.login-card {
  width: 100%; max-width: 420px; background: #fff; border-radius: 22px;
  padding: 26px 22px 22px; box-shadow: 0 20px 50px rgba(0,0,0,.28); border-top: 4px solid var(--brick);
}
.login-logo { display: flex; justify-content: center; margin-bottom: 10px; }
.login-logo img { height: 78px; }
.login-card h1 { text-align: center; margin: 4px 0; color: var(--navy); }
.login-card .sub { text-align: center; color: var(--muted); margin: 0 0 18px; }
label.field { display: block; font-size: .8rem; font-weight: 700; color: var(--navy); margin: 10px 0 6px; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; background: #f7fafc; color: var(--text); font: inherit;
}
textarea { min-height: 70px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; padding: 13px 16px; font-weight: 700;
  background: var(--brick); color: #fff; cursor: pointer; text-decoration: none;
}
.btn.block { width: 100%; }
.btn.navy { background: var(--navy); }
.btn.ghost { background: #e8eef3; color: var(--navy); }
.btn.danger { background: var(--danger); }
.err { color: var(--danger); font-size: .9rem; margin: 8px 0 0; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.stat {
  background: var(--card); border-radius: var(--radius); padding: 14px;
  box-shadow: var(--shadow); border: 1px solid #e7eef3; text-align: left; width: 100%; cursor: pointer;
}
.stat b { display: block; font-size: 1.45rem; color: var(--navy); }
.stat span { color: var(--muted); font-size: .8rem; }
.stat.warn b { color: var(--warn); }
.stat.bad b { color: var(--danger); }
.list { display: flex; flex-direction: column; gap: 10px; }
.list-item, .card {
  background: var(--card); border: 1px solid #e7eef3; border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.list-item {
  padding: 14px; display: flex; gap: 12px; align-items: center; text-align: left; width: 100%;
}
.list-item .mark {
  width: 48px; height: 48px; border-radius: 12px; background: #fff; color: var(--brick-d);
  display: grid; place-items: center; font-weight: 800; font-size: .72rem; flex: none;
  overflow: visible; border: 1px solid var(--line); position: relative;
}
.mark .nro {
  position: absolute; bottom: -6px; right: -6px;
  background: var(--navy); color: #fff; font-size: .62rem; font-weight: 800;
  border-radius: 8px; padding: 1px 5px; min-width: 1.4em; text-align: center;
}
.list-item .mark img.brand, .sug-item img.brand {
  width: 44px; height: 44px; display: block; object-fit: contain; background: #fff;
}
.list-item .grow { flex: 1; min-width: 0; }
.list-item h3 { margin: 0; font-size: 1rem; color: var(--navy); }
.list-item p { margin: 3px 0 0; color: var(--muted); font-size: .82rem; }
.chev { color: #9bb0c0; font-size: 1.2rem; }
.badge {
  display: inline-flex; align-items: center; border-radius: 999px;
  padding: 3px 8px; font-size: .72rem; font-weight: 700;
}
.b-ok { background: #ddf6e5; color: #157a32; }
.b-at { background: #fff3d6; color: #8a6508; }
.b-ve { background: #fde2e2; color: #a12626; }
.b-wait { background: #e8eef3; color: var(--navy); }
.b-off { background: #eee; color: #666; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 8px 12px; font-weight: 700; font-size: .82rem; color: var(--navy);
}
.chip.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.search { margin-bottom: 14px; }
.search input { background: #fff; }
.fab-row { display: flex; gap: 8px; margin: 8px 0 16px; flex-wrap: wrap; }
.bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: #fff; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
}
.bottom button {
  border: 0; background: transparent; color: var(--muted); padding: 8px 4px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .7rem; font-weight: 700;
}
.bottom button.on { color: var(--navy); }
.bottom .ico { font-size: 1.15rem; }
.info-card { padding: 6px 16px 10px; margin-bottom: 14px; }
.kv {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid #f0e7df; font-size: .92rem;
}
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--muted); }
.kv b { text-align: right; font-weight: 650; }
.item-row {
  padding: 12px 14px; display: grid; grid-template-columns: 1fr auto; gap: 6px;
}
.item-row h3 { margin: 0; font-size: .95rem; }
.item-row .meta { color: var(--muted); font-size: .8rem; }
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 12px;
  font-size: .88rem; z-index: 50; max-width: 90%;
}
.empty { text-align: center; color: var(--muted); padding: 28px 10px; }
.small { font-size: .8rem; color: var(--muted); }
.modal-bg {
  position: fixed; inset: 0; background: rgba(10,24,38,.45); z-index: 40;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: #fff; width: 100%; max-width: 640px; border-radius: 20px 20px 0 0;
  padding: 18px 16px 24px; max-height: 92vh; overflow: auto;
}
.modal h3 { margin: 0 0 10px; color: var(--navy); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.search-pick { position: relative; }
.sug {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px);
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  max-height: 240px; overflow: auto; z-index: 8; box-shadow: var(--shadow);
}
.sug-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  text-align: left; padding: 8px 10px; border: 0; background: #fff; font: inherit;
}
.sug-item small { display: block; color: var(--muted); font-size: .75rem; }
.sug-item:active, .sug-item:hover { background: #f6f1eb; }
.sug-empty { padding: 12px; color: var(--muted); font-size: .85rem; }
@media (min-width: 800px) {
  .stats { grid-template-columns: repeat(4, 1fr); }
  .modal { border-radius: 20px; margin-bottom: 40px; }
  .modal-bg { align-items: center; }
}
