:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --line: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --good: #4ade80;
  --bad: #f87171;
  --cell: #0b1220;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, sans-serif;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: #0b1220;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--accent);
  letter-spacing: 0.03em;
}

.meta {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.meta label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
  padding: 1.25rem;
  max-width: 1400px;
  margin: 0 auto;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem;
  align-self: start;
}

.panel h2 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.4rem;
}

.panel h3 {
  margin: 1rem 0 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.sheet {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
  font-size: 0.85rem;
}

.sheet caption {
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  padding: 0.35rem 0.1rem;
  font-size: 0.85rem;
}

.sheet th,
.sheet td {
  border: 1px solid var(--line);
  padding: 0.3rem 0.5rem;
  text-align: left;
}

.sheet thead th {
  background: #0b1220;
  color: var(--muted);
  font-weight: 600;
}

.sheet td.out,
.sheet td.imp {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.sheet .total-row th,
.sheet .total-row td {
  background: #0b1220;
  font-weight: 700;
}

.sheet .diff th,
.sheet .diff td {
  background: #7f1d1d;
  color: #ffe4e6;
  font-weight: 700;
}

.num {
  width: 100%;
  min-width: 70px;
  background: var(--cell);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.25rem 0.4rem;
  font: inherit;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.num:focus {
  outline: none;
  border-color: var(--accent);
}

.tname,
.name {
  background: var(--cell);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.2rem 0.4rem;
  font: inherit;
  width: 100%;
}

.field {
  display: block;
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.field input {
  margin-top: 0.3rem;
}

.emps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.5rem;
}

.emps label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.hint {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0.25rem 0 0;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn {
  background: #334155;
  border: 1px solid #475569;
  color: var(--text);
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
}

.btn:hover { filter: brightness(1.15); }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b1220;
  font-weight: 700;
}

.msg { min-height: 1.2em; font-size: 0.85rem; }

.msg.ok { color: var(--good); }
.msg.err { color: var(--bad); }

.historial {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 260px;
  overflow: auto;
}

.historial li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  margin-bottom: 0.35rem;
  font-size: 0.8rem;
}

.historial li .who { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.historial li .t {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.historial button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 6px;
  padding: 0.15rem 0.5rem;
  font-size: 0.75rem;
  cursor: pointer;
}

.historial button:hover { color: var(--text); border-color: var(--accent); }

#notas {
  width: 100%;
  background: var(--cell);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem;
  font: inherit;
  resize: vertical;
}

.foot {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 1rem;
  border-top: 1px solid var(--line);
}

@media print {
  body { background: #fff; color: #111; }
  .topbar, .actions, .historial, .btn, #p-acciones, .foot, #p-notas { display: none !important; }
  .panel { border: 1px solid #999; background: #fff; }
  .sheet th, .sheet td { border-color: #666; color: #111 !important; background: #fff !important; }
  .num { border: none; background: none; -webkit-print-color-adjust: exact; }
}