:root {
  color-scheme: light;

  /* Surfaces — warm "paper / kraft" base for an industrial feel */
  --bg: #efe9df;
  --bg-grain: #e7e0d3;
  --surface: #ffffff;
  --surface-2: #faf7f1;
  --surface-3: #f3eee4;
  --line: #ded6c6;
  --line-strong: #cabfa9;

  /* Ink */
  --text: #1c1f24;
  --muted: #5e6470;
  --muted-2: #8a8576;

  /* Industrial graphite (sidebar / dark chrome) */
  --graphite: #16181d;
  --graphite-2: #1e2128;
  --graphite-line: rgba(255, 255, 255, 0.08);

  /* Signal amber (primary brand accent) */
  --amber: #e8820c;
  --amber-bright: #ff9a1f;
  --amber-dark: #c4690a;
  --amber-soft: #fdecd2;
  --amber-ink: #92510a;

  /* Status palette */
  --teal: #0f766e;
  --teal-soft: #d8efeb;
  --blue: #2563eb;
  --blue-soft: #e2ebff;
  --red: #b42318;
  --red-soft: #fbe0dd;
  --gray-soft: #eae4d8;

  --shadow-sm: 0 1px 2px rgba(28, 22, 10, 0.05);
  --shadow: 0 14px 34px rgba(40, 30, 12, 0.10);
  --shadow-lift: 0 18px 44px rgba(40, 30, 12, 0.16);
  --radius: 12px;
  --radius-sm: 9px;

  --font-display: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --font-body: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 18% -10%, rgba(232, 130, 12, 0.06), transparent 42%),
    radial-gradient(circle at 100% 0%, rgba(28, 33, 40, 0.05), transparent 35%);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

::selection {
  background: var(--amber);
  color: #fff;
}

/* Scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--muted-2);
  background-clip: content-box;
}

.app-shell {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  min-height: 100vh;
}

/* ---------------------------------------------------------------- Sidebar */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 26px 20px 18px;
  background:
    linear-gradient(180deg, var(--graphite-2), var(--graphite) 60%);
  color: #f4f1ea;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow: hidden;
  border-right: 1px solid rgba(0, 0, 0, 0.4);
}

/* hazard stripe accent across the top of the sidebar */
.hazard-stripe {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background-image: repeating-linear-gradient(
    -45deg,
    var(--amber) 0 14px,
    #15171c 14px 28px
  );
  opacity: 0.95;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  margin-top: 4px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 11px;
  background: linear-gradient(160deg, var(--amber-bright), var(--amber-dark));
  color: #1a1206;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 16px rgba(232, 130, 12, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.brand-text strong {
  display: block;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.brand-text span {
  display: block;
  color: #a7a293;
  font-size: 12px;
  letter-spacing: 0.06em;
  margin-top: 3px;
}

.nav-tabs {
  display: grid;
  gap: 6px;
  margin-top: 4px;
}

.nav-tab {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: #cdc8bb;
  text-align: left;
  padding: 0 14px;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.01em;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.nav-marker {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: currentColor;
  opacity: 0.35;
  transform: rotate(45deg);
  transition: opacity 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.nav-tab:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #f4f1ea;
  border-color: var(--graphite-line);
}

.nav-tab.active {
  background: linear-gradient(180deg, rgba(232, 130, 12, 0.18), rgba(232, 130, 12, 0.08));
  color: #ffd8a3;
  border-color: rgba(232, 130, 12, 0.4);
}

.nav-tab.active .nav-marker {
  opacity: 1;
  background: var(--amber-bright);
  transform: rotate(45deg) scale(1.05);
  box-shadow: 0 0 10px rgba(255, 154, 31, 0.7);
}

.sidebar-panel {
  border: 1px solid var(--graphite-line);
  border-left: 3px solid var(--amber);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: rgba(255, 255, 255, 0.04);
}

.panel-label,
.eyebrow {
  display: block;
  color: var(--muted-2);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 700;
}

.sidebar-panel .panel-label {
  color: #b6905f;
}

.sidebar-panel strong {
  display: block;
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 16px;
  letter-spacing: 0.02em;
  color: #f4f1ea;
}

.sidebar-panel p {
  margin: 9px 0 0;
  color: #b6b1a4;
  font-size: 12.5px;
  line-height: 1.5;
}

.sidebar-visual {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--graphite-line);
  margin-top: auto;
  filter: saturate(1.05);
}

.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  color: #8f8a7c;
}

.readonly-tag {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.25);
}

/* -------------------------------------------------------------- Workspace */

.workspace {
  min-width: 0;
  padding: 26px 30px 40px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--amber-ink);
}

h1, h2, h3, p {
  margin-top: 0;
}

h1 {
  font-family: var(--font-display);
  font-size: clamp(24px, 2.6vw, 33px);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.01em;
  margin-bottom: 0;
}

h2 {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: 0;
}

h3 {
  font-size: 15px;
  margin-bottom: 8px;
}

.status-strip {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  padding: 0 16px;
  color: var(--muted);
  white-space: nowrap;
  font-weight: 600;
  font-size: 13px;
  box-shadow: var(--shadow-sm);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--amber);
  box-shadow: 0 0 0 3px rgba(232, 130, 12, 0.18);
  animation: pulse 1.6s ease-in-out infinite;
}

.status-strip.ok .status-dot {
  background: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.2);
  animation: none;
}

.status-strip.error .status-dot {
  background: var(--red);
  box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.2);
  animation: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ----------------------------------------------------------------- Metrics */

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.metric {
  position: relative;
  min-height: 96px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 16px 15px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.metric::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, var(--amber-bright), var(--amber-dark));
}

.metric:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 11px;
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.01em;
}

.metric small {
  display: block;
  margin-top: 9px;
  color: var(--muted-2);
  font-size: 12px;
}

/* ------------------------------------------------------------------- Views */

.view {
  display: none;
  animation: fade-in 0.22s ease;
}

.view-active {
  display: block;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.toolbar {
  display: flex;
  align-items: end;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.search-control,
.select-control {
  display: grid;
  gap: 7px;
}

.search-control {
  min-width: 260px;
  flex: 1;
}

.search-control.wide {
  max-width: 620px;
}

.select-control {
  min-width: 138px;
}

label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

input,
select {
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  padding: 0 13px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

input::placeholder {
  color: var(--muted-2);
}

input:focus,
select:focus {
  border-color: var(--amber);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(232, 130, 12, 0.16);
}

.primary-button {
  height: 42px;
  border: 0;
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, var(--amber-bright), var(--amber-dark));
  color: #2a1604;
  padding: 0 20px;
  font-weight: 700;
  font-size: 13.5px;
  letter-spacing: 0.02em;
  box-shadow: 0 6px 16px rgba(232, 130, 12, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: transform 0.14s ease, box-shadow 0.14s ease, filter 0.14s ease;
}

.primary-button:hover {
  filter: brightness(1.04);
  box-shadow: 0 9px 22px rgba(232, 130, 12, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.primary-button:active {
  transform: translateY(1px);
}

/* --------------------------------------------------------- Split + panels */

.split-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.92fr) minmax(420px, 1.08fr);
  gap: 16px;
  align-items: start;
}

.list-panel,
.detail-panel,
.table-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 0;
  box-shadow: var(--shadow);
}

.panel-heading {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: var(--radius) var(--radius) 0 0;
}

.panel-heading h2 {
  text-transform: uppercase;
  font-size: 13px;
  letter-spacing: 0.07em;
  color: var(--text);
}

.panel-heading span {
  min-width: 36px;
  height: 26px;
  border-radius: 999px;
  background: var(--graphite);
  color: var(--amber-bright);
  display: inline-grid;
  place-items: center;
  padding: 0 10px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12px;
}

/* --------------------------------------------------------------- Remitos */

.remito-list {
  max-height: calc(100vh - 280px);
  overflow: auto;
}

.remito-row {
  position: relative;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 14px 16px 14px 16px;
  text-align: left;
  transition: background 0.14s ease;
}

.remito-row::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--amber);
  transform: scaleY(0);
  transform-origin: center;
  transition: transform 0.16s ease;
}

.remito-row:hover {
  background: var(--surface-2);
}

.remito-row.active {
  background: var(--amber-soft);
}

.remito-row.active::before {
  transform: scaleY(1);
}

.remito-main strong,
.remito-main span {
  display: block;
}

.remito-main strong {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--text);
}

.remito-main span {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.4;
}

.remito-meta {
  display: grid;
  justify-items: end;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
}

.remito-meta > span:first-child {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted-2);
}

/* ----------------------------------------------------------------- Badges */

.badge {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge.teal {
  color: var(--teal);
  background: var(--teal-soft);
  border-color: rgba(15, 118, 110, 0.25);
}

.badge.blue {
  color: var(--blue);
  background: var(--blue-soft);
  border-color: rgba(37, 99, 235, 0.22);
}

.badge.amber {
  color: var(--amber-ink);
  background: var(--amber-soft);
  border-color: rgba(232, 130, 12, 0.3);
}

.badge.red {
  color: var(--red);
  background: var(--red-soft);
  border-color: rgba(180, 35, 24, 0.25);
}

.badge.gray {
  color: var(--muted);
  background: var(--gray-soft);
  border-color: var(--line-strong);
}

/* ------------------------------------------------------------ Detail panel */

.detail-panel {
  min-height: 520px;
}

.empty-state {
  min-height: 420px;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
  padding: 36px;
  color: var(--muted);
}

.empty-icon {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  color: var(--amber);
  background: var(--amber-soft);
  border: 1px dashed rgba(232, 130, 12, 0.5);
}

.empty-state h2 {
  color: var(--text);
  margin-bottom: 8px;
  font-size: 18px;
}

.empty-state p {
  max-width: 320px;
  line-height: 1.5;
  font-size: 13.5px;
}

.detail-header {
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: var(--radius) var(--radius) 0 0;
}

.detail-title {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.detail-title strong {
  display: block;
  font-family: var(--font-mono);
  font-size: 21px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0.01em;
}

.detail-title span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 11px;
}

.info-tile {
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 11px 12px;
}

.info-tile span {
  display: block;
  color: var(--muted);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.info-tile strong {
  display: block;
  margin-top: 8px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

/* ------------------------------------------------------------------- Items */

.item-list {
  display: grid;
}

.item-row {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) 108px 118px 100px;
  gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  align-items: center;
  transition: background 0.14s ease;
}

.item-row:hover {
  background: var(--surface-2);
}

.item-row:last-child {
  border-bottom: 0;
}

.item-name strong,
.item-name span,
.item-stat span,
.item-stat strong {
  display: block;
}

.item-name strong {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 5px;
}

.item-name span,
.item-stat span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.item-stat span {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  font-size: 10.5px;
}

.item-stat strong {
  margin-top: 5px;
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
}

.item-stat span:last-child {
  margin-top: 4px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  font-size: 11px;
}

/* ------------------------------------------------------ Delivery / estados */

.delivery-panel {
  padding: 16px 18px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.delivery-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.delivery-head .panel-label {
  color: var(--muted);
}

.badge-lg {
  height: 28px;
  font-size: 12px;
  padding: 0 14px;
}

.cost-panel {
  padding: 16px 18px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

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

.cost-head .panel-label {
  color: var(--muted);
}

.cost-total {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: 0.01em;
}

.cost-hint {
  margin: 8px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.cost-error {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--red);
}

.cost-warn {
  margin: 10px 0 0;
  padding: 8px 12px;
  font-size: 12.5px;
  color: var(--amber-ink);
  background: var(--amber-soft);
  border: 1px solid var(--amber);
  border-radius: var(--radius-sm);
}

.cost-total.is-doubtful {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: var(--amber);
}

.cost-actions {
  display: flex;
  gap: 8px;
}

.cost-corrector {
  margin-top: 12px;
}

.addr-search {
  width: 100%;
  height: 38px;
}

.addr-results {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: grid;
  gap: 4px;
}

.addr-results li {
  margin: 0;
}

.addr-pick {
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 12.5px;
  transition: border-color 0.14s ease, background 0.14s ease;
}

.addr-pick:hover {
  border-color: var(--amber);
  background: var(--amber-soft);
}

.addr-empty {
  padding: 8px 4px;
  font-size: 12px;
  color: var(--muted);
}

.cost-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.cost-cell {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.cost-cell span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.cost-cell strong {
  font-size: 15px;
  color: var(--text);
}

.cost-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
}

.cost-flag {
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 10.5px;
}

.cost-flag.verified {
  background: var(--teal-soft, rgba(16, 145, 130, 0.14));
  border-color: var(--teal);
  color: var(--teal);
  font-weight: 600;
}

.ghost-button {
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 12.5px;
  white-space: nowrap;
  transition: border-color 0.14s ease, transform 0.1s ease;
}

.ghost-button:hover {
  border-color: var(--amber);
  transform: translateY(-1px);
}

.status-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.status-pick {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  font-size: 12.5px;
  transition: border-color 0.14s ease, background 0.14s ease, color 0.14s ease, transform 0.1s ease;
}

.status-pick::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--muted-2);
}

.status-pick.teal::before { background: var(--teal); }
.status-pick.blue::before { background: var(--blue); }
.status-pick.amber::before { background: var(--amber); }
.status-pick.red::before { background: var(--red); }
.status-pick.gray::before { background: var(--muted-2); }

.status-pick:hover {
  border-color: var(--amber);
  color: var(--text);
  transform: translateY(-1px);
}

.status-pick.is-current {
  border-color: var(--amber);
  background: var(--amber-soft);
  color: var(--amber-ink);
  box-shadow: 0 0 0 3px rgba(232, 130, 12, 0.14);
  cursor: default;
}

.delivery-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  margin-bottom: 14px;
}

.control-inline {
  display: grid;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.control-inline input {
  height: 38px;
}

.note-control {
  display: flex;
  gap: 8px;
  flex: 1;
  min-width: 240px;
}

.note-control input {
  flex: 1;
  height: 38px;
}

.note-control .primary-button {
  height: 38px;
  padding: 0 16px;
}

.delivery-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
  max-height: 220px;
  overflow: auto;
}

.event-row {
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 11px;
  align-items: start;
}

.event-dot {
  width: 10px;
  height: 10px;
  margin-top: 4px;
  border-radius: 999px;
  background: var(--muted-2);
  box-shadow: 0 0 0 3px var(--surface-2);
}

.event-dot.teal { background: var(--teal); }
.event-dot.blue { background: var(--blue); }
.event-dot.amber { background: var(--amber); }
.event-dot.red { background: var(--red); }
.event-dot.gray { background: var(--muted-2); }

.event-row strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
}

.event-meta {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--muted-2);
  font-variant-numeric: tabular-nums;
}

.event-note {
  display: block;
  margin-top: 5px;
  font-size: 12.5px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
}

.delivery-empty {
  margin: 0;
  color: var(--muted-2);
  font-size: 12.5px;
}

/* ------------------------------------------------------------------- Tables */

.table-panel {
  overflow: hidden;
}

.data-table {
  overflow: auto;
  max-height: calc(100vh - 270px);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  font-size: 13px;
  vertical-align: top;
}

tbody tr {
  transition: background 0.12s ease;
}

tbody tr:hover {
  background: var(--surface-2);
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line-strong);
}

td strong {
  display: block;
  margin-bottom: 3px;
  font-weight: 600;
}

td span {
  color: var(--muted);
  font-size: 12px;
}

/* numeric-looking table cells get mono */
td:nth-child(n+3) strong,
td:nth-child(n+3) {
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------ Loading/Toast */

.loading {
  min-height: 180px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.loading::after {
  content: "";
  width: 22px;
  height: 22px;
  margin-left: 0;
  margin-top: 12px;
  border-radius: 50%;
  border: 2.5px solid var(--line-strong);
  border-top-color: var(--amber);
  animation: spin 0.7s linear infinite;
  grid-row: 2;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(420px, calc(100vw - 40px));
  min-height: 44px;
  display: none;
  align-items: center;
  gap: 10px;
  border-radius: var(--radius-sm);
  background: var(--graphite);
  color: #f4f1ea;
  padding: 12px 16px;
  font-size: 13.5px;
  font-weight: 500;
  border-left: 3px solid var(--amber);
  box-shadow: var(--shadow-lift);
}

.toast.show {
  display: flex;
  animation: toast-in 0.24s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ------------------------------------------------------------------- Login */

.login-body {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: 100%;
  max-width: 420px;
}

.login-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 34px 30px 24px;
  box-shadow: var(--shadow-lift);
  overflow: hidden;
}

.login-card .hazard-stripe {
  height: 5px;
}

.login-head {
  display: flex;
  align-items: center;
  gap: 13px;
  margin: 8px 0 26px;
}

.login-head strong {
  display: block;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.login-head span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12.5px;
}

.login-card h1 {
  font-size: 26px;
  margin-bottom: 6px;
}

.login-sub {
  color: var(--muted);
  font-size: 13.5px;
  margin-bottom: 24px;
}

.login-form {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 7px;
}

.field input {
  height: 46px;
}

.login-error {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--red-soft);
  border: 1px solid rgba(180, 35, 24, 0.25);
  color: var(--red);
  font-size: 13px;
  font-weight: 600;
}

.login-submit {
  height: 46px;
  width: 100%;
  margin-top: 4px;
  font-size: 14.5px;
}

.login-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--muted-2);
}

.login-foot .readonly-tag {
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.18);
}

/* -------------------------------------------------------- User chip / logout */

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 6px 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.user-chip .user-info {
  display: grid;
  line-height: 1.15;
}

.user-chip .user-name {
  font-weight: 700;
  font-size: 13px;
}

.user-chip .user-role {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--amber-ink);
  font-weight: 700;
}

.logout-button {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--muted);
  transition: background 0.14s ease, color 0.14s ease;
}

.logout-button:hover {
  background: var(--red-soft);
  color: var(--red);
}

/* --------------------------------------------------------------- Responsive */

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
    padding-top: 22px;
  }

  .hazard-stripe {
    grid-column: 1 / -1;
  }

  .brand,
  .nav-tabs {
    grid-column: 1;
  }

  .sidebar-panel,
  .sidebar-visual {
    grid-column: 2;
  }

  .sidebar-foot {
    grid-column: 1 / -1;
  }

  .split-layout {
    grid-template-columns: 1fr;
  }

  .remito-list {
    max-height: 440px;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }
}

@media (max-width: 720px) {
  .workspace {
    padding: 16px;
  }

  .sidebar {
    padding: 16px;
    grid-template-columns: 1fr;
  }

  .brand,
  .nav-tabs,
  .sidebar-panel,
  .sidebar-visual,
  .sidebar-foot {
    grid-column: 1;
  }

  .topbar,
  .toolbar,
  .detail-title {
    flex-direction: column;
    align-items: stretch;
  }

  .metrics,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .search-control,
  .select-control {
    min-width: 0;
    width: 100%;
  }

  .primary-button {
    width: 100%;
  }

  .item-row {
    grid-template-columns: 1fr 1fr;
  }

  .item-name {
    grid-column: 1 / -1;
  }
}

/* ------------------------------------------------ ABM camiones / destinos */
.toolbar-note {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.entity-form {
  margin-bottom: 16px;
  padding: 16px 18px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

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

.field {
  display: grid;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.field input {
  height: 38px;
  text-transform: none;
  font-weight: 500;
  letter-spacing: normal;
}

.field.wide {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.form-hint {
  flex: 1;
  font-size: 12px;
  color: var(--muted);
  text-transform: none;
  letter-spacing: normal;
}

/* autocompletado (cliente / direccion) */
.autocomplete {
  position: relative;
}

.ac-list {
  list-style: none;
  margin: 0;
  padding: 0;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 20;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  max-height: 230px;
  overflow-y: auto;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.28);
}

.ac-list:empty {
  display: none;
}

.ac-pick {
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font-size: 12.5px;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 500;
}

.ac-pick small {
  color: var(--muted);
  margin-left: 6px;
}

.ac-pick:hover {
  background: var(--amber-soft);
}

.ac-empty {
  padding: 9px 12px;
  font-size: 12px;
  color: var(--muted);
}

.row-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  white-space: nowrap;
}

.ghost-button.danger:hover {
  border-color: var(--red);
  color: var(--red);
}

.muted-cell {
  color: var(--muted);
  font-style: italic;
}

@media (max-width: 720px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}
