:root {
  --navy: #0b1f44; --navy2: #16315f; --bg: #f4f6fa; --card: #fff; --line: #e1e6ef; --text: #0b1f44; --muted: #5b6780;
  --octopus: #163f7c; --almen: #0e8a8a; --link: #2a5dae; --accent-light: #6e9fea; --ok: #1f9d6b; --danger: #d64545; --r: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0a1224; --card: #111c36; --line: #223152; --text: #e8edf8; --muted: #9fb0d0; --navy: #060d1d; --octopus: #4a86dd; --almen: #35b8b8; --link: #8db4f0; --ok: #3cc78c; --danger: #f27d7d; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1 { margin: 0; font-size: 26px; } h2 { margin: 0 0 12px; font-size: 18px; } h3 { margin: 0 0 8px; font-size: 15px; }
a { color: var(--link); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { background: linear-gradient(160deg, #0c2650, #163f7c 60%, #2a5dae); }
.login .wrap { width: min(380px, 100%); display: grid; gap: 18px; }
.login form { background: var(--card); padding: 28px; border-radius: 20px; display: grid; gap: 12px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.login .brand { text-align: center; margin-bottom: 4px; } .login .brand img { width: 190px; } .login .brand span { display: block; color: #fff; font-weight: 900; letter-spacing: 10px; font-size: 22px; padding-left: 10px; }
.login form { position: relative; }

.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
aside { background: var(--navy); color: #fff; padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
aside .logo { padding: 6px 10px 2px; } aside .logo img { width: 150px; display: block; }
aside .logo-sub { color: var(--accent-light); font-size: 11px; font-weight: 700; letter-spacing: 5px; padding: 2px 10px 16px; }
aside a { color: #c9d4ec; text-decoration: none; padding: 10px 12px; border-radius: 10px; display: block; }
aside a:hover { background: var(--navy2); }
aside a.on { background: var(--navy2); color: #fff; box-shadow: inset 3px 0 var(--accent-light); }
aside .who { margin-top: auto; padding: 10px; font-size: 13px; color: #9fb0d0; }
aside .who b { display: block; color: #fff; }
main { padding: 24px; max-width: 1200px; width: 100%; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.sub { color: var(--muted); margin: 4px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 14px; }
.btn { background: var(--octopus); color: #fff; border: 0; border-radius: 10px; padding: 9px 14px; font-weight: 600; }
.btn.alt { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
input, select, textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.error { color: var(--danger); font-size: 14px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
td.c, th.c { text-align: center; }
td input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--ok); }
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--line); color: var(--text); }
.badge.pub { background: #d6f3e7; color: #0e6b47; } .badge.draft { background: #fdebd2; color: #8a4e0a; }
.badge.prop { background: #dce8fb; color: #163f7c; } .badge.no { background: #fbe0e0; color: #a12d2d; }
@media (prefers-color-scheme: dark) { .badge.pub { background: #123528; color: #7fe0b4; } .badge.draft { background: #372b12; color: #e8b04d; } .badge.prop { background: #1c2d4e; color: #9bbdf3; } .badge.no { background: #3b1d21; color: #f5a0a0; } }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.dot.octopus { background: var(--octopus); } .dot.almendralejo { background: var(--almen); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 10px 14px; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--text); border-color: var(--octopus); font-weight: 600; }

.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.cal .dow { background: var(--card); padding: 6px; font-size: 12px; color: var(--muted); text-align: center; }
.cal .day { background: var(--card); min-height: 92px; padding: 4px; font-size: 12px; }
.cal .day.off { opacity: .45; } .cal .day.today b { background: var(--octopus); color: #fff; border-radius: 99px; padding: 1px 6px; }
.chip { display: block; width: 100%; text-align: left; border: 0; border-left: 4px solid var(--octopus); background: var(--bg); border-radius: 6px; padding: 3px 6px; margin-top: 3px; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.almendralejo { border-color: var(--almen); } .chip.draft { opacity: .6; border-left-style: dashed; } .chip.proposed { border-left-style: dashed; background: transparent; outline: 1px dashed var(--line); }

.list-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border: 0; }
.muted { color: var(--muted); font-size: 13px; }
.issue { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.issue.closed { opacity: .55; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; } .checks label { display: flex; align-items: center; gap: 6px; color: var(--text); width: auto; }
.checks input { width: auto; }

dialog { border: 0; border-radius: 16px; padding: 0; width: min(640px, 94vw); background: var(--card); color: var(--text); }
dialog::backdrop { background: rgba(5, 12, 30, .6); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 18px; display: grid; gap: 12px; max-height: 76vh; overflow: auto; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none; transition: opacity .2s; }
#toast.show { opacity: 1; }

@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  aside { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  aside .who, aside .logo-sub { display: none; }
  main { padding: 14px; }
  .cal .day { min-height: 62px; }
}

.actions .badge { align-self: center; }
aside .who a { display: inline; padding: 0; color: #c9d4ec; }
aside .who a:hover { background: none; text-decoration: underline; }
.card h2.month { text-transform: none; }
.card h2.month::first-letter { text-transform: uppercase; }

/* v2: hoja de ruta, roles por gira */
.rs-row { display: grid; gap: 6px; margin-bottom: 8px; align-items: center; }
.rs-row input, .rs-row select { padding: 7px 9px; min-width: 0; }
@media (max-width: 800px) { .rs-row { grid-template-columns: 1fr 1fr 36px !important; } }
.roles-grid { display: grid; gap: 2px; font-size: 14px; }
.rg-head, .rg-row { display: grid; grid-template-columns: minmax(120px, 2fr) repeat(4, 1fr); gap: 6px; align-items: center; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.rg-head { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; text-align: center; }
.rg-head span:first-child { text-align: left; }
.rg-row label { justify-content: center; display: flex; }
.rg-row input { width: 20px; height: 20px; accent-color: var(--ok); }
.card.archived { opacity: .65; }
.badge a { color: inherit; margin-left: 4px; }
@media print { aside, .actions, .tabs, header { display: none !important; } .shell { display: block; } }

/* v2.1: varias giras a la vez */
.card.warn { border-color: #d9a441; background: color-mix(in srgb, #d9a441 12%, var(--card)); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }
.chip.cancelled { text-decoration: line-through; opacity: .55; }
