/* TroopCor Routes. Plain, large and calm: one column, big targets, system fonts. */
:root {
  --navy: #1f3a5f; --navy-dark: #162c49; --amber: #f5b942;
  --bg: #f3f5f8; --card: #fff; --line: #d5dbe3; --text: #16202c; --muted: #5a6675;
  --blue: #1a5fb4; --green: #1c7c3c; --green-bg: #e3f4e8; --grey-bg: #e9ecf0; --red: #b3261e; --red-bg: #fdecea; --warn-bg: #fff6dd;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { font-size: 17px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 1rem/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
h1 { font-size: 1.7rem; margin: 0; line-height: 1.2; }
h2 { font-size: 1.15rem; margin: 0 0 14px; }
a { color: var(--blue); }
p { margin: 8px 0; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.grow { flex: 1 1 auto; }
.hidden, [hidden] { display: none !important; }
.loading { padding: 60px 20px; text-align: center; color: var(--muted); }
.arrow { color: var(--muted); font-weight: 400; }

/* controls */
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=password], input[type=search], input[type=number], input[type=date], input[type=time], select, textarea {
  width: 100%; min-height: 46px; padding: 9px 12px; background: #fff; border: 1.5px solid #9aa5b3; border-radius: 8px;
}
textarea { min-height: 70px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible, tr:focus-visible {
  outline: 3px solid var(--amber); outline-offset: 1px; border-color: var(--navy);
}
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset:disabled { opacity: .7; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 9px 16px; background: #fff; color: var(--text);
  border: 1.5px solid #9aa5b3; border-radius: 8px; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #eef2f7; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-dark); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger-text { color: var(--red); }
.btn.big { min-height: 52px; padding: 12px 26px; font-size: 1.05rem; }
.btn.small { min-height: 38px; padding: 5px 12px; font-size: .9rem; }
.btn.icon { min-width: 38px; padding: 5px 8px; }
.btn.link { min-height: 0; padding: 0; border: 0; background: none; color: var(--blue); text-decoration: underline; font-weight: 500; }
.btn:disabled { opacity: .45; cursor: default; }
.field { display: flex; flex-direction: column; gap: 5px; margin: 0 0 14px; min-width: 0; }
.field .lbl { font-weight: 600; }
.field .help, .help { font-size: .86rem; color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; min-height: 40px; cursor: pointer; }
.check input { width: 22px; height: 22px; flex: none; accent-color: var(--navy); }
.inline { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.inline input { width: auto; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.row.end { justify-content: flex-end; margin-top: 16px; }
.err { color: var(--red); font-weight: 600; margin: 6px 0; }
.err:empty { display: none; }

/* segmented buttons (On / Off, vehicle, days) */
.seg, .days { display: inline-flex; flex-wrap: wrap; border: 1.5px solid #9aa5b3; border-radius: 8px; overflow: hidden; background: #fff; }
.seg button, .days button { min-height: 43px; padding: 6px 14px; border: 0; border-right: 1px solid var(--line); background: #fff; cursor: pointer; font-weight: 600; }
.seg button:last-child, .days button:last-child { border-right: 0; }
.seg button.sel, .days button.sel { background: var(--navy); color: #fff; }
.days button { padding: 6px 10px; min-width: 50px; }

/* top bar */
.top { display: flex; align-items: center; gap: 18px; padding: 10px 22px; background: var(--navy); color: #fff; }
.top a { color: #fff; }
.top nav { display: flex; gap: 18px; }
.top nav a { text-decoration: none; font-weight: 600; padding: 6px 2px; border-bottom: 3px solid transparent; }
.top nav a:hover { border-bottom-color: var(--amber); }
.top .btn { background: transparent; color: #fff; border-color: rgba(255,255,255,.6); }
.top .btn:hover { background: rgba(255,255,255,.12); }
.brand { font-weight: 800; letter-spacing: .08em; text-decoration: none; font-size: 1.1rem; }
.brand span { margin-left: 8px; font-weight: 500; letter-spacing: 0; color: var(--amber); }
.who { font-size: .92rem; }

.page { max-width: 1180px; margin: 0 auto; padding: 22px 22px 120px; }
.head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin: 0 0 18px; }
.notice { background: var(--warn-bg); border: 1px solid #e7c873; border-radius: var(--radius); padding: 12px 16px; margin: 12px 0; }
.notice.bad { background: var(--red-bg); border-color: #f0b5b0; }

/* sign in */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--navy); }
.signin .card { width: 100%; max-width: 430px; padding: 30px; }
.signin .brand { display: block; color: var(--navy); margin-bottom: 18px; }
.signin .brand span { color: #9a6b00; }
.signin .btn.big { width: 100%; margin: 6px 0 12px; }

/* list */
.filters { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 8px; }
.search { min-height: 56px !important; font-size: 1.15rem; margin-bottom: 12px; }
.filters select { width: auto; max-width: 260px; }
.count { color: var(--muted); margin: 10px 2px; min-height: 1.4em; }
.tablewrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; background: #eef1f5; border-bottom: 1px solid var(--line); padding: 0; white-space: nowrap; }
.table th .sort { width: 100%; text-align: left; padding: 11px 14px; background: none; border: 0; font-weight: 700; cursor: pointer; }
.table td { padding: 11px 14px; border-bottom: 1px solid #e6eaef; vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table.plain th { padding: 8px 12px; }
.table.plain td { padding: 8px 12px; }
.rowlink { cursor: pointer; }
.rowlink:hover { background: #f1f6fd; }
.rowlink.dim { color: var(--muted); }
.rname { font-weight: 700; font-size: 1.05rem; text-decoration: none; }
.rowlink:hover .rname { text-decoration: underline; }
.sub { font-size: .86rem; color: var(--muted); }
.num { text-align: left; }
.empty { text-align: center; padding: 40px 14px !important; color: var(--muted); }
.tag { display: inline-block; margin-left: 8px; padding: 0 7px; border-radius: 5px; background: #e6edf8; color: #23467a; font-size: .78rem; font-weight: 700; }
.pill { display: inline-block; padding: 2px 12px; border-radius: 999px; font-size: .86rem; font-weight: 700; }
.pill.on { background: var(--green-bg); color: var(--green); }
.pill.off { background: var(--grey-bg); color: #48525f; }
.pill.removed { background: var(--red-bg); color: var(--red); }

/* one route */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 22px; }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.moneybox { display: flex; align-items: center; gap: 8px; }
.moneybox .money { text-align: right; }
.moneybox .unit { white-space: nowrap; color: var(--muted); font-size: .9rem; }
.rows { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.rowcard { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 12px; background: #f7f9fb; border: 1px solid var(--line); border-radius: 8px; }
.rowcard select, .rowcard input[type=time] { width: auto; }
.rowcard input.grow { flex: 1 1 170px; width: auto; }
.rowcard .combo { flex: 0 1 190px; }
.rowcard .mins { width: 90px; }
.seq { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--navy); color: #fff; font-weight: 700; flex: none; }
.combo { position: relative; }
.combo-list { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 3px); max-height: 280px; overflow-y: auto; background: #fff; border: 1.5px solid var(--navy); border-radius: 8px; box-shadow: 0 8px 22px rgba(0,0,0,.16); }
.opt { padding: 9px 12px; cursor: pointer; }
.opt:hover, .opt.sel { background: #e6edf8; }
.opt.none { color: var(--muted); cursor: default; }
.checklist { max-height: 300px; overflow-y: auto; margin-top: 10px; padding: 4px 12px; border: 1px solid var(--line); border-radius: 8px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
h2 .muted { font-weight: 400; font-size: .92rem; margin-left: 8px; }
details { margin-top: 6px; }
summary { cursor: pointer; color: var(--blue); font-weight: 600; padding: 6px 0; }
.history { list-style: none; margin: 0; padding: 0; }
.history li { padding: 10px 0; border-bottom: 1px solid #e6eaef; }
.history li:last-child { border-bottom: 0; }
.history.card { padding: 6px 22px; }
.savebar { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 2px solid var(--navy); box-shadow: 0 -4px 14px rgba(0,0,0,.08); z-index: 30; }
.savebar .inner { max-width: 1180px; margin: 0 auto; padding: 12px 22px; display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.savestate { color: #8a5a00; font-weight: 600; }

/* pop-up questions and messages */
.dialog { width: min(480px, calc(100vw - 32px)); padding: 24px; border: 0; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.dialog::backdrop { background: rgba(15, 25, 40, .5); }
#toasts { position: fixed; top: 16px; right: 16px; z-index: 50; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: #173d24; color: #fff; padding: 12px 16px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.25); font-weight: 600; }
.toast.bad { background: var(--red); }

@media (max-width: 760px) {
  html { font-size: 16px; }
  .grid, .grid.three, .checklist { grid-template-columns: 1fr; }
  .page { padding: 16px 14px 150px; }
  .top { flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
  .filters select { max-width: 100%; }
}
@media print {
  .no-print, #toasts, .savebar { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  .page { max-width: none; padding: 0; }
  .card, .tablewrap, .filters { border: 0; padding: 0; break-inside: avoid; }
  .card { margin-bottom: 14px; border-bottom: 1px solid #999; padding-bottom: 8px; }
  .checklist { max-height: none; overflow: visible; }
  .checklist .check:not(:has(input:checked)) { display: none; }
  input, select, textarea { border-color: #bbb !important; min-height: 0 !important; }
  .btn { display: none; }
  a { color: inherit; text-decoration: none; }
}
.field .seg { align-self: flex-start; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.tag.branch { margin-left: 0; background: #e8f0e4; color: #2c5a1e; font-size: .82rem; padding: 1px 8px; }
.branchline { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 10px 0 12px; }
.agpick select { width: auto; flex: 0 0 auto; }
.agpick input { flex: 1 1 240px; width: auto; }
.checklist .check .sub { margin-left: 4px; }
.seg.wrap { border: 0; gap: 6px; overflow: visible; background: none; }
.seg.wrap button { border: 1.5px solid #9aa5b3; border-radius: 8px; }
.seg.wrap button:last-child { border-right: 1.5px solid #9aa5b3; }
.seg.wrap button.sel { border-color: var(--navy); }
