:root {
  --bg: #f1ebe0;
  --surface: #fffcf5;
  --surface-2: #faf5ea;
  --ink: #1a1714;
  --ink-soft: #5b524a;
  --ink-muted: #8a7f74;
  --line: rgba(26, 23, 20, 0.12);
  --line-strong: rgba(26, 23, 20, 0.22);
  --accent: #c2410c;
  --accent-soft: #fed7aa;
  --success: #15803d;
  --success-soft: #dcfce7;
  --warn: #a16207;
  --warn-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --shadow-sm: 0 1px 2px rgba(26, 23, 20, 0.06);
  --shadow: 0 8px 24px -10px rgba(26, 23, 20, 0.18), 0 2px 6px -2px rgba(26, 23, 20, 0.08);
  --shadow-lg: 0 24px 48px -16px rgba(26, 23, 20, 0.28);
  --radius: 14px;
  --radius-sm: 8px;
  --r-lg: 22px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Manrope", -apple-system, system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  background-image:
    radial-gradient(circle at 0% 0%, rgba(194, 65, 12, 0.04), transparent 40%),
    radial-gradient(circle at 100% 100%, rgba(21, 128, 61, 0.04), transparent 40%);
}

.display { font-family: "Fraunces", Georgia, serif; letter-spacing: -0.02em; }
.mono { font-family: "JetBrains Mono", monospace; }

/* === LOGIN === */
.login-screen { display: none; min-height: 100vh; align-items: center; justify-content: center; padding: 20px; }
.login-screen.show { display: flex; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 36px 32px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.login-title {
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.login-sub { font-size: 12px; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600; margin-top: 3px; }
.login-card .form-group { margin-bottom: 14px; }
.login-card label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  margin-bottom: 6px;
}
.login-card input {
  width: 100%;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
}
.login-card input:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.login-error {
  background: var(--danger-soft);
  color: var(--danger);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  margin-bottom: 12px;
  display: none;
  font-weight: 600;
}
.login-error.show { display: block; }
.login-btn { width: 100%; justify-content: center; margin-top: 6px; padding: 13px; font-size: 14.5px; }
.login-footer { text-align: center; margin-top: 24px; font-size: 11px; color: var(--ink-muted); font-family: "JetBrains Mono", monospace; }

/* === APP SHELL === */
.app-shell { display: none; }
.app-shell.show { display: block; }

/* === HEADER === */
header.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 14px 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px;
  background: var(--ink);
  color: var(--surface);
  display: grid;
  place-items: center;
  border-radius: 10px;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.brand-mark::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 50%, var(--accent) 50%);
  opacity: 0.85;
}
.brand-mark span {
  position: relative; z-index: 1;
  font-family: "Fraunces", serif;
  font-weight: 700;
  font-size: 18px;
}
.brand-text { line-height: 1.1; }
.brand-text .name { font-family: "Fraunces", serif; font-weight: 700; font-size: 19px; letter-spacing: -0.02em; }
.brand-text .sub { font-size: 11px; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.12em; font-weight: 600; margin-top: 2px; }

nav.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 12px; border: 1px solid var(--line); }
nav.tabs button { background: transparent; border: 0; padding: 8px 16px; border-radius: 8px; font-family: inherit; font-weight: 600; font-size: 13.5px; color: var(--ink-soft); cursor: pointer; display: flex; align-items: center; gap: 8px; transition: all 0.18s ease; }
nav.tabs button:hover { color: var(--ink); }
nav.tabs button.active { background: var(--ink); color: var(--surface); box-shadow: var(--shadow-sm); }
nav.tabs .badge-count { background: rgba(255,255,255,0.18); padding: 1px 7px; border-radius: 10px; font-size: 11px; font-family: "JetBrains Mono", monospace; }
nav.tabs button:not(.active) .badge-count { background: var(--accent-soft); color: var(--accent); }

.header-spacer { flex: 1; }

.icon-btn { background: var(--surface-2); border: 1px solid var(--line); width: 38px; height: 38px; border-radius: 10px; cursor: pointer; display: grid; place-items: center; color: var(--ink); transition: all 0.15s ease; flex-shrink: 0; }
.icon-btn:hover { background: var(--ink); color: var(--surface); }

.driver-info { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.driver-info .avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), #f97316); color: var(--surface); display: grid; place-items: center; font-weight: 700; font-size: 12px; flex-shrink: 0; }
.driver-info .meta { line-height: 1.2; }
.driver-info .meta .nm { font-weight: 600; }
.driver-info .meta .vh { font-size: 11px; color: var(--ink-muted); font-family: "JetBrains Mono", monospace; }

.loading-bar { position: absolute; bottom: 0; left: 0; height: 2px; width: 0; background: var(--accent); transition: width 0.3s ease; }
.loading-bar.show { animation: loadingPulse 1.4s ease infinite; width: 60%; }
@keyframes loadingPulse {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(200%); }
}

/* === MAIN === */
main { padding: 24px 22px 40px; max-width: 1400px; margin: 0 auto; }
.view { display: none; animation: fadeIn 0.3s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 16px; margin-bottom: 22px; }
.page-head h1 { font-family: "Fraunces", serif; font-weight: 500; font-size: clamp(28px, 4vw, 42px); margin: 0 0 4px; letter-spacing: -0.03em; line-height: 1; }
.page-head h1 em { font-style: italic; color: var(--accent); }
.page-head .sub { color: var(--ink-soft); font-size: 14px; }
.page-head .sub strong { color: var(--ink); }

.filter-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chip { padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 12.5px; font-weight: 600; color: var(--ink-soft); cursor: pointer; transition: all 0.15s ease; display: inline-flex; align-items: center; gap: 6px; }
.chip:hover { border-color: var(--line-strong); color: var(--ink); }
.chip.active { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.6; }

.search-box { flex: 0 1 280px; position: relative; }
.search-box input { width: 100%; padding: 9px 12px 9px 34px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-family: inherit; font-size: 13px; color: var(--ink); transition: border-color 0.15s ease; }
.search-box input:focus { outline: none; border-color: var(--accent); }
.search-box svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-muted); }

/* === CARDS === */
.albaranes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.empty { grid-column: 1/-1; text-align: center; padding: 60px 20px; color: var(--ink-muted); }

.albaran-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; cursor: pointer; transition: all 0.2s ease; position: relative; overflow: hidden; }
.albaran-card::before { content: ''; position: absolute; top: 0; left: 0; bottom: 0; width: 3px; background: var(--ink-muted); opacity: 0.3; transition: all 0.2s ease; }
.albaran-card[data-status="pendiente"]::before { background: var(--warn); opacity: 1; }
.albaran-card[data-status="firmado"]::before { background: var(--success); opacity: 1; }
.albaran-card[data-status="incidencia"]::before { background: var(--danger); opacity: 1; }
.albaran-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line-strong); }

.albaran-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.doc-num { font-family: "JetBrains Mono", monospace; font-size: 11px; color: var(--ink-muted); font-weight: 600; letter-spacing: 0.05em; }
.doc-num strong { color: var(--ink); font-size: 13px; }
.status-badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.status-badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-pendiente { background: var(--warn-soft); color: var(--warn); }
.status-firmado { background: var(--success-soft); color: var(--success); }
.status-incidencia { background: var(--danger-soft); color: var(--danger); }

.client-name { font-family: "Fraunces", serif; font-size: 19px; font-weight: 500; line-height: 1.2; margin: 0 0 4px; letter-spacing: -0.01em; }
.client-code { font-family: "JetBrains Mono", monospace; font-size: 11px; color: var(--ink-muted); margin-bottom: 12px; }
.address { display: flex; gap: 8px; align-items: flex-start; color: var(--ink-soft); font-size: 13px; line-height: 1.4; margin-bottom: 14px; }
.address svg { flex-shrink: 0; margin-top: 2px; color: var(--ink-muted); }

.albaran-foot { display: flex; justify-content: space-between; align-items: center; padding-top: 12px; border-top: 1px dashed var(--line); }
.items-count { font-size: 12px; color: var(--ink-soft); display: flex; align-items: center; gap: 5px; }
.total { font-family: "Fraunces", serif; font-weight: 700; font-size: 18px; letter-spacing: -0.02em; }
.total .cur { font-size: 12px; color: var(--ink-muted); margin-left: 2px; font-weight: 500; }

/* === RUTAS === */
.rutas-layout { display: grid; grid-template-columns: 1fr 380px; gap: 20px; align-items: start; }
@media (max-width: 980px) { .rutas-layout { grid-template-columns: 1fr; } }

.map-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); }
.map-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; }
.map-card-head h3 { margin: 0; font-family: "Fraunces", serif; font-weight: 500; font-size: 22px; letter-spacing: -0.02em; }
.map-stats { display: flex; gap: 18px; font-size: 12px; color: var(--ink-soft); }
.map-stats div { display: flex; flex-direction: column; gap: 2px; }
.map-stats .v { font-family: "JetBrains Mono", monospace; color: var(--ink); font-weight: 700; font-size: 16px; }
.map-stats .l { text-transform: uppercase; letter-spacing: 0.08em; font-size: 10px; font-weight: 600; color: var(--ink-muted); }

#map { height: 460px; border-radius: var(--radius-sm); border: 1px solid var(--line); z-index: 1; }

.ruta-marker { width: 28px; height: 28px; background: var(--ink); color: var(--surface); border: 2px solid var(--surface); border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; font-family: "JetBrains Mono", monospace; box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
.ruta-marker.done { background: var(--success); }
.ruta-marker.next { background: var(--accent); transform: scale(1.15); }

.ruta-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); position: sticky; top: 90px; max-height: calc(100vh - 110px); overflow-y: auto; }
.ruta-panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.ruta-panel-head h3 { margin: 0; font-family: "Fraunces", serif; font-size: 19px; font-weight: 500; letter-spacing: -0.02em; }
.btn-optimize { background: var(--ink); color: var(--surface); border: 0; padding: 7px 14px; border-radius: 8px; font-family: inherit; font-size: 12px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: transform 0.15s ease; }
.btn-optimize:hover { transform: scale(1.03); }
.btn-optimize:active { transform: scale(0.98); }

.ruta-list { display: flex; flex-direction: column; gap: 8px; }
.ruta-stop { display: flex; gap: 12px; padding: 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid transparent; cursor: grab; transition: all 0.18s ease; align-items: flex-start; }
.ruta-stop:hover { border-color: var(--line); }
.ruta-stop.dragging { opacity: 0.4; cursor: grabbing; }
.ruta-stop.drag-over { border-color: var(--accent); border-style: dashed; }

.stop-num { flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: var(--surface); display: grid; place-items: center; font-family: "JetBrains Mono", monospace; font-size: 12px; font-weight: 700; }
.ruta-stop[data-status="firmado"] .stop-num { background: var(--success); }
.ruta-stop[data-status="incidencia"] .stop-num { background: var(--danger); }
.stop-info { flex: 1; min-width: 0; }
.stop-info .nm { font-weight: 600; font-size: 13.5px; line-height: 1.25; margin-bottom: 2px; }
.stop-info .ad { font-size: 11.5px; color: var(--ink-muted); line-height: 1.3; }
.stop-info .meta-row { display: flex; gap: 10px; margin-top: 6px; font-size: 10.5px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; flex-wrap: wrap; }
.grip { color: var(--ink-muted); cursor: grab; align-self: center; opacity: 0.5; }
.ruta-stop:hover .grip { opacity: 1; }

.ruta-summary { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; text-align: center; }
.ruta-summary div .v { font-family: "JetBrains Mono", monospace; font-weight: 700; font-size: 16px; }
.ruta-summary div .l { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-muted); font-weight: 600; }

/* === MODAL === */
.modal-overlay { position: fixed; inset: 0; background: rgba(26, 23, 20, 0.55); backdrop-filter: blur(4px); z-index: 100; display: none; align-items: center; justify-content: center; padding: 20px; animation: fadeIn 0.2s ease; }
.modal-overlay.open { display: flex; }
.modal { background: var(--surface); border-radius: var(--r-lg); width: 100%; max-width: 580px; max-height: 92vh; overflow-y: auto; box-shadow: var(--shadow-lg); animation: slideUp 0.25s ease; position: relative; }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-head { padding: 22px 24px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: flex-start; }
.modal-head h2 { margin: 0; font-family: "Fraunces", serif; font-weight: 500; font-size: 26px; letter-spacing: -0.02em; line-height: 1.1; }
.modal-head .doc { font-family: "JetBrains Mono", monospace; font-size: 11px; color: var(--ink-muted); margin-top: 4px; font-weight: 600; }
.modal-close { background: var(--surface-2); border: 1px solid var(--line); width: 34px; height: 34px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; color: var(--ink); transition: all 0.15s ease; }
.modal-close:hover { background: var(--ink); color: var(--surface); }

.modal-body { padding: 20px 24px; }
.modal-section { margin-bottom: 18px; }
.modal-section:last-child { margin-bottom: 0; }
.modal-section h4 { margin: 0 0 8px; font-size: 11px; font-weight: 700; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.1em; }

.info-row { display: flex; justify-content: space-between; padding: 7px 0; font-size: 13.5px; border-bottom: 1px dashed var(--line); gap: 12px; }
.info-row:last-child { border-bottom: 0; }
.info-row .l { color: var(--ink-soft); flex-shrink: 0; }
.info-row .v { font-weight: 600; text-align: right; }
.info-row .v.mono { font-family: "JetBrains Mono", monospace; font-size: 12.5px; }

.items-table { background: var(--surface-2); border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.item-row { display: grid; grid-template-columns: 50px 1fr auto; gap: 10px; padding: 10px 12px; font-size: 13px; align-items: center; border-bottom: 1px solid var(--line); }
.item-row:last-child { border-bottom: 0; }
.item-qty { font-family: "JetBrains Mono", monospace; font-weight: 700; font-size: 13px; color: var(--accent); background: var(--accent-soft); padding: 2px 6px; border-radius: 5px; text-align: center; }
.item-desc { line-height: 1.2; }
.item-desc .code { font-size: 10.5px; color: var(--ink-muted); font-family: "JetBrains Mono", monospace; }
.item-price { font-family: "JetBrains Mono", monospace; font-weight: 600; font-size: 12.5px; }
.item-row.total-row { background: var(--ink); color: var(--surface); font-weight: 700; }
.item-row.total-row .item-qty { background: rgba(255,255,255,0.15); color: var(--surface); }
.item-row.total-row .item-price { font-size: 16px; font-family: "Fraunces", serif; }

.signature-area { border: 2px dashed var(--line-strong); border-radius: 12px; background: var(--surface-2); padding: 6px; position: relative; }
#signaturePad { width: 100%; height: 200px; background: var(--surface); border-radius: 8px; cursor: crosshair; touch-action: none; display: block; }
.sig-empty { position: absolute; inset: 6px; display: grid; place-items: center; color: var(--ink-muted); font-size: 13px; pointer-events: none; text-align: center; border-radius: 8px; }
.sig-empty svg { display: block; margin: 0 auto 6px; opacity: 0.4; }
.signature-area.has-sig .sig-empty { display: none; }

.sig-controls { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; flex-wrap: wrap; gap: 8px; }
.sig-name { flex: 1 1 200px; }
.sig-name input { width: 100%; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); font-family: inherit; font-size: 13px; color: var(--ink); }
.sig-name input:focus { outline: none; border-color: var(--accent); }
.btn-clear { background: transparent; border: 1px solid var(--line); padding: 8px 12px; border-radius: 8px; font-family: inherit; font-size: 12px; font-weight: 600; cursor: pointer; color: var(--ink-soft); display: inline-flex; align-items: center; gap: 5px; }
.btn-clear:hover { background: var(--surface-2); color: var(--ink); }

.modal-foot { padding: 16px 24px 22px; background: var(--surface-2); border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.btn { padding: 11px 20px; border-radius: 10px; border: 0; font-family: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer; transition: all 0.15s ease; display: inline-flex; align-items: center; gap: 7px; }
.btn-secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn-secondary:hover { border-color: var(--line-strong); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: var(--surface); }
.btn-primary { background: var(--accent); color: var(--surface); box-shadow: 0 4px 12px rgba(194, 65, 12, 0.3); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(194, 65, 12, 0.4); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.loader-overlay { position: absolute; inset: 0; background: rgba(255, 252, 245, 0.88); display: none; align-items: center; justify-content: center; flex-direction: column; gap: 12px; z-index: 5; border-radius: var(--r-lg); backdrop-filter: blur(2px); }
.loader-overlay.show { display: flex; }
.spinner { width: 32px; height: 32px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loader-overlay .lbl { font-size: 13px; color: var(--ink-soft); font-weight: 600; }

/* === TOAST === */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(100px); background: var(--ink); color: var(--surface); padding: 12px 20px; border-radius: 12px; font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow-lg); z-index: 200; display: flex; align-items: center; gap: 10px; transition: transform 0.3s ease; pointer-events: none; }
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.warn { background: var(--warn); }

/* === PANEL ADMIN === */
.admin-grid { display: grid; grid-template-columns: 1fr 1fr 2fr; gap: 14px; margin-bottom: 22px; }
@media (max-width: 760px) { .admin-grid { grid-template-columns: 1fr; } }

.admin-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); margin-bottom: 18px; }
.admin-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.admin-card-head h3 { margin: 0; font-family: "Fraunces", serif; font-size: 18px; font-weight: 500; letter-spacing: -0.01em; }

.stat-card { padding: 22px; }
.stat-label { font-size: 11px; font-weight: 700; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 8px; }
.stat-value { font-family: "Fraunces", serif; font-weight: 500; font-size: 42px; line-height: 1; letter-spacing: -0.03em; color: var(--accent); }
.stat-card-wide { padding: 18px 22px; }
.stat-list { display: flex; flex-direction: column; gap: 6px; max-height: 110px; overflow-y: auto; }
.stat-list .kv { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.stat-list .kv:last-child { border-bottom: 0; }
.stat-list .kv strong { font-family: "JetBrains Mono", monospace; color: var(--accent); }

.btn-small { padding: 6px 12px; font-size: 12.5px; }

.table-wrap { overflow-x: auto; margin: 0 -18px -18px; padding: 0 18px 18px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table thead { border-bottom: 2px solid var(--line); }
.data-table th { text-align: left; padding: 9px 12px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-muted); }
.data-table td { padding: 11px 12px; border-bottom: 1px solid var(--line); }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tr:hover { background: var(--surface-2); }
.data-table .actions { text-align: right; white-space: nowrap; }
.data-table .mono { font-family: "JetBrains Mono", monospace; font-size: 11.5px; }

.btn-mini { background: var(--surface-2); border: 1px solid var(--line); padding: 4px 10px; border-radius: 6px; font-size: 11.5px; font-weight: 600; cursor: pointer; color: var(--ink); margin-left: 4px; transition: all 0.15s ease; font-family: inherit; }
.btn-mini:hover { background: var(--ink); color: var(--surface); }
.btn-mini-danger:hover { background: var(--danger); color: var(--surface); }

.role-badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.role-driver { background: var(--surface-2); color: var(--ink-soft); }
.role-admin { background: var(--accent-soft); color: var(--accent); }

.input-inline { padding: 7px 11px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); font-family: inherit; font-size: 12.5px; min-width: 200px; }
.input-inline:focus { outline: none; border-color: var(--accent); }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-muted); margin-bottom: 6px; }
.form-group input, .form-group select { width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); font-family: inherit; font-size: 13.5px; color: var(--ink); }
.form-group input:focus, .form-group select:focus { outline: none; border-color: var(--accent); }
.form-group input:disabled { background: var(--surface-2); color: var(--ink-muted); }
.form-group .hint { font-size: 11.5px; color: var(--ink-muted); margin-top: 5px; }

/* === RESPONSIVE === */
@media (max-width: 640px) {
  header.app-header { padding: 12px 14px; gap: 10px; flex-wrap: wrap; }
  .driver-info .meta { display: none; }
  nav.tabs { width: 100%; order: 3; }
  nav.tabs button { flex: 1; justify-content: center; padding: 8px 8px; font-size: 12.5px; }
  main { padding: 18px 14px 30px; }
  .albaranes-grid { grid-template-columns: 1fr; }
  .modal { max-height: 100vh; border-radius: 0; }
  .modal-head h2 { font-size: 22px; }
  .item-row { grid-template-columns: 40px 1fr auto; font-size: 12px; }
  .ruta-panel { position: static; }
}

/* leaflet overrides */
.leaflet-container { font-family: "Manrope", sans-serif; background: #f1ebe0; }
.leaflet-popup-content-wrapper { border-radius: 12px; box-shadow: var(--shadow); }
.leaflet-popup-content { margin: 12px 14px; font-size: 13px; line-height: 1.4; }
.leaflet-popup-content strong { font-family: "Fraunces", serif; font-size: 15px; }

/* === SUB-TABS DEL PANEL ADMIN === */
.subtabs {
  display: flex;
  gap: 2px;
  margin: 0 0 18px;
  padding: 4px;
  background: var(--surface-2);
  border-radius: 10px;
  border: 1px solid var(--line);
  overflow-x: auto;
}
.subtab {
  flex: 1;
  min-width: 110px;
  padding: 9px 14px;
  border: none;
  background: transparent;
  border-radius: 7px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
}
.subtab:hover { color: var(--ink); }
.subtab.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.subview { display: none; }
.subview.active { display: block; }

/* === FORM ROWS Y SECCIONES === */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row.three { grid-template-columns: 1fr 1fr 1fr; }
.form-row .form-group { margin-bottom: 14px; }
.form-section {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin-top: 18px;
}
.form-section h4 {
  font-family: "Fraunces", serif;
  font-size: 17px;
  margin: 0 0 14px;
}
.hint.inline { display: inline; font-weight: normal; text-transform: none; letter-spacing: 0; }

/* Textarea */
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-family: "Roboto Mono", monospace;
  font-size: 12.5px;
  color: var(--ink);
  resize: vertical;
}
.form-group textarea:focus { outline: none; border-color: var(--accent); }

/* Color input */
.form-group input[type="color"] {
  width: 100%;
  height: 38px;
  padding: 4px;
  cursor: pointer;
}

/* === CHECKBOX GRID PARA ZONAS === */
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  min-height: 50px;
  max-height: 220px;
  overflow-y: auto;
}
.checkbox-grid label {
  display: flex !important;
  align-items: center;
  gap: 7px;
  padding: 5px 8px;
  font-size: 12.5px !important;
  font-weight: 500 !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
  color: var(--ink) !important;
  cursor: pointer;
  border-radius: 6px;
  transition: background .12s;
}
.checkbox-grid label:hover { background: var(--surface); }
.checkbox-grid input[type="checkbox"] {
  width: auto !important;
  margin: 0;
  cursor: pointer;
}
.checkbox-grid .zone-pill {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* === TAGS Y CHIPS === */
.muted-tag {
  font-size: 11.5px;
  color: var(--ink-muted);
  font-weight: 500;
}
.zone-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 11.5px;
  font-weight: 600;
  margin: 2px;
}
.zone-chip-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.coord-source {
  font-size: 10.5px;
  color: var(--ink-muted);
  margin-left: 4px;
}
.coord-source.manual { color: #c2410c; font-weight: 600; }

/* === BOTONES PEQUEÑOS DE ACCIÓN EN TABLA === */
.action-btn {
  padding: 5px 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  transition: all .12s;
}
.action-btn:hover { background: var(--surface-2); border-color: var(--ink-muted); }
.action-btn.danger:hover { background: #fef2f2; color: #dc2626; border-color: #fca5a5; }

.btn-danger {
  padding: 9px 18px;
  border: 1px solid #fca5a5;
  background: #fef2f2;
  color: #dc2626;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
}
.btn-danger:hover { background: #fee2e2; }

/* === COBERTURA GRID DEL DASHBOARD === */
.coverage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}
.coverage-tile {
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.coverage-tile.warn { border-color: #fbbf24; background: #fffbeb; }
.coverage-tile.error { border-color: #f87171; background: #fef2f2; }
.coverage-tile-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  margin-bottom: 6px;
}
.coverage-tile-value {
  font-family: "Fraunces", serif;
  font-size: 28px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1;
}
.coverage-tile-detail {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 4px;
}

/* === RESPONSIVE PARA FORMULARIOS === */
@media (max-width: 640px) {
  .form-row, .form-row.three { grid-template-columns: 1fr; }
  .subtabs { padding: 3px; }
  .subtab { font-size: 12px; padding: 7px 8px; min-width: 90px; }
}

/* === BANNER INFORMATIVO === */
.info-banner {
  padding: 12px 14px;
  background: #fef9c3;
  border: 1px solid #fde047;
  border-radius: 8px;
  font-size: 13px;
  color: #78350f;
  margin: 0 0 14px;
  line-height: 1.45;
}

/* === BADGE DE CUENTA EN SUB-TABS === */
.badge-count {
  display: inline-block;
  min-width: 18px;
  padding: 1px 6px;
  margin-left: 5px;
  background: #f87171;
  color: white;
  border-radius: 10px;
  font-size: 10.5px;
  font-weight: 700;
  text-align: center;
  vertical-align: 1px;
}
.badge-count:empty { display: none; }

/* === BADGE DE ESTADO DE DECISIÓN === */
.decision-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11.5px;
  font-weight: 600;
}
.decision-badge.pending {
  background: #fef3c7;
  color: #78350f;
  border: 1px solid #fde68a;
}
.decision-badge.manual {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #93c5fd;
}
.decision-badge.external {
  background: #f3e8ff;
  color: #6b21a8;
  border: 1px solid #d8b4fe;
}

/* ====================================================================
   PESTAÑA PLANIFICAR
   ==================================================================== */

/* Controles superiores */
.planning-controls {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.planning-controls-row {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  flex-wrap: wrap;
  justify-content: space-between;
}
.planning-options {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.opt-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}
.opt-field input[type="time"],
.opt-field input[type="number"] {
  padding: 7px 9px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  width: 95px;
}
.opt-field-check {
  flex-direction: row;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--ink);
  padding: 7px 0;
}
.opt-field-check input { cursor: pointer; }

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

.planning-status {
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--ink-muted);
  font-style: italic;
}
.planning-status.error { color: #dc2626; font-style: normal; }
.planning-status.success { color: #15803d; font-style: normal; }

/* Estado vacío */
.planning-empty {
  text-align: center;
  padding: 60px 20px;
  background: var(--surface-2);
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: var(--ink-muted);
}
.planning-empty .empty-icon {
  width: 72px; height: 72px; margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--surface);
  color: var(--ink-muted);
}
.planning-empty h3 {
  font-family: "Fraunces", serif;
  font-weight: 500;
  margin: 0 0 6px;
  color: var(--ink);
}
.planning-empty p {
  margin: 0;
  font-size: 13.5px;
  max-width: 460px;
  margin: 0 auto;
}

/* Layout principal de planificar */
.planning-grid {
  display: grid;
  grid-template-columns: minmax(420px, 5fr) minmax(380px, 7fr);
  gap: 16px;
  align-items: start;
}

.planning-left { min-width: 0; }
.planning-right {
  position: sticky;
  top: 14px;
}

#planningMap {
  height: 680px;
  border-radius: 12px;
  border: 1px solid var(--line);
  overflow: hidden;
  background: #f1ebe0;
}

@media (max-width: 1100px) {
  .planning-grid { grid-template-columns: 1fr; }
  .planning-right { position: static; }
  #planningMap { height: 480px; }
}

/* Resumen al inicio */
.planning-summary {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.psum-pill {
  flex: 1;
  min-width: 105px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  text-align: center;
}
.psum-pill .v {
  font-family: "Fraunces", serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1;
}
.psum-pill .l {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
  color: var(--ink-muted);
  margin-top: 4px;
}
.psum-pill.warn { background: #fffbeb; border-color: #fcd34d; }
.psum-pill.warn .v { color: #b45309; }
.psum-pill.danger { background: #fef2f2; border-color: #fca5a5; }
.psum-pill.danger .v { color: #b91c1c; }
.psum-pill.success { background: #f0fdf4; border-color: #86efac; }
.psum-pill.success .v { color: #15803d; }

/* Tarjeta de ruta */
.route-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 12px;
  overflow: hidden;
}
.route-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.route-color-bar {
  width: 6px;
  align-self: stretch;
  border-radius: 3px;
  flex-shrink: 0;
}
.route-driver {
  flex: 1;
  min-width: 0;
}
.route-driver h4 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--ink);
  font-family: inherit;
}
.route-driver .meta {
  font-size: 11.5px;
  color: var(--ink-muted);
  margin-top: 2px;
}
.route-stats {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--ink-muted);
}
.route-stats strong {
  display: block;
  font-family: "Fraunces", serif;
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
}
.route-actions {
  display: flex;
  gap: 6px;
}

.route-stops {
  list-style: none;
  margin: 0;
  padding: 0;
}
.route-stop {
  display: grid;
  grid-template-columns: 30px 50px 1fr auto;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  gap: 10px;
}
.route-stop:last-child { border-bottom: none; }
.route-stop:hover { background: var(--surface-2); }

.route-stop input[type="checkbox"] { cursor: pointer; }
.route-stop .stop-num {
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 700;
  color: white;
}
.route-stop .stop-time {
  font-family: "Roboto Mono", monospace;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
}
.route-stop .stop-info { min-width: 0; }
.route-stop .stop-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.route-stop .stop-addr {
  font-size: 11.5px;
  color: var(--ink-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.route-stop .stop-tags {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.tag-manual {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.tag-old {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
}
/* Variante para entregas vencidas (rojo) — el por defecto ya es rojo, pero
   por claridad lo dejamos explícito. */
.tag-overdue {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fca5a5;
}
/* Variante para entregas futuras (azul tenue) — visualmente distintas
   del vencido para que el admin las identifique de un vistazo. */
.tag-future {
  background: #dbeafe;
  color: #1e40af;
  border-color: #93c5fd;
}

/* Bandejas laterales (aplazados, externos, etc.) */
.tray-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-top: 12px;
  overflow: hidden;
}
.tray-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  cursor: pointer;
  user-select: none;
}
.tray-card-head h4 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tray-card-head .tray-count {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 11px;
  font-family: "Roboto Mono", monospace;
}
.tray-card.warn .tray-card-head { background: #fffbeb; }
.tray-card.warn .tray-count { background: #fef3c7; border-color: #fde68a; }
.tray-card-body {
  padding: 0;
}
.tray-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.tray-item {
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
}
.tray-item:last-child { border-bottom: none; }
.tray-item .doc { font-weight: 700; }
.tray-item .name { color: var(--ink-muted); }
.tray-item .reason {
  display: block;
  color: var(--ink-muted);
  font-size: 11.5px;
  margin-top: 3px;
  font-style: italic;
}

/* === Iconos del mapa === */
.map-warehouse-icon {
  background: white;
  border: 2px solid #1f2937;
  width: 26px !important;
  height: 26px !important;
  border-radius: 4px;
  display: flex !important;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 11px;
  color: #1f2937;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.map-stop-icon {
  background: white;
  border: 2px solid;
  width: 22px !important;
  height: 22px !important;
  border-radius: 50%;
  display: flex !important;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 10px;
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.map-stop-icon.manual {
  background: #fde68a;
}
.map-stop-icon.manual::after {
  content: "★";
  position: absolute;
  top: -8px;
  right: -8px;
  font-size: 14px;
  color: #d97706;
}

/* === BOTÓN PUBLICAR === */
.btn-publish {
  padding: 9px 18px;
  border: 1px solid #16a34a;
  background: #16a34a;
  color: white;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-publish:hover:not(:disabled) { background: #15803d; }
.btn-publish:disabled {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--ink-muted);
  cursor: not-allowed;
}

/* === BADGE PUBLICADA EN TARJETA DE RUTA === */
.route-published {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-left: 8px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.route-published.stale {
  background: #fef3c7;
  color: #92400e;
  border-color: #fcd34d;
}

/* === BANNER DE RUTA PUBLICADA EN VISTA REPARTIDOR === */
.driver-route-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
  border: 1px solid #86efac;
  border-radius: 12px;
  margin-bottom: 16px;
}
.driver-route-banner .icon {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: #16a34a;
  color: white;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.driver-route-banner .text { flex: 1; min-width: 0; }
.driver-route-banner .text h4 {
  margin: 0 0 2px;
  font-family: "Fraunces", serif;
  font-size: 17px;
  color: #14532d;
}
.driver-route-banner .text .meta {
  font-size: 12.5px;
  color: #166534;
}

/* === NÚMERO DE PARADA EN TARJETA DE ALBARÁN (vista driver) === */
.albaran-card .stop-number {
  position: absolute;
  top: 12px;
  left: 14px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #1f2937;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  font-family: "Roboto Mono", monospace;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  z-index: 1;
}
.albaran-card.has-stop-number {
  padding-left: 56px;
}
.albaran-card .albaran-arrival {
  font-size: 11.5px;
  color: var(--ink-muted);
  font-family: "Roboto Mono", monospace;
  margin-top: 4px;
}

/* === SEPARADOR ENTRE VIAJES (multi-trip) === */
.trip-separator {
  list-style: none;
  padding: 8px 14px;
  background: #fef9c3;
  color: #78350f;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-top: 1px dashed #fde047;
  border-bottom: 1px dashed #fde047;
  text-align: center;
}
.trip-separator.first-trip {
  background: #ecfdf5;
  color: #14532d;
  border-color: #86efac;
  border-top: none;
}

/* === SEPARADOR DE VIAJES EN LA RUTA DEL DRIVER === */
.ruta-trip-separator {
  padding: 7px 12px;
  margin: 8px 0 6px;
  background: #fef9c3;
  color: #78350f;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px dashed #fde047;
  border-radius: 6px;
  text-align: center;
}
.ruta-trip-separator.first-trip {
  background: #ecfdf5;
  color: #14532d;
  border-color: #86efac;
}

/* Paradas bloqueadas (no se pueden reordenar - planificación publicada) */
.ruta-stop.locked {
  cursor: pointer;
}
.ruta-stop.locked:hover { background: var(--surface-2); }
.ruta-stop.locked .grip { display: none; }

/* Etiqueta de manual en paradas del driver */
.ruta-manual-tag {
  display: inline-block;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-left: 6px;
  vertical-align: 1px;
}

/* === MENSAJE: DRIVER SIN RUTA HOY === */
.empty.no-route {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 30px;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--ink-muted);
}
.empty.no-route .no-route-icon {
  width: 80px; height: 80px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-muted);
}
.empty.no-route h3 {
  font-family: "Fraunces", serif;
  font-weight: 500;
  font-size: 22px;
  margin: 0 0 8px;
  color: var(--ink);
}
.empty.no-route p {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  max-width: 480px;
  margin: 0 auto;
}

/* === FACTURAS RECHAZADAS === */
.badge-count.badge-red {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}
.error-cell {
  max-width: 380px;
  font-size: 12px;
  color: #b91c1c;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  word-break: break-word;
  line-height: 1.4;
}
.empty-row {
  text-align: center;
  padding: 28px;
  color: var(--ink-muted);
  font-style: italic;
}
.muted-sm {
  font-size: 11px;
  color: var(--ink-muted);
  margin-top: 2px;
}
.row-actions {
  white-space: nowrap;
  text-align: right;
}
.btn-mini {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 5px;
  cursor: pointer;
  border: 1px solid transparent;
  margin-left: 4px;
}
.btn-mini.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-mini.btn-primary:hover { filter: brightness(1.05); }
.btn-mini.btn-primary:disabled { opacity: 0.6; cursor: wait; }
.btn-mini.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink-muted);
}
.btn-mini.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.sub-text {
  font-size: 12.5px;
  color: var(--ink-muted);
  margin: 4px 0 0;
}

/* === Logo Albaran360 (tamaño medio) === */
.brand-mark.a360 {
  width: auto !important;
  height: 58px !important;
  min-width: 116px !important;
  padding: 0 22px !important;
  border-radius: 12px !important;
}
.brand-mark.a360 span {
  font-size: 26px !important;
  letter-spacing: 1px !important;
  font-weight: 800 !important;
  font-family: "Fraunces", Georgia, serif !important;
  color: #fdf6e8 !important;
}


/* ===== Botones de Google Maps (anadidos por mejora-02b) ===== */

.btn-maps {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  margin-right: 6px;
  background: #fff;
  color: #1a73e8;
  border: 1px solid #dadce0;
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-maps:hover {
  background: #f0f6ff;
  border-color: #1a73e8;
}

/* Boton "Ir": flotante a la derecha del card, siempre visible */
.stop-actions {
  position: absolute;
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
}

/* La parada padre necesita position:relative para que el boton flote dentro */
.ruta-stop {
  position: relative;
}

.btn-goto-stop {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: #1a73e8;
  color: #fff;
  border: none;
  border-radius: 8px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 1px 3px rgba(26,115,232,0.25);
}
.btn-goto-stop:hover {
  background: #1557b0;
}
.btn-goto-stop:active {
  transform: scale(0.96);
}

/* En movil, mas compacto y separado del borde de la pantalla */
@media (max-width: 720px) {
  .stop-actions {
    right: 10px;
  }
  .btn-goto-stop {
    padding: 7px 10px;
    font-size: 11.5px;
  }
  .btn-goto-stop svg {
    width: 11px;
    height: 11px;
  }
  /* La info del stop necesita margen a la derecha para no quedar tapada por el boton */
  .ruta-stop .stop-info {
    padding-right: 60px;
  }
}

/* En desktop tambien necesita un margen menor */
.ruta-stop .stop-info {
  padding-right: 70px;
}


/* ===== Etiquetas de tipo de mision (mejora 4) ===== */
.mission-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
  margin-right: 6px;
  vertical-align: middle;
  border: 1px solid transparent;
}
.mission-delivery {
  background: #e8f1ff;
  color: #1a4d9e;
  border-color: #b7d0f0;
}
.mission-return {
  background: #fff3e6;
  color: #b35900;
  border-color: #f5c98a;
}
.mission-pickup {
  background: #e6f7ee;
  color: #166534;
  border-color: #a8dec0;
}


/* === Mejora 4 Fase C: boton "+ Devolucion" y modal de creacion === */
.tabs .btn-new-return {
  background: linear-gradient(135deg, #ff9800 0%, #f57c00 100%);
  color: #fff;
  border: none;
  font-weight: 600;
  margin-left: 8px;
  padding: 8px 14px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: transform 0.1s, box-shadow 0.1s;
}
.tabs .btn-new-return:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(255,152,0,0.4);
}
.tabs .btn-new-return:active {
  transform: translateY(0);
}
#newReturnModal .info-row .v.mono {
  font-family: 'SF Mono', Consolas, monospace;
  font-size: 13px;
}
#nrLines .item-row {
  display: grid;
  grid-template-columns: 60px 1fr 90px;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
}
#nrLines .item-row:last-child {
  border-bottom: none;
}
#nrLines .item-qty-input {
  width: 80px;
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 14px;
  text-align: right;
}
#nrLines .item-qty-max {
  font-size: 11px;
  color: #888;
  text-align: right;
  margin-top: 2px;
}
#newReturnModal #nrSigArea {
  position: relative;
  background: #fafafa;
  border: 2px dashed #ccc;
  border-radius: 8px;
  height: 200px;
  overflow: hidden;
}
#newReturnModal #nrSigPad {
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}
