:root {
  --navy: #092a54;
  --navy-hover: #123a6e;
  --ink: #142033;
  --muted: #3e5168;
  --line: #d5dee8;
  --line-strong: #8aa0b8;
  --bg: #f3f6fa;
  --card: #ffffff;
  --wash: #eef3f8;
  --teal: #0b6e6e;
  --ok-bg: #e5f6ee;
  --ok: #0f5c3a;
  --error-bg: #fdecea;
  --error: #8c1d18;
  --focus: #11a6a6;
  --shadow: 0 10px 28px rgba(9, 42, 84, 0.07);
  --radius: 10px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #e7eef6 0, var(--bg) 240px);
  line-height: 1.5;
}
.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  background: #fff;
  color: var(--navy);
  padding: 0.5rem 1rem;
}
.skip:focus { top: 0.5rem; }
.wrap { width: min(1080px, calc(100% - 2rem)); margin: 0 auto; }
.app-header { background: var(--navy); color: #fff; border-bottom: 3px solid var(--focus); }
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
}
.brand { margin: 0; min-width: 0; font-size: 1.25rem; font-weight: 700; }
.brand span { display: block; font-size: 0.95rem; font-weight: 500; color: #d5e4f5; }
.header-admin {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  margin: 0;
  padding: 0.4rem 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: var(--radius);
  background: transparent;
  color: #fff;
  font-weight: 650;
  letter-spacing: 0.01em;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.header-admin:hover,
.header-admin:focus-visible { background: #fff; color: var(--navy); }
main { padding: 1.5rem 0 3rem; }
.card {
  background: var(--card);
  border: 1px solid #e4edf5;
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 1.35rem 1.4rem;
}
.auth-card { max-width: 34rem; margin: 0 auto; }
h1, h2 { color: var(--navy); line-height: 1.25; }
h1 { font-size: 1.8rem; margin: 0 0 0.5rem; }
h2 { font-size: 1.25rem; margin: 1.5rem 0 0.75rem; }
.lead { color: var(--muted); margin-top: 0; }
label, legend { display: block; font-weight: 650; margin: 0.95rem 0 0.35rem; color: var(--navy); letter-spacing: 0.01em; }
input, select, button { font: inherit; }
input[type="text"], input[type="email"], input[type="password"], input:not([type]), select, input[inputmode="numeric"] {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0.55rem 0.8rem;
  background: #fff;
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input[type="text"]:hover, input[type="email"]:hover, input[type="password"]:hover, input:not([type]):hover, select:hover, input[inputmode="numeric"]:hover {
  border-color: var(--navy);
}
select {
  appearance: none;
  padding-right: 2.2rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--navy) 50%), linear-gradient(135deg, var(--navy) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% - 2px), calc(100% - 12px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}
input:focus-visible, select:focus-visible {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(17, 166, 166, 0.28);
}
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin-top: 1rem;
  padding: 0.6rem 1.15rem;
  border-radius: var(--radius);
  border: 1px solid var(--navy);
  background: var(--navy);
  color: #fff;
  font-weight: 650;
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.button:hover { background: var(--navy-hover); border-color: var(--navy-hover); }
.button.secondary { background: #fff; color: var(--navy); }
.button.secondary:hover { background: var(--wash); color: var(--navy); border-color: var(--navy); }
.button.ghost { background: transparent; color: var(--navy); }
.button.ghost:hover { background: var(--wash); color: var(--navy); border-color: var(--navy); }
.auth-card form > .button,
.alt-entry .button { width: 100%; }
.alt-entry { margin: 0.35rem 0 0; }
.button.danger { background: var(--error); border-color: var(--error); }
.button.danger:hover { background: #751814; border-color: #751814; }
.button:disabled, .button:disabled:hover { opacity: 0.55; cursor: not-allowed; background: var(--navy); }
.button.secondary:disabled, .button.ghost:disabled { background: #fff; }
a { color: var(--navy); }
.flash { padding: 0.8rem 1rem; border-radius: 8px; margin: 0.8rem 0; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--error-bg); color: var(--error); }
.otp { display: flex; gap: 0.45rem; }
.otp input {
  text-align: center;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--navy);
  padding: 0;
}
.choice { display: flex; gap: 0.6rem; align-items: center; min-height: 48px; font-weight: 500; }
.choice input { width: 1.2rem; height: 1.2rem; }
.company-card { max-width: 32rem; margin: 0 auto; padding: 1rem 1.1rem; }
.company-card h1 { font-size: 1.35rem; margin-bottom: 0.25rem; }
.company-card .lead { font-size: 0.95rem; }
.company-picker { border: 0; margin: 0.35rem 0 0; padding: 0; }
.company-picker legend { margin: 0 0 0.45rem; font-size: 0.85rem; }
.company-row { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.company-option { position: relative; display: inline-flex; margin: 0; cursor: pointer; font-weight: 700; }
.company-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
}
.company-option span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 4.5rem;
  min-height: 36px;
  padding: 0.2rem 0.85rem;
  border: 1px solid var(--navy);
  border-radius: var(--radius);
  background: #fff;
  color: var(--navy);
  transition: background 0.15s ease, color 0.15s ease;
}
.company-option span:hover { background: var(--wash); }
.company-option input:checked + span,
.company-option input:checked + span:hover { background: var(--navy); color: #fff; }
.company-option input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.company-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.company-actions .button { width: auto; min-height: 36px; margin-top: 0.75rem; padding: 0.35rem 0.9rem; }
.title-row, .switch-row, .actions { display: flex; gap: 0.75rem; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.title-row .button, .switch-row .button, .actions .button { margin-top: 0; }
.actions .button { min-width: 11rem; }
.tabs {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin: 0.35rem 0 1.1rem;
  padding: 0.25rem;
  width: fit-content;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--wash);
}
.tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0.3rem 0.9rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--navy);
  font-weight: 650;
  text-decoration: none;
}
.tab:hover { background: #fff; }
.tab.is-current { background: var(--navy); border-color: var(--navy); color: #fff; }
.badges { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.badge { background: #e7eef6; color: var(--navy); border-radius: 999px; padding: 0.2rem 0.7rem; font-weight: 650; }
.badge.closed { background: #fdecea; color: var(--error); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.7rem 0.75rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--navy); font-size: 0.84rem; background: #f7fafc; }
table:not(.distribution) tbody tr:last-child td,
table:not(.distribution) tbody tr:last-child th { border-bottom: 0; }
table:not(.distribution) tbody tr:hover td { background: #f8fbfe; }
table.distribution { min-width: 52rem; border-collapse: collapse; }
table.distribution th,
table.distribution td { border: 1px solid #c5d0dc; vertical-align: bottom; }
table.distribution thead th { text-align: center; font-size: 0.82rem; line-height: 1.3; }
table.distribution tbody th { background: #f7fafc; white-space: nowrap; }
table.distribution td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.distribution .pp-market { background: #f8e4da; }
table.distribution .pp-canasta { background: #f8f3d2; }
table.distribution .pp-gasolina { background: #e7f2e3; }
table.distribution .pp-total { background: #e7eef6; font-weight: 650; }
table.distribution .blank { color: var(--muted); font-weight: 400; }
.help, .empty { color: var(--muted); }
.flash { border: 1px solid transparent; }
.flash.ok { border-color: #b7e4cc; }
.flash.error { border-color: #f3c1be; }
.pocket {
  margin-top: 0.75rem;
  padding: 0.75rem 0.85rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfe;
}
.pocket label { margin-top: 0; }
.total { font-size: 1.15rem; color: var(--navy); }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  .button, .tab, .company-option span, .header-admin, input, select { transition: none; }
}
@media (max-width: 700px) {
  .header-admin { padding: 0.35rem 0.6rem; font-size: 0.85rem; }
  .switch-row, .actions, .title-row { align-items: stretch; }
  .button, select { width: 100%; }
  .company-actions .button,
  .company-option span { width: auto; }
}
