@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Bricolage+Grotesque:wght@600;700;800&display=swap');

:root {
    --navy: #111f31; --ink: #18283b; --muted: #526378; --line: #dfe6eb;
    --green: #08784f; --green-dark: #05603e; --lime: #a5e8ae; --paper: #f5f7f8;
    --white: #fff; --radius: 18px; --shadow: 0 12px 35px #172d4510;
    font-family: 'DM Sans', system-ui, sans-serif; color: var(--ink); background: var(--paper);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; min-width: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid #239663; outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3, .brand { font-family: 'Bricolage Grotesque', 'DM Sans', system-ui, sans-serif; letter-spacing: -.035em; }
p { line-height: 1.58; }
.wrap { width: min(1140px, calc(100% - 80px)); margin-inline: auto; }
.icon { width: 1.18em; height: 1.18em; flex: none; vertical-align: middle; }
.sr-only, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip:focus { position: fixed; z-index: 20; top: 10px; left: 10px; padding: 12px; background: white; }
.site-header { background: var(--navy); color: #fff; border-bottom: 1px solid #ffffff1a; }
.header-row { min-height: 74px; display: flex; justify-content: space-between; align-items: center; gap: 28px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 1.43rem; font-weight: 800; }
.top-nav { display: flex; align-items: center; gap: clamp(12px, 3vw, 34px); min-height: inherit; }
.top-nav a { color: #ced9e5; font-size: .91rem; font-weight: 600; padding: 25px 2px; border-block: 2px solid transparent; }
.top-nav a:hover, .top-nav a[aria-current] { color: #fff; }
.top-nav a[aria-current] { border-bottom-color: #a5e8ae; }
.admin-link { border: 1px solid #ffffff35; border-radius: 10px; color: #edf3f8; white-space: nowrap; padding: 10px 13px; display: inline-flex; align-items: center; gap: 7px; font-size: .82rem; font-weight: 700; }
.admin-link:hover { background: #ffffff14; }
.search-form { display: grid; grid-template-columns: 1fr 42px 1fr auto; align-items: end; gap: 13px; padding: 18px 22px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.search-form.full-search { grid-template-columns: repeat(3, minmax(0, 1fr)) auto; }
label { display: grid; gap: 6px; color: var(--ink); font-size: .87rem; font-weight: 700; min-width: 0; }
input, select, textarea { border: 1px solid #ccd7df; border-radius: 10px; padding: 11px 13px; color: var(--ink); width: 100%; min-width: 0; background: #fff; min-height: 44px; }
input::placeholder, textarea::placeholder { color: #596b7b; }
textarea { min-height: 100px; resize: vertical; }
.input-icon { position: relative; display: block; }
.input-icon .icon { position: absolute; inset: 50% auto auto 13px; transform: translateY(-50%); color: var(--green); }
.input-icon input { padding-left: 38px; background: #f8fafb; }
.button { display: inline-flex; justify-content: center; align-items: center; gap: 8px; background: var(--green); color: white; padding: 11px 16px; min-height: 44px; border: 1px solid transparent; border-radius: 10px; font-weight: 700; font-size: .9rem; white-space: nowrap; }
.button:hover { background: var(--green-dark); }
.button.secondary { background: white; border-color: var(--line); color: var(--ink); }
.button.secondary:hover, .swap:hover { background: #e6f4ed; }
.swap { margin-bottom: 2px; width: 41px; height: 41px; background: #f2f7f5; border: 1px solid #dce9e1; border-radius: 10px; color: var(--green-dark); }
.section { padding-block: 46px 72px; }
.home-routes { padding-bottom: 30px; }
.section-heading, .results-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 22px; }
.section-heading h2, .results-heading h2 { font-size: clamp(1.36rem, 3vw, 1.95rem); }
.section-heading p, .page-heading p { color: var(--muted); margin-top: 5px; }
.text-link { display: inline-flex; align-items: center; gap: 7px; color: var(--green-dark); font-weight: 700; }
.text-link:hover, .stop-jump:hover { text-decoration: underline; }
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 17px; }
.route-card, .panel, .empty { min-width: 0; background: white; border: 1px solid var(--line); border-radius: var(--radius); }
.route-card { display: flex; flex-direction: column; padding: 20px; box-shadow: 0 3px 14px #172d4505; overflow-wrap: anywhere; }
.route-id, .demo { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 7px; font-size: .78rem; font-weight: 800; }
.route-id.green { background: #e4f5e8; color: #096144; }
.route-id.blue { background: #e6effa; color: #274e7b; }
.route-id.orange { background: #fcefe3; color: #864512; }
.demo { background: #f0f2f6; color: #46566a; }
.route-card h3 { font-size: 1.22rem; }
.route-meta { display: flex; flex-wrap: wrap; gap: 8px 15px; font-size: .83rem; color: var(--muted); margin-top: auto; }
.route-meta .icon { margin-right: 3px; }
.shortcut-icon { display: inline-grid; place-items: center; width: 43px; height: 43px; border-radius: 11px; background: #e0f0e5; color: #096144; font-size: 1.22rem; }
.site-footer { background: var(--navy); color: #e4ecf5; }
.footer-row { display: flex; justify-content: space-between; align-items: center; gap: 24px; padding-block: 30px; }
.footer-row p { margin-top: 10px; color: #bfd0dd; font-size: .84rem; max-width: 460px; }
.footer-row nav { display: flex; gap: 19px; font-size: .88rem; }
.footer-row nav a:hover { text-decoration: underline; }
.page-heading { margin-bottom: 27px; }
.page-heading h1 { margin-top: 5px; font-size: clamp(2.25rem, 5vw, 3.3rem); line-height: 1.12; overflow-wrap: anywhere; }
.results-heading { margin-top: 30px; }
.panel, .empty { padding: 23px; }
.panel h2 { font-size: 1.42rem; margin-bottom: 9px; }
.panel h3 { margin: 20px 0 9px; }
.panel p + p { margin-top: 8px; }
.detail-grid, .map-layout { display: grid; grid-template-columns: 1.65fr 1fr; align-items: start; gap: 20px; }
.back { margin-bottom: 20px; }
.preserve-lines { white-space: pre-line; overflow-wrap: anywhere; }
.stop-list { display: grid; gap: 12px; padding-left: 25px; margin: 12px 0 21px; color: #31445a; overflow-wrap: anywhere; }
.stop-list li::marker { color: var(--green-dark); font-weight: 800; }
.service-hour { font-size: 1.56rem; font-weight: 800; }
.notice { display: flex; gap: 8px; align-items: baseline; background: #eaf4ef; padding: 10px 14px; border-radius: 10px; color: #285340; margin: 14px 0; }
.time-panel { margin-top: 16px; }
.time-panel .section-heading h2 { margin: 0; }
.time-panel .section-heading a:hover { text-decoration: underline; }
.table-scroll { overflow-x: auto; margin-top: 13px; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: .9rem; }
th, td { padding: 12px 11px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
th { background: #edf3f6; color: #30435a; font-weight: 800; }
tr:last-child td { border-bottom: 0; }
.map-filter { display: flex; align-items: center; gap: 12px; margin-bottom: 17px; }
.map-filter select { width: min(100%, 330px); }
.map-layout { grid-template-columns: minmax(0, 2.1fr) minmax(0, 1fr); margin-top: 17px; }
.map-view { position: relative; height: clamp(340px, 55vh, 540px); background: #e6ede6; border: 1px solid var(--line); overflow: hidden; border-radius: var(--radius); }
.map-view canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.map-view canvas:active { cursor: grabbing; }
.map-controls { position: absolute; top: 10px; left: 10px; display: grid; gap: 4px; }
.map-controls button { width: 42px; height: 42px; border-radius: 9px; background: white; border: 1px solid #b7c8bd; font-size: 1.35rem; font-weight: 700; color: var(--navy); }
.map-message, .attribution { position: absolute; background: #fffffff0; padding: 4px 9px; font-size: .77rem; }
.map-message { top: 12px; right: 12px; max-width: calc(100% - 76px); border-radius: 6px; }
.attribution { bottom: 0; right: 0; text-decoration: underline; }
.stop-jump { border: 0; background: none; text-align: left; color: var(--green-dark); padding: 0; font-weight: 800; }
.login { width: min(455px, calc(100% - 40px)); margin: 55px auto; }
.login .panel { padding: 30px; }
.login h1 { font-size: 2rem; margin: 12px 0 5px; }
.login form, .edit-form { display: grid; gap: 15px; margin-top: 20px; }
.password-row { display: flex; gap: 8px; }
.admin-layout { display: grid; align-items: start; grid-template-columns: 218px minmax(0, 1fr); gap: 22px; }
.sidebar { display: grid; gap: 4px; padding: 14px; }
.sidebar a, .sidebar button { display: block; color: #30435a; padding: 10px 12px; width: 100%; text-align: left; font-weight: 700; font-size: .86rem; border: 0; border-radius: 8px; background: none; }
.sidebar a[aria-current], .sidebar a:hover, .sidebar button:hover { background: #e8f3eb; color: var(--green-dark); }
.admin-content { min-width: 0; }
.admin-content .page-heading h1 { font-size: clamp(1.8rem, 4vw, 2.65rem); }
.action-row, .form-actions, .record-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.action-row { justify-content: space-between; margin-bottom: 13px; }
.record-actions { flex-wrap: nowrap; }
.record-actions button, .record-actions a { border: 0; background: none; color: var(--green-dark); padding: 3px; font-weight: 700; }
.record-actions button { color: #a12630; }
.record-actions a:hover, .record-actions button:hover { text-decoration: underline; }
.grid-fields, .admin-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.admin-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.admin-stats strong { display: block; font-size: 1.75rem; color: var(--green-dark); }
.admin-stats a { display: block; }
fieldset { border: 1px solid var(--line); padding: 15px; border-radius: 11px; min-width: 0; }
legend { font-weight: 800; }
.help { color: var(--muted); font-size: .84rem; font-weight: 400; }
.stop-field { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 12px; margin-top: 8px; }
.stop-field input { max-width: 100px; }
.flash { padding: 11px 14px; color: #0a5d3c; background: #e4f5ea; border-radius: 9px; margin: 0 0 16px; }
.flash.error { color: #8e2531; background: #fce8eb; }
.flash ul { margin-block: 4px; padding-left: 20px; }
@media (max-width: 900px) {
    .wrap { width: min(100% - 46px, 1140px); }
    .search-form.full-search { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .search-form.full-search .button { justify-self: start; }
    .cards { gap: 10px; }
    .route-card { padding: 15px; }
}
@media (max-width: 670px) {
    .wrap { width: calc(100% - 30px); }
    .header-row { flex-wrap: wrap; gap: 4px 12px; padding-top: 12px; }
    .top-nav { order: 3; width: 100%; justify-content: space-between; min-height: 0; }
    .top-nav a { padding: 11px 4px; }
    .brand { font-size: 1.26rem; }
    .admin-link { font-size: .76rem; padding: 8px; }
    .search-form { grid-template-columns: minmax(0, 1fr) 36px minmax(0, 1fr); gap: 7px; padding: 12px; }
    .search-form .button, .search-form.full-search .button { grid-column: 1 / -1; justify-self: stretch; }
    .search-form .input-icon input { padding-left: 29px; padding-right: 4px; font-size: .76rem; }
    .input-icon .icon { left: 8px; }
    .swap { width: 35px; height: 38px; }
    .cards, .detail-grid, .map-layout, .admin-layout { grid-template-columns: 1fr; }
    .section { padding-block: 30px 42px; }
    .section-heading { align-items: start; }
    .section-heading .text-link { font-size: .81rem; flex-shrink: 0; }
    .footer-row { flex-direction: column; align-items: flex-start; }
    .map-filter { flex-wrap: wrap; }
    .map-filter select { width: 100%; }
    .admin-stats .panel { padding: 12px; font-size: .84rem; }
}
@media (max-width: 365px) {
    .search-form, .search-form.full-search, .grid-fields { grid-template-columns: 1fr; }
    .swap { display: none; }
    .section-heading { flex-wrap: wrap; }
}

[data-stop-rows] { display: grid; gap: 9px; margin-block: 12px; }

/* Editor geográfico del panel de administración. */
.map-editor { display: grid; gap: 12px; }
.map-editor .editor-map { height: clamp(320px, 54vh, 520px); }
.map-editor canvas { cursor: crosshair; }
.map-editor canvas:active { cursor: grabbing; }
.map-editor .editor-tools { margin: 0; }
.map-editor .button { white-space: normal; }
.map-editor .button:disabled { opacity: .5; }
.waypoint-list { display: grid; gap: 4px; margin: 0; padding-left: 24px; color: var(--muted); font-size: .85rem; max-height: 180px; overflow: auto; }
.editor-status { background: #edf3fb; color: #24456d; padding: 10px 12px; border-radius: 8px; font-size: .88rem; min-height: 40px; }
.technical-path summary { font-size: .85rem; color: var(--green-dark); cursor: pointer; font-weight: 700; }
.technical-path label { margin-top: 8px; }
