/* Tokens de docs/03-diseno/guia-ui.md § 2 */
:root {
  color-scheme: light;
  --teal: #153e3b;
  --teal-2: #24594f;
  --line: #d3ddd8;
  --mute: #56695f;
  --sel: #f2c230;
  --sel-bg: #fff8dc;
  --ok: #1d6f46;
  --ok-bg: #e3f3ea;
  --warn: #8a5a00;
  --warn-bg: #fff4d9;
  --warn-text: #5c3e00;
  --cut: #a8321f;
  --cut-bg: #fdeceb;
  --surface: #fff;
  --page: #f3f5f4;
  --text: #183632;
  --r-btn: 5px;
  --r-card: 10px;
  --r-lg: 14px;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 15px;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--page);
  font-variant-numeric: tabular-nums;
  overflow-x: hidden;
}

h1 {
  font-size: 28px;
  margin: 0 0 4px;
  line-height: 1.2;
}

h2 {
  font-size: 20px;
  margin: 0 0 12px;
  line-height: 1.25;
}

h3 {
  font-size: 17px;
  margin: 0 0 8px;
}

p {
  margin: 0 0 10px;
}

.small {
  font-size: 13px;
}

.mute {
  color: var(--mute);
}

.right {
  text-align: right;
}

.nowrap {
  white-space: nowrap;
}

a {
  color: var(--teal-2);
}

/* Banner de ambiente de simulación */
.env-banner {
  background: var(--warn-bg);
  color: var(--warn-text);
  border-bottom: 1px solid rgba(138, 90, 0, .25);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  padding: 6px 16px;
}

/* Encabezado */
.top {
  background: var(--teal);
  color: #fff;
}

.top-in {
  max-width: 1440px;
  margin: 0 auto;
  padding: 8px 20px;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.brand {
  font-weight: 700;
  font-size: 17px;
  white-space: nowrap;
}

.brand small {
  font-weight: 400;
  opacity: .85;
  margin-left: 6px;
}

.top .spacer {
  flex: 1;
}

.top-user {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.clock {
  font-size: 13px;
  opacity: .9;
  white-space: nowrap;
}

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.top button.top-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, .4);
  color: #fff;
  min-height: 42px;
  padding: 0 12px;
  font-size: 14px;
}

.top button.top-btn:hover {
  background: rgba(255, 255, 255, .12);
}

main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 20px 48px;
}

/* Controles */
button,
.link-button {
  font: inherit;
  font-weight: 600;
  min-height: 42px;
  padding: 0 16px;
  border-radius: var(--r-btn);
  border: 1px solid var(--teal-2);
  background: var(--teal-2);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

button.secondary,
.link-button.secondary {
  background: #fff;
  color: var(--teal-2);
  text-decoration: none;
}

button.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--teal-2);
  padding: 0 10px;
}

button.primary-lg {
  width: 100%;
  min-height: 52px;
  font-size: 17px;
  background: var(--teal);
  border-color: var(--teal);
}

button.danger {
  background: var(--cut);
  border-color: var(--cut);
  color: #fff;
}

button.sm,
.link-button.sm {
  min-height: 42px;
  padding: 0 12px;
  font-size: 13px;
}

button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

input,
select,
textarea {
  font: inherit;
  min-height: 42px;
  border: 1px solid #9fb2a9;
  border-radius: var(--r-btn);
  padding: 0 10px;
  background: #fff;
  color: var(--text);
  width: 100%;
}

input.num {
  text-align: right;
  width: 140px;
  max-width: 100%;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--sel);
  outline-offset: 2px;
}

input.invalid {
  border-color: var(--cut);
  background: var(--cut-bg);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.field > span {
  font-size: 13px;
  color: var(--mute);
  font-weight: 600;
}

.field .err {
  color: var(--cut);
  font-size: 13px;
  min-height: 1em;
}

.row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.row.end {
  justify-content: flex-end;
}

/* Segmented control para método de ingreso */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: var(--page);
  padding: 4px;
  border-radius: var(--r-btn);
  border: 1px solid var(--line);
  margin-bottom: 14px;
}

.segmented button {
  background: transparent;
  border-color: transparent;
  color: var(--mute);
  min-height: 42px;
  padding: 0 10px;
  font-size: 14px;
}

.segmented button.on {
  background: var(--surface);
  color: var(--teal);
  border-color: var(--line);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
}

/* Tarjetas */
.card {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 16px;
  margin-bottom: 16px;
}

.card h2 {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.card h2 .small {
  font-weight: 400;
}

/* Ingreso y selector de estación */
.center-wrap {
  min-height: calc(100vh - 60px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 24px;
  box-shadow: 0 4px 20px rgba(21, 62, 59, .08);
}

.login-card h1 {
  font-size: 24px;
  margin-bottom: 4px;
}

.login-sub {
  color: var(--mute);
  font-size: 14px;
  margin-bottom: 18px;
}

.station-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.station-btn {
  width: 100%;
  justify-content: space-between;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 12px 16px;
  min-height: 52px;
  text-align: left;
}

.station-btn:hover {
  border-color: var(--teal-2);
  background: var(--sel-bg);
}

/* Tablas */
.table-wrap {
  overflow-x: auto;
  max-width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .02em;
  color: var(--mute);
  border-bottom: 2px solid var(--line);
  padding: 8px;
  white-space: nowrap;
}

td {
  border-bottom: 1px solid var(--line);
  padding: 8px;
  vertical-align: middle;
}

td.num,
th.num {
  text-align: right;
  white-space: nowrap;
}

.diff {
  color: var(--cut);
  font-weight: 700;
}

/* Estados y cajas */
.pill {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--page);
  color: var(--mute);
  white-space: nowrap;
}

.pill.ok {
  background: var(--ok-bg);
  color: var(--ok);
}

.pill.warn {
  background: var(--warn-bg);
  color: var(--warn-text);
}

.pill.cut {
  background: var(--cut-bg);
  color: var(--cut);
}

.pill.sel {
  background: var(--sel-bg);
  color: var(--teal);
  border: 1px solid var(--sel);
}

.ok-box,
.warn-box,
.error,
.info-box {
  border-radius: var(--r-card);
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 14px;
}

.ok-box {
  background: var(--ok-bg);
  color: var(--ok);
}

.warn-box {
  background: var(--warn-bg);
  color: var(--warn-text);
}

.error {
  background: var(--cut-bg);
  color: var(--cut);
}

.info-box {
  background: var(--page);
  color: var(--mute);
  border: 1px solid var(--line);
}

.empty {
  color: var(--mute);
  padding: 18px 0;
  text-align: center;
}

/* Barra del turno y estado del controlador */
.shift-bar {
  display: flex;
  gap: 12px 20px;
  flex-wrap: wrap;
  align-items: baseline;
  margin-bottom: 10px;
}

.shift-bar h1 {
  margin: 0;
}

.shift-bar .meta {
  color: var(--mute);
  font-size: 14px;
}

.status-strip {
  display: flex;
  gap: 8px 16px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 13px;
  color: var(--mute);
  margin: 0 0 12px;
}

.status-sep {
  color: var(--line);
}

/* Surtidores */
.pumps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(2, auto);
  grid-auto-flow: column;
  gap: 12px;
  margin-bottom: 16px;
}

.pumps.many {
  grid-template-rows: none;
  grid-auto-flow: row;
}

.pump {
  container-type: inline-size;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 170px;
}

.pump .head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.pump .head b {
  font-size: 17px;
}

.pump .big {
  font-size: clamp(20px, 11cqi, 38px);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -.01em;
  white-space: nowrap;
}

.pump .amt {
  font-size: 19px;
  font-weight: 700;
  white-space: nowrap;
  color: var(--mute);
}

.pump .amt small {
  font-size: 14px;
  font-weight: 600;
  color: var(--mute);
}

.pump .foot {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--mute);
  flex-wrap: wrap;
}

.pump.no-load .big,
.pump.no-load .amt {
  color: var(--mute);
}

.pump:focus-visible {
  outline: 4px solid var(--sel);
  outline-offset: 2px;
}

#fills tr[data-load-id]:focus-visible {
  outline: 3px solid var(--sel);
  outline-offset: -3px;
  background: var(--sel-bg);
}

#fills tr[data-load-id],
.pump {
  scroll-margin: 80px 0 40px;
}

.kbd-hint {
  margin: -4px 0 12px;
}

.kbd-hint kbd {
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 5px;
  background: var(--surface);
}

/* Sin turno abierto */
.no-shift-card {
  text-align: center;
  padding: 32px 16px;
}

.no-shift-card p {
  max-width: 560px;
  margin: 8px auto 18px;
}

.no-shift-card .primary-lg {
  max-width: 340px;
}

/* Diálogos y avisos */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(21, 62, 59, .5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  z-index: 50;
  overflow-y: auto;
}

.dialog {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 20px;
  width: 100%;
  max-width: 560px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
}

.dialog.narrow {
  max-width: 400px;
}

.dialog h2 {
  margin-bottom: 12px;
}

.dialog .actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
  flex-wrap: wrap;
}

.toasts {
  position: fixed;
  right: 16px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
}

.toast {
  background: var(--teal);
  color: #fff;
  padding: 10px 14px;
  border-radius: var(--r-card);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .2);
  max-width: 360px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast.error {
  background: var(--cut);
  color: #fff;
}

.toast button.toast-close {
  background: transparent;
  border: 0;
  color: #fff;
  min-height: 32px;
  padding: 0 6px;
  font-size: 16px;
  margin-left: auto;
}

/* Emisión, borradores y detalle de comprobantes */
.drafts-card {
  border-color: rgba(138, 90, 0, .35);
  background: #fffdf7;
}

.emit-block {
  margin-bottom: 14px;
}

.emit-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.emit-total {
  font-size: 14px;
  font-weight: 700;
  color: var(--teal);
}

.load-picker {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
  padding: 2px;
}

.load-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-btn);
  background: var(--surface);
  cursor: pointer;
  min-height: 42px;
  font-size: 14px;
}

.load-opt.on {
  border-color: var(--teal-2);
  background: var(--sel-bg);
}

.load-opt input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: 18px;
  margin: 0;
  flex-shrink: 0;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.customer-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 190px;
  overflow-y: auto;
}

.customer-item {
  width: 100%;
  justify-content: space-between;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 8px 12px;
  text-align: left;
  font-weight: 400;
}

.customer-item:hover:not(:disabled) {
  border-color: var(--teal-2);
  background: var(--sel-bg);
}

.cust-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.selected-cust {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.card-inset {
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 12px;
  margin-bottom: 12px;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
}

.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.detail-head h2 {
  margin: 0;
}

.state-blocks {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.state-block {
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

@media (max-width: 680px) {
  .grid-2,
  .state-blocks,
  .meta-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .pumps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: none;
    grid-auto-flow: row;
  }
}

@media (max-width: 760px) {
  .kbd-hint {
    display: none;
  }
}

@media (max-width: 680px) {
  .top-in {
    padding: 8px 12px;
    gap: 8px;
  }

  .brand small,
  .clock {
    display: none;
  }

  main {
    padding: 14px 12px 36px;
  }

  .shift-bar h1 {
    font-size: 22px;
  }

  .pumps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .pump {
    min-height: 144px;
    padding: 10px;
  }

  .pump .head {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .pump .big {
    font-size: clamp(16px, 12cqi, 26px);
  }

  .pump .amt {
    font-size: 15px;
  }

  .pump .foot {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
}

@media (max-width: 360px) {
  .pumps {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
