:root {
  --navy: #0F3D5E;
  --navy-2: #0A2C44;
  --orange: #F28C28;
  --orange-2: #D9731A;
  --yellow: #FFC20E;
  --magenta: #CC3366;
  --green: #1E9E5A;
  --red: #C62828;
  --ink: #1f2433;
  --muted: #6b7280;
  --line: #e6e8ef;
  --bg: #f5f6fa;
  --card: #ffffff;
  --soft: #FFF4EA;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 24, 60, .06), 0 4px 16px rgba(20, 24, 60, .06);
  --grad: linear-gradient(90deg, var(--orange), var(--orange-2));
  font-family: Roboto, Inter, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--navy); }
h1, h2, h3 { margin: 0; color: var(--navy); line-height: 1.2; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* Arranque */
.boot { min-height: 100vh; display: grid; place-items: center; align-content: center; gap: 24px; }
.spinner { width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--orange); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Acceso */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art { background: var(--navy); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-art::after { content: ""; position: absolute; right: -90px; bottom: -90px; width: 380px; height: 380px; background: url(assets/rtt-icon.svg) center/contain no-repeat; opacity: .14; }
.auth-art h1 { color: #fff; font-size: 34px; max-width: 420px; }
.auth-art .bar { height: 6px; width: 120px; background: var(--grad); border-radius: 3px; margin: 18px 0; }
.auth-art p { opacity: .85; max-width: 420px; }
.auth-form { display: grid; place-items: center; padding: 32px 20px; background: #fff; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card img { width: 210px; display: block; margin: 0 auto 22px; }
.auth-card h2 { margin-bottom: 4px; }
.auth-links { display: flex; justify-content: space-between; gap: 8px; margin-top: 14px; font-size: 14px; flex-wrap: wrap; }
.auth-links a { cursor: pointer; text-decoration: none; color: var(--magenta); font-weight: 500; }

/* Estructura */
.topbar { position: sticky; top: 0; z-index: 20; background: #fff; border-bottom: 1px solid var(--line); }
.topbar::after { content: ""; display: block; height: 3px; background: var(--grad); }
.topbar-in { max-width: 1240px; margin: auto; display: flex; align-items: center; gap: 18px; padding: 8px 18px; }
.topbar .logo { height: 40px; }
.nav { display: flex; gap: 2px; flex: 1; }
.nav a { padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--ink); font-weight: 500; font-size: 14px; display: flex; gap: 6px; align-items: center; }
.nav a:hover { background: var(--bg); }
.nav a.active { color: var(--navy); background: #EAF1F6; }
.user-chip { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 4px 6px 4px 4px; border-radius: 30px; }
.user-chip:hover { background: var(--bg); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; }
.user-chip .who { font-size: 13px; line-height: 1.2; }
.user-chip .who b { display: block; color: var(--ink); }
.role-badge { font-size: 11px; color: var(--orange-2); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
main { max-width: 1240px; margin: auto; padding: 22px 18px 100px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }
.bottom-nav { display: none; }

/* Botones */
.btn { appearance: none; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 9px 14px; border-radius: 9px; font: inherit; font-weight: 500; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #cfd3e0; background: #fafbfd; }
.btn.primary { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn.primary:hover { filter: brightness(.93); }
.btn.navy { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.wa { background: #25D366; border-color: #25D366; color: #fff; }
.btn.danger { color: var(--red); border-color: #f1c7c7; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn.block { width: 100%; justify-content: center; padding: 11px; }
.btn:disabled { opacity: .6; cursor: default; }
.icon { width: 18px; height: 18px; flex: none; }

/* Tarjetas */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(4, 1fr); margin-bottom: 18px; }
.kpi { padding: 14px 16px; }
.kpi .label { font-size: 13px; color: var(--muted); }
.kpi .value { font-size: 24px; font-weight: 700; color: var(--navy); margin-top: 2px; }
.kpi.accent { border-top: 3px solid var(--orange); }
.two-col { grid-template-columns: 1.4fr 1fr; }

.alert { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius); margin-bottom: 14px; border: 1px solid; }
.alert.warn { background: #FFF4E5; border-color: #FFD8A8; }
.alert.info { background: #EEF1FB; border-color: #D5DBF3; }
.alert.ok { background: #E9F7EF; border-color: #C3E8D2; }
.alert .icon { color: var(--orange-2); margin-top: 2px; width: 22px; height: 22px; }
.alert b { color: var(--navy); }

/* Lista de viajes */
.trip { display: grid; grid-template-columns: 62px 1fr auto; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); align-items: center; cursor: pointer; }
.trip:last-child { border-bottom: 0; }
.trip:hover .trip-title { color: var(--orange-2); }
.date-box { text-align: center; border-radius: 10px; padding: 6px 0; background: var(--soft); color: var(--navy); line-height: 1.1; }
.date-box .d { font-size: 20px; font-weight: 700; }
.date-box .m { font-size: 11px; text-transform: uppercase; font-weight: 600; color: var(--orange-2); }
.trip-title { font-weight: 600; }
.trip-meta { font-size: 13px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; vertical-align: middle; margin-right: 4px; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.pill.confirmada { background: #E9F7EF; color: var(--green); }
.pill.pendiente { background: #FFF4E5; color: #B45F06; }
.pill.cancelada { background: #FDECEC; color: var(--red); }
.pill.finalizada { background: #EEF0F5; color: #4b5563; }
.pill.manana { background: var(--orange); color: #fff; }
.pill.hoy { background: var(--magenta); color: #fff; }
.money-due { color: var(--orange-2); font-weight: 600; }
.empty { text-align: center; padding: 30px 10px; color: var(--muted); }

/* Tablas */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafbfd; }
table.data td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tr.click { cursor: pointer; }
table.data tr.click:hover td { background: #FFFAF4; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; padding: 14px; border-bottom: 1px solid var(--line); }
.filters > * { flex: 1 1 150px; }
.filters .search { flex: 2 1 220px; }

/* Formularios */
label { display: block; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 5px; }
input, select, textarea { width: 100%; font: inherit; font-size: 15px; padding: 10px 12px; border: 1px solid #d5d9e4; border-radius: 9px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(240, 123, 29, .15); }
input[readonly] { background: #f6f7fa; }
textarea { min-height: 70px; resize: vertical; }
.field { margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0 14px; }
.c2 { grid-column: span 2; } .c3 { grid-column: span 3; } .c4 { grid-column: span 4; } .c6 { grid-column: span 6; }
.form-section { grid-column: span 6; font-size: 12px; font-weight: 700; color: var(--orange-2); text-transform: uppercase; letter-spacing: .05em; margin: 6px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.check input { width: auto; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.error-text { color: var(--red); font-size: 13px; margin-top: 8px; }
.balance-box { background: var(--soft); border: 1px dashed #F5C08F; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 20, 50, .45); z-index: 50; display: grid; place-items: center; padding: 16px; animation: fade .15s; }
.modal { background: #fff; border-radius: 14px; width: 100%; min-width: 0; max-width: 720px; overflow: hidden; max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal.narrow { max-width: 480px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.modal-body { padding: 18px 20px; overflow-y: auto; overflow-x: hidden; min-width: 0; }
.modal-body .table-wrap { max-width: 100%; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.modal-foot .spacer { flex: 1; }
@keyframes fade { from { opacity: 0; } }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; }
.detail-grid .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.detail-grid .v { font-weight: 500; }
.money-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0 4px; }
.money-row > div { background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.money-row .v { font-size: 18px; font-weight: 700; color: var(--navy); }
.money-row .due .v { color: var(--orange-2); }

/* Toast */
#toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px); background: var(--navy); color: #fff; padding: 11px 18px; border-radius: 10px; opacity: 0; pointer-events: none; transition: .2s; z-index: 80; max-width: 90vw; font-size: 14px; }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.err { background: var(--red); }

/* Calendario */
.cal-card { padding: 14px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 5px 12px; font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.chip.off { opacity: .45; }
.fc { --fc-border-color: var(--line); --fc-today-bg-color: #FFF6EC; --fc-button-bg-color: #fff; --fc-button-text-color: var(--ink); --fc-button-border-color: var(--line);
  --fc-button-hover-bg-color: #f3f4f8; --fc-button-hover-border-color: #cfd3e0; --fc-button-active-bg-color: var(--navy); --fc-button-active-border-color: var(--navy); font-size: 13px; }
.fc .fc-button-primary:not(:disabled).fc-button-active { color: #fff; }
.fc .fc-toolbar-title { font-size: 18px; color: var(--navy); text-transform: lowercase; }
.fc .fc-toolbar-title::first-letter { text-transform: uppercase; }
.fc .fc-button { font-weight: 500; text-transform: capitalize; box-shadow: none !important; }
.fc .fc-daygrid-day-number, .fc .fc-col-header-cell-cushion { color: var(--ink); text-decoration: none; }
.fc .fc-event { cursor: pointer; border-radius: 5px; padding: 1px 3px; }
.fc .fc-list-event:hover td { background: #FFFAF4; }

/* Responsivo */
@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
}
@media (max-width: 760px) {
  body { font-size: 15px; }
  .nav, .user-chip .who { display: none; }
  .topbar-in { padding: 8px 14px; justify-content: space-between; }
  .topbar .logo { height: 34px; }
  main { padding: 16px 12px 110px; }
  .bottom-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: #fff; border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; }
  .bottom-nav a { flex: 1; text-align: center; text-decoration: none; color: var(--muted); font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; font-weight: 500; }
  .bottom-nav a.active { color: var(--navy); }
  .bottom-nav a.active .icon { color: var(--orange); }
  .bottom-nav .icon { width: 22px; height: 22px; }
  .fab { position: fixed; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); width: 56px; height: 56px; border-radius: 50%; background: var(--orange); color: #fff; border: 0; box-shadow: 0 6px 18px rgba(240, 123, 29, .45); display: grid; place-items: center; z-index: 31; cursor: pointer; }
  .fab .icon { width: 26px; height: 26px; }
  .page-head .btn.primary.desk { display: none; }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
  .c2, .c3 { grid-column: span 1; } .c4, .c6, .form-section { grid-column: span 2; }
  .c2.full-m { grid-column: span 2; }
  .modal-bg { padding: 0; place-items: end center; }
  .modal { max-height: 94vh; border-radius: 16px 16px 0 0; }
  .detail-grid { grid-template-columns: 1fr; }
  .money-row .v { font-size: 15px; }
  .hide-m { display: none; }
  .fc .fc-toolbar { flex-wrap: wrap; gap: 8px; }
  .fc .fc-toolbar-title { font-size: 16px; }
  table.data.cards thead { display: none; }
  table.data.cards tr { display: block; border-bottom: 1px solid var(--line); padding: 8px 4px; }
  table.data.cards td { display: block; border: 0; padding: 3px 10px; }
  table.data.cards td[data-l]::before { content: attr(data-l) ": "; color: var(--muted); font-size: 12px; }
}
@media (min-width: 761px) { .fab { display: none; } }
@media print {
  .topbar, .bottom-nav, .fab, .filters, .btn { display: none !important; }
  main { padding: 0; }
}

/* Marca de empresa */
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.brand-name { font-weight: 700; color: var(--navy); font-size: 16px; line-height: 1.1; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-sub { font-size: 11px; color: var(--muted); }
.scope-select { width: auto; padding: 6px 10px; font-size: 13px; border-radius: 20px; max-width: 220px; }
.logo-preview { width: 100%; max-width: 260px; height: 90px; border: 1px dashed #cfd3e0; border-radius: 10px; display: grid; place-items: center; background: #fafbfd; overflow: hidden; }
.logo-preview img { max-width: 100%; max-height: 80px; }
.import-table td, .import-table th { font-size: 13px; padding: 6px 8px; }
.row-err td { background: #FDECEC; }
.powered { text-align: center; font-size: 12px; color: var(--muted); margin-top: 28px; }
.powered img { height: 16px; vertical-align: -3px; }
@media (max-width: 760px) { .scope-select { max-width: 130px; } .brand-name { max-width: 150px; font-size: 14px; } }
