:root {
  --bg: #0f141b; --panel: #171e28; --panel2: #1e2733; --line: #2a3544;
  --text: #e6edf5; --muted: #93a1b3; --accent: #5aa2ff; --accent-ink: #06121f;
  --red: #ff6b6b; --red-bg: #3a1c20; --yellow: #ffcc4d; --yellow-bg: #3a3017;
  --green: #4cd68a; --green-bg: #15322a; --grey: #8b98a9; --grey-bg: #232c38;
  --radius: 12px; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 22px; margin: 0 0 4px; } h2 { font-size: 17px; margin: 0 0 10px; } h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* barra superior */
.topbar { position: sticky; top: 0; z-index: 20; background: #121923; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 4px; padding: 0 12px; overflow-x: auto; }
.brand { font-weight: 700; margin-right: 12px; white-space: nowrap; padding: 14px 0; }
.topbar a.nav { color: var(--muted); padding: 14px 12px; white-space: nowrap; border-bottom: 3px solid transparent; }
.topbar a.nav.on { color: var(--text); border-color: var(--accent); }
.topbar .spacer { flex: 1; }
.userbox { display: flex; gap: 10px; align-items: center; white-space: nowrap; }
main { max-width: 1280px; margin: 0 auto; padding: 18px 14px 60px; }
.pagehead { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.pagehead .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* tarjetas y rejillas */
.grid { display: grid; gap: 14px; }
.g-cards { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.g-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat { display: block; color: inherit; }
.stat .n { font-size: 36px; font-weight: 700; line-height: 1.1; }
.stat .l { color: var(--muted); font-size: 13px; }
.stat.red { background: var(--red-bg); border-color: #5b2a30; } .stat.red .n { color: var(--red); }
.stat.yellow { background: var(--yellow-bg); border-color: #5b4b1f; } .stat.yellow .n { color: var(--yellow); }
.stat.green { background: var(--green-bg); border-color: #1f4a3b; } .stat.green .n { color: var(--green); }
.stat.grey .n { color: var(--grey); }

/* semáforo: color + icono + texto, para no depender solo del color */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge::before { font-size: 11px; }
.b-vencido { background: var(--red-bg); color: var(--red); } .b-vencido::before { content: "▲"; }
.b-por_vencer { background: var(--yellow-bg); color: var(--yellow); } .b-por_vencer::before { content: "●"; }
.b-al_dia { background: var(--green-bg); color: var(--green); } .b-al_dia::before { content: "✔"; }
.b-sin_datos { background: var(--grey-bg); color: var(--grey); } .b-sin_datos::before { content: "?"; }
.b-info { background: #172a44; color: var(--accent); }
.b-recibido { background: #172a44; color: var(--accent); }
.b-en_progreso { background: #2d2347; color: #b79bff; }
.b-esperando_repuesto { background: var(--yellow-bg); color: var(--yellow); }
.b-listo { background: var(--green-bg); color: var(--green); }
.b-entregado { background: var(--grey-bg); color: var(--grey); }
.b-anulado { background: var(--grey-bg); color: var(--grey); text-decoration: line-through; }

/* tablas */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; background: var(--panel2); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--panel2); }

/* formularios */
label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 4px; }
input, select, textarea { width: 100%; background: #0f151d; color: var(--text); border: 1px solid var(--line); border-radius: 9px; padding: 11px 12px; font: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
textarea { min-height: 84px; resize: vertical; }
input[type=checkbox] { width: 20px; height: 20px; padding: 0; accent-color: var(--accent); flex: none; }
.field { margin-bottom: 14px; }
.row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.checks { display: grid; gap: 6px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.check { display: flex; align-items: center; gap: 9px; padding: 9px 10px; background: #0f151d; border: 1px solid var(--line); border-radius: 9px; color: var(--text); font-size: 14px; margin: 0; cursor: pointer; }
.check:has(input:checked) { border-color: var(--accent); background: #12233a; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 9px; padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer; min-height: 42px; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--red); } .btn.small { min-height: 34px; padding: 6px 11px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: default; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.filters > * { flex: 1 1 160px; max-width: 280px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tab { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); cursor: pointer; background: transparent; font: inherit; }
.tab.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }

/* tarjetas de orden (celular) */
.ocard { display: block; color: inherit; cursor: pointer; }
.ocard:hover { border-color: var(--accent); }
.ocard .top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.ocard .title { font-weight: 700; font-size: 17px; }

/* modal */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .65); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 18px 10px; overflow-y: auto; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; width: 100%; max-width: 760px; padding: 20px; }
.modal .head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; white-space: pre-wrap; }

/* barras / dona */
.bar { display: grid; grid-template-columns: minmax(120px, 1.4fr) 3fr 36px; gap: 10px; align-items: center; margin: 7px 0; font-size: 14px; }
.bar .track { background: #0f151d; border-radius: 6px; height: 14px; overflow: hidden; } .bar .fill { height: 100%; background: var(--red); border-radius: 6px; }
.donut { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.legend div { display: flex; align-items: center; gap: 8px; margin: 4px 0; font-size: 14px; }
.dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: #223044; border: 1px solid var(--line); padding: 11px 18px; border-radius: 10px; z-index: 99; max-width: 92vw; }
.toast.err { background: var(--red-bg); border-color: #5b2a30; color: #ffd0d0; }
.empty { text-align: center; color: var(--muted); padding: 36px 12px; }
.loginbox { max-width: 400px; margin: 9vh auto; padding: 0 14px; }
.notice { background: #172a44; border: 1px solid #25456f; border-radius: 10px; padding: 10px 14px; font-size: 14px; margin-bottom: 14px; }
.notice.warn { background: var(--yellow-bg); border-color: #5b4b1f; }
pre.share { background: #0f151d; border: 1px solid var(--line); border-radius: 10px; padding: 12px; max-height: 300px; overflow: auto; white-space: pre-wrap; font: 13px/1.5 ui-monospace, Consolas, monospace; }

@media (max-width: 640px) {
  main { padding: 14px 10px 60px; }
  .kv { grid-template-columns: 1fr; } .kv dt { margin-top: 6px; }
  .stat .n { font-size: 30px; }
  .modal { padding: 14px; }
}

/* Bitácora: usa todo el ancho de la pantalla */
main.wide { max-width: 100vw; padding-left: 8px; padding-right: 8px; }
main.wide td, main.wide th { padding: 9px 12px; }
@media (min-width: 1500px) { main.wide { font-size: 15px; } main.wide .tablewrap td { font-size: 15px; } }
@media (min-width: 1900px) { main.wide td[style*="min-width:220px"] { min-width: 380px !important; } main.wide td[style*="min-width:160px"] { min-width: 260px !important; } main.wide td[style*="min-width:140px"] { min-width: 220px !important; } }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(440px, 1fr)); gap: 12px; align-items: start; }
.cards-grid > .card { margin-bottom: 0 !important; }

/* Control y resumen */
.g-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.text-red { color: var(--red); }
.invalid { outline: 2px solid var(--red); outline-offset: 3px; border-radius: 8px; }
.sumwrap { max-height: 76vh; overflow: auto; }
.sumtable { width: auto; min-width: 100%; border-collapse: separate; border-spacing: 0; }
.sumtable th, .sumtable td { padding: 6px 10px; font-size: 13.5px; white-space: nowrap; }
.sumtable thead th { position: sticky; background: var(--panel); z-index: 2; }
.sumtable thead tr:first-child th { top: 0; text-align: center; font-size: 14px; border-bottom: 1px solid var(--line); }
.sumtable thead tr:nth-child(2) th { top: 38px; font-size: 12px; color: var(--muted); font-weight: 600; }
.sumtable .g1 { background: #151d27; } .sumtable thead .g1 { background: #18222e; }
.sumtable .g0 { background: var(--panel); }
.sumtable .sep { border-left: 2px solid var(--line); }

/* subtítulo pequeño bajo el nombre (menú y títulos de página) */
.navt { display: inline-flex; flex-direction: column; align-items: center; text-align: center; line-height: 1.1; }
.navt small { font-size: 10.5px; opacity: .72; font-weight: 500; margin-top: 1px; }
.h1sub { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-top: 2px; }

/* neumáticos y frenos: botones de un toque */
.chipbox { padding: 10px; border: 1px solid var(--line); border-radius: 10px; }
.chipfield { margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { min-width: 44px; min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); font-size: 16px; font-weight: 600; cursor: pointer; }
.chip.on { background: var(--accent, #5aa2ff); border-color: var(--accent, #3b82f6); color: var(--accent-ink, #06121f); }
.chipother { width: 78px; min-height: 44px; }


/* tabla de servicios del equipo: compacta para que no necesite barra deslizante */
.svct th, .svct td { padding: 8px 6px; }
.svct th { font-size: 11px; letter-spacing: 0; white-space: normal; line-height: 1.15; }
.svct td:first-child { min-width: 110px; }
.svct input { width: 100%; min-width: 56px; max-width: 96px; padding: 8px 6px; }
.svct input[type=date] { min-width: 132px; max-width: none; padding: 8px 4px; }
.svct .btn.small { padding: 6px 8px; }

/* km y horas actuales sobre las bitácoras */
.curkm { margin: 0 0 12px; padding: 10px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; font-size: 15px; }

/* recibir: camión de la empresa / cliente externo, y filas de materiales */
.modes { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.modes .btn { flex: 1 1 200px; min-height: 48px; font-size: 16px; }
.matrow { display: grid; grid-template-columns: 1fr 100px 72px auto; gap: 6px; margin-bottom: 6px; align-items: center; }
.matrow input, .matrow select { min-width: 0; }
.badge.b-ext { background: #2a2140; color: #c9b6ff; }

/* logo de Transportes 3A: esquina superior (vuelve al menú principal) y pantalla de ingreso */
.topbar a.brand { padding: 4px 0; margin-right: 14px; display: flex; align-items: center; }
.logo { height: 38px; width: auto; display: block; }
.logo-l { display: none; }                                   /* tema oscuro: logo blanco */
html[data-theme="claro"] .logo-d { display: block; }
html[data-theme="claro"] .logo-l { display: none; }
html:not([data-theme="claro"]) .logo-d { display: none; }
html:not([data-theme="claro"]) .logo-l { display: block; }
.loginlogo { display: flex; justify-content: center; margin: 4px 0 14px; } .loginlogo .logo { height: 96px; }
#tema { cursor: pointer; }

/* ===== TEMA CLARO: fondo blanco y letras negras ===== */
html[data-theme="claro"] {
  --bg: #ffffff; --panel: #f6f8fb; --panel2: #eceff4; --line: #d3dae4;
  --text: #0d1117; --muted: #566273; --accent: #1565d8; --accent-ink: #ffffff;
  --red: #c62828; --red-bg: #fdeaea; --yellow: #8a5a00; --yellow-bg: #fff3d1;
  --green: #17734a; --green-bg: #e2f5ea; --grey: #566273; --grey-bg: #e8ecf1;
  color-scheme: light;
}
html[data-theme="claro"] .topbar { background: #ffffff; box-shadow: 0 1px 0 var(--line); }
html[data-theme="claro"] .stat.red { border-color: #f2b9b9; }
html[data-theme="claro"] .stat.yellow { border-color: #ecd28a; }
html[data-theme="claro"] .stat.green { border-color: #a9dcc0; }
html[data-theme="claro"] .b-info, html[data-theme="claro"] .b-recibido { background: #e0ecff; color: #0f4fb0; }
html[data-theme="claro"] .b-en_progreso { background: #ece6ff; color: #5b3fc4; }
html[data-theme="claro"] input, html[data-theme="claro"] select, html[data-theme="claro"] textarea { background: #ffffff; color: var(--text); }
html[data-theme="claro"] .check { background: #ffffff; }
html[data-theme="claro"] .check:has(input:checked) { background: #e6f0ff; border-color: var(--accent); }
html[data-theme="claro"] .overlay { background: rgba(13, 17, 23, .45); }
html[data-theme="claro"] .bar .track { background: #e4e9f0; }
html[data-theme="claro"] .toast { background: #1d2633; color: #ffffff; }
html[data-theme="claro"] .toast.err { background: #fdeaea; color: #8e1b1b; border-color: #f2b9b9; }
html[data-theme="claro"] .notice { background: #e8f1ff; border-color: #b9d3f6; }
html[data-theme="claro"] .notice.warn { background: var(--yellow-bg); border-color: #ecd28a; }
html[data-theme="claro"] pre.share { background: #ffffff; }
html[data-theme="claro"] .sumtable .g1 { background: #f1f4f8; } html[data-theme="claro"] .sumtable thead .g1 { background: #e8edf4; }
html[data-theme="claro"] .badge.b-ext { background: #efe9ff; color: #5b3fc4; }
html[data-theme="claro"] .chip.on { color: #ffffff; }
html[data-theme="claro"] tr.click:hover td { background: var(--panel2); }

/* Bitácora resumen: bloques de 4 servicios por línea; los registros bajan dentro de cada bloque */
.sumgrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; align-items: start; }
@media (max-width: 1199px) { .sumgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 800px) { .sumgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .sumgrid { grid-template-columns: minmax(0, 1fr); } }
.sumblock { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 4px 4px; }
.sumblock h3 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .03em; }
.sumblock .tablewrap { border: 0; background: transparent; overflow-x: auto; }
.sumt { width: 100%; } .sumt th, .sumt td { padding: 4px 1.5px; font-size: 11px; white-space: nowrap; }
.sumt th { font-size: 9.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0; }

/* "todas las tablas del mismo tamaño": las filas de relleno mantienen el aspecto de tabla */
.sumt tr.fill td { color: transparent; }
.sumgrid.igual { align-items: stretch; }

#qt input,#qt select{width:100%;min-width:0;padding:6px}
#qt td{padding:3px}
#qt select.ik{min-width:150px}
.modal.quoteform { max-width: 1320px; }
#qt { width:100%; }
#qt th:nth-child(1), #qt td:nth-child(1) { width:34px; min-width:34px; padding:0; text-align:center; }
#qt th:nth-child(2), #qt td:nth-child(2) { min-width:160px; }
#qt th:nth-child(3), #qt td:nth-child(3) { min-width:300px; width:36%; }
#qt th:nth-child(4), #qt td:nth-child(4) { min-width:80px; }
#qt th:nth-child(5), #qt td:nth-child(5) { min-width:80px; }
#qt .handle { display:inline-block; cursor:grab; font-size:20px; line-height:1; padding:8px 6px; color:var(--muted); border-radius:8px; user-select:none; -webkit-user-select:none; touch-action:none; }
#qt .handle:hover, #qt .handle:focus { background:var(--line); color:var(--text); outline:none; }
#qt tr.dragging { opacity:.55; background:var(--line); }
#qt tr.dragging .handle { cursor:grabbing; }

.mini { height: 22px; width: auto; border-radius: 5px; }
.modes .btn { display: flex; align-items: center; justify-content: center; gap: 8px; }

.viewas { background: #b45309; color: #fff; padding: 8px 14px; text-align: center; font-size: 14px; position: sticky; top: 0; z-index: 50; }
.viewas .btn { margin-left: 10px; }

#qt th[style*="8a6d1a"] { color:#fff; }
