:root {
  --bg: #121212; --surface: #1e1e1e; --surface2: #262626; --border: #3a3a3a;
  --text: #ffffff; --muted: #b3b3b3; --accent: #1abc9c; --danger: #e57373; --warn: #f0b429;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: Arial, Helvetica, sans-serif; font-size: 15px; }
a { color: var(--accent); }
button, input, select { font: inherit; }
button { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 9px 16px; cursor: pointer; font-weight: 600; }
button:hover { filter: brightness(1.08); }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
button.danger { background: var(--danger); }
button.small { padding: 5px 10px; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }
input, select { background: var(--surface2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%; }
label { display: block; color: var(--muted); font-size: 13px; margin: 10px 0 4px; }

.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: #000; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.brand img { height: 32px; max-width: 120px; object-fit: contain; border-radius: 4px; }
.tabs { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.tabs button { background: transparent; color: var(--muted); padding: 8px 12px; }
.tabs button.active { color: var(--text); background: var(--surface2); }
.mode-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.mode-switch button { background: transparent; color: var(--muted); border-radius: 0; padding: 6px 12px; font-size: 13px; }
.mode-switch button.active { background: var(--accent); color: #fff; }
.user { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin-left: auto; }

main { max-width: 1200px; margin: 0 auto; padding: 20px; min-height: calc(100vh - 140px); }
.center { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 60vh; text-align: center; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin-bottom: 16px; }
.login { width: 100%; max-width: 380px; text-align: left; }
.login h1 { margin: 0 0 4px; font-size: 24px; }
.muted { color: var(--muted); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1; min-width: 140px; }
.row > .shrink { flex: 0 0 auto; min-width: 0; }
.grid-kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.kpi .v { font-size: 26px; font-weight: 700; margin-top: 4px; }
.kpi .l { color: var(--muted); font-size: 13px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--surface); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface2); }
.table-wrap { overflow: auto; max-height: 65vh; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; background: var(--surface2); color: var(--muted); }
.badge.web { background: #12384a; color: #8fd3ff; }
.badge.plus { background: var(--accent); color: #fff; }
.bar { height: 10px; background: var(--accent); border-radius: 5px; min-width: 2px; }
.banner { background: #1d3b33; border: 1px solid var(--accent); border-radius: 12px; padding: 14px 16px; margin-bottom: 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.banner.warn { background: #3b3220; border-color: var(--warn); }
.actions-list { margin: 6px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 16px; }
.modal-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; width: 100%; max-width: 640px; max-height: 90vh; overflow: auto; padding: 20px; }
.modal-card h2 { margin-top: 0; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--surface2); border: 1px solid var(--border); padding: 10px 18px; border-radius: 10px; z-index: 30; }
.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 20px; }

.print-only { display: none; }
@media print {
  body { background: #fff; color: #000; font-size: 11px; }
  .topbar, .no-print, .footer, button, .banner { display: none !important; }
  .print-only { display: block; }
  main { padding: 0; max-width: none; }
  .card, .kpi, .table-wrap { background: #fff; border-color: #999; max-height: none; overflow: visible; }
  th { background: #eee; color: #000; }
  td, th { border-color: #bbb; padding: 4px 6px; }
  .kpi .l, .muted { color: #333; }
}
@media (max-width: 700px) {
  main { padding: 12px; }
  th, td { padding: 7px 6px; }
}

.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.dash-grid canvas { max-height: 280px; }
@media (max-width: 860px) { .dash-grid { grid-template-columns: 1fr; } }

.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.panel-grid .widget { margin-bottom: 0; min-width: 0; }
.panel-grid .w-l { grid-column: 1 / -1; }
.widget .w-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.widget .w-head h3 { margin: 0 0 10px; }
.widget .w-tools { display: flex; gap: 6px; }
.widget[draggable="true"] { cursor: grab; border-style: dashed; }
.widget.dragging { opacity: .45; }
.widget.w-hidden { opacity: .5; }
.w-grip { color: var(--muted); }
.support-banner { background: #3b3220; border-bottom: 1px solid var(--warn); color: var(--text); padding: 8px 20px; font-size: 14px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
@media (max-width: 860px) { .panel-grid { grid-template-columns: 1fr; } }

.logo-prev { width: 64px; height: 64px; border: 1px solid var(--border); border-radius: 8px; display: flex; align-items: center; justify-content: center; overflow: hidden; background: var(--surface2); font-size: 11px; text-align: center; }
.logo-prev img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* Landing */
a.btn { display: inline-block; background: var(--accent); color: #fff; text-decoration: none; padding: 10px 16px; border-radius: 8px; font-weight: 600; }
a.btn.ghost { background: transparent; border: 1px solid var(--border); }
.hero { display: grid; grid-template-columns: 1.3fr 1fr; gap: 32px; align-items: center; padding: 40px 0 24px; }
.hero h1 { font-size: 38px; line-height: 1.15; margin: 0 0 12px; }
.lead { color: var(--muted); font-size: 18px; margin: 0 0 20px; }
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 24px 0; }
.features h3, .plan h3 { margin-top: 0; }
.plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.plan ul { padding-left: 18px; color: var(--muted); line-height: 1.7; }
.plan .price { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.plan.featured { border-color: var(--accent); }
@media (max-width: 860px) { .hero, .features, .plans { grid-template-columns: 1fr; } .hero h1 { font-size: 30px; } }

/* Calendario de vehículos (PRO) */
table.cal th, table.cal td { text-align: center; min-width: 92px; }
table.cal td:first-child, table.cal th:first-child { text-align: left; min-width: 120px; }
.cal-cell { cursor: default; font-size: 13px; border-radius: 6px; }
.cal-cell[data-mat] { cursor: pointer; }
.cal-cell[data-mat]:hover { outline: 1px solid var(--accent); }
.cal-libre { color: #81c784; }
.cal-asig { background: #12384a; color: #8fd3ff; }
.cal-usado { background: #262626; color: var(--muted); }
.cal-bloq { background: #4a3a12; color: #ffcc80; }
.cal-averia { background: #4a1f1f; color: var(--danger); font-weight: 600; }
.cal-hoy { color: var(--accent); }
.cal-nota { font-size: 11px; opacity: .8; }
.cal-sum td { font-size: 12px; }
.cal-leg { display: inline-block; padding: 1px 8px; border-radius: 6px; margin-right: 4px; }

/* Tablero de tráfico (calendario v2) */
.cal-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 16px; }
.tab-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 12px; }
.tab-kpis .kpi b { font-size: 26px; display: block; margin: 2px 0; }
.kpi-list { font-size: 12px; color: var(--muted); line-height: 1.5; }
.t-warn { color: var(--warn); }
.t-bad { color: var(--danger); }
.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.pill.ok { background: #12384a; color: #8fd3ff; }
.pill.off { background: #4a3a12; color: #ffcc80; }
.pill.warn { background: #3a2f12; color: var(--warn); }
table.tablero tr.clic { cursor: pointer; }
table.tablero tr.clic:hover td { background: var(--surface2); }
table.tablero tr.row-bad td:first-child { box-shadow: inset 3px 0 0 var(--danger); }

/* Mantenimiento */
.bar-row { display: grid; grid-template-columns: 220px 1fr 110px; gap: 10px; align-items: center; margin: 6px 0; font-size: 14px; }
.bar-row b { text-align: right; }
.mt-bar { background: var(--surface2); border-radius: 6px; height: 12px; overflow: hidden; }
.mt-bar i { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
tr.clic { cursor: pointer; }
tr.clic:hover td { background: var(--surface2); }
@media (max-width: 600px) { .bar-row { grid-template-columns: 1fr 90px; } .bar-row .mt-bar { grid-column: 1 / -1; } }

/* 4.11: faenas, resumen del jefe */
.pill.f-warn { background: #3a2f12; color: var(--warn); }
.pill.f-ok { background: #12384a; color: #8fd3ff; }
.pill.f-done { background: #1f3a24; color: #81c784; }
.pill.f-bad { background: #4a1f1f; color: var(--danger); }
.clic-card { cursor: pointer; }
.clic-card:hover { border-color: var(--accent); }
