:root {
  --navy: #0b2a4a; --navy-2: #12406e; --blue: #1a73e8; --blue-soft: #e8f0fe;
  --bg: #f2f5f9; --card: #fff; --line: #dfe5ec; --text: #142233; --muted: #627285;
  --ok: #188038; --ok-soft: #e6f4ea; --warn: #b06000; --warn-soft: #fef3e0; --bad: #c5221f; --bad-soft: #fce8e6;
  --radius: 14px; --shadow: 0 2px 10px rgba(11, 42, 74, .08);
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; -webkit-text-size-adjust: 100%; }
a { color: var(--blue); }
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.2; }
h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; } h4 { font-size: .95rem; margin-top: 1em; }
code { background: #eef2f6; padding: 1px 5px; border-radius: 4px; font-size: .9em; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; } .nowrap { white-space: nowrap; }
.boot { padding: 40vh 0; text-align: center; color: var(--muted); }

/* Üst çubuk */
.topbar { position: sticky; top: 0; z-index: 900; display: flex; align-items: center; gap: 10px; padding: calc(10px + var(--safe-top)) 14px 10px; background: var(--navy); color: #fff; }
.topbar-title { flex: 1; font-weight: 700; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo { font-size: 1.3rem; }
.user-chip { background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 20px; padding: 6px 12px; font: inherit; font-size: .9rem; cursor: pointer; }
.page { max-width: 760px; margin: 0 auto; padding: 14px 12px calc(30px + var(--safe-bottom)); }
.page.wide { max-width: 1400px; }

/* Kartlar */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px; }
.card.narrow { max-width: 420px; margin: 20px auto; }
.card.link { display: block; color: inherit; text-decoration: none; }
.card.link:hover { outline: 2px solid var(--blue-soft); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.route-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; margin-bottom: 10px; }
.plate { display: inline-block; border: 2px solid var(--navy); border-radius: 6px; padding: 2px 8px; font-weight: 800; letter-spacing: .5px; font-size: .9rem; white-space: nowrap; background: #fff; }
.plate.small { font-size: .75rem; padding: 1px 6px; border-width: 1.5px; }
.row-between { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 980px) { .grid-2 { grid-template-columns: minmax(380px, 1fr) 1.2fr; } }

/* Düğmeler */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 10px; padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; min-height: 44px; background: #e9eef4; color: var(--text); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--blue); color: #fff; }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--text); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.sos { background: var(--bad); color: #fff; font-weight: 900; letter-spacing: 1px; }
.btn.block { display: flex; width: 100%; }
.btn.big { min-height: 52px; font-size: 1.05rem; padding: 12px 20px; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: .88rem; }
.icon-btn { border: 0; background: transparent; font-size: 1.1rem; cursor: pointer; padding: 6px 8px; border-radius: 8px; color: inherit; text-decoration: none; line-height: 1; }
.icon-btn.light { color: #fff; font-size: 1.8rem; padding: 0 8px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.spacer { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 16px; padding: 6px 12px; font: inherit; font-size: .9rem; cursor: pointer; }

/* Formlar */
label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; font-weight: 600; color: #34465a; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
input, select, textarea { font: inherit; font-size: 16px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--text); width: 100%; min-height: 44px; }
input[type=checkbox] { width: 20px; height: 20px; min-height: 0; }
textarea { resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
.input-row { display: flex; gap: 8px; } .input-row > input, .input-row > select { flex: 1; }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.day { flex-direction: row; } .day input { display: none; }
.day span { display: inline-block; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-weight: 600; }
.day input:checked + span { background: var(--blue); color: #fff; border-color: var(--blue); }

/* Uyarılar */
.notice { background: var(--blue-soft); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; font-size: .92rem; }
.notice.warn { background: var(--warn-soft); } .notice.ok { background: var(--ok-soft); }
.notice .issue { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 8px; }
.tag { display: inline-block; font-size: .75rem; font-weight: 700; border-radius: 6px; padding: 2px 7px; background: #eef2f6; color: var(--muted); }
.tag.ok { background: var(--ok-soft); color: var(--ok); } .tag.warn { background: var(--warn-soft); color: var(--warn); } .tag.bad { background: var(--bad-soft); color: var(--bad); }

/* Giriş */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, var(--navy), var(--navy-2)); }
.login-card { background: #fff; border-radius: 20px; padding: 28px 24px; width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.25); text-align: center; }
.login-card form { text-align: left; margin-top: 16px; }
.login-logo { font-size: 3rem; }

/* Personel: tahmini süre kutusu */
.eta { border-radius: 12px; padding: 16px; text-align: center; margin: 6px 0 4px; background: #eef2f6; }
.eta-label { font-size: .85rem; color: var(--muted); font-weight: 600; }
.eta-big { font-size: 1.9rem; font-weight: 800; line-height: 1.15; }
.eta-small { margin-top: 4px; color: #34465a; }
.eta-warn { margin-top: 6px; color: var(--warn); font-weight: 600; font-size: .9rem; }
.eta.live { background: var(--blue-soft); } .eta.live .eta-big { color: var(--blue); }
.eta.soon { background: #fff4d6; animation: pulse 1.6s infinite; } .eta.soon .eta-big { color: #a05a00; }
.eta.aboard, .eta.done { background: var(--ok-soft); } .eta.aboard .eta-big { color: var(--ok); }
.eta.absent { background: #f1f3f4; } .eta.absent .eta-big { color: var(--muted); font-size: 1.4rem; }
.eta.idle .eta-big { font-size: 1.4rem; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(249, 171, 0, .25); } }
.push-card { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
ul.plain { padding-left: 18px; margin: 0; }

/* Harita */
.map { width: 100%; border-radius: 12px; overflow: hidden; background: #e5e9ee; z-index: 0; }
.small-map { height: 230px; margin-top: 10px; }
.big-map { height: 70vh; min-height: 380px; }
.pick-map { height: 260px; }
.run-map { height: 42vh; min-height: 260px; margin-bottom: 10px; }
.bus-marker { width: 38px; height: 38px; border-radius: 50%; background: var(--blue); border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.35); display: grid; place-items: center; color: #fff; font-size: 16px; }
.bus-marker span { display: inline-block; transform-origin: center; margin-top: -1px; }
.bus-marker span { rotate: -90deg; }
.bus-marker.stale { background: #8a96a3; }
.stop-marker { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #fff; background: #f29900; border: 2px solid #fff; box-shadow: 0 1px 5px rgba(0,0,0,.35); }
.stop-marker.st-aboard, .stop-marker.st-done { background: var(--ok); }
.stop-marker.st-absent, .stop-marker.st-noshow { background: #9aa0a6; }
.stop-marker.next { outline: 3px solid var(--blue); outline-offset: 1px; transform: scale(1.15); }
.end-marker { width: 34px; height: 34px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-size: 18px; box-shadow: 0 1px 6px rgba(0,0,0,.35); }

/* Sürücü */
.track-bar { border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; font-size: .88rem; font-weight: 600; }
.track-bar.ok { background: var(--ok-soft); color: var(--ok); } .track-bar.warn { background: var(--warn-soft); color: var(--warn); }
.track-bar.bad { background: var(--bad-soft); color: var(--bad); } .track-bar.done { background: #eef2f6; color: var(--muted); }
.summary { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .9rem; margin: 2px 0 10px; color: #34465a; }
.summary.small { font-size: .82rem; margin: 6px 0; }
.card.next { border-left: 5px solid var(--blue); }
.card.next.done { border-left-color: var(--ok); }
.next-label { font-size: .75rem; font-weight: 800; letter-spacing: .6px; color: var(--blue); }
.next-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.next-name { font-size: 1.35rem; font-weight: 800; }
.next-eta { font-size: 1.2rem; font-weight: 800; color: var(--blue); white-space: nowrap; }
.stop-list { list-style: none; margin: 0; padding: 0; }
.stop-list li { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.stop-list li:last-child { border-bottom: 0; }
.stop-list li.is-next { background: var(--blue-soft); border-radius: 10px; }
.stop-list.compact li { padding: 5px 2px; }
.stop-no { width: 28px; height: 28px; flex: none; border-radius: 50%; display: grid; place-items: center; background: #f29900; color: #fff; font-weight: 800; font-size: .85rem; }
li.st-aboard .stop-no, li.st-done .stop-no, tr.st-aboard td:first-child, tr.st-done td:first-child { background: var(--ok); color: #fff; }
li.st-absent .stop-no, li.st-noshow .stop-no { background: #9aa0a6; }
li.st-absent .stop-name, li.st-noshow .stop-name { color: var(--muted); }
.stop-main { flex: 1; min-width: 0; } .stop-name { font-weight: 700; }
.stop-act { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.run-foot { position: sticky; bottom: 0; display: flex; gap: 8px; padding: 10px 0 calc(10px + var(--safe-bottom)); background: linear-gradient(transparent, var(--bg) 30%); z-index: 800; }
.run-foot .btn { flex: 1; }
.run-foot .btn.sos { flex: 0 0 90px; }

/* Yönetim */
.tabs { display: flex; gap: 4px; overflow-x: auto; margin: -4px 0 12px; padding-bottom: 4px; scrollbar-width: none; }
.tabs a { padding: 8px 14px; border-radius: 20px; text-decoration: none; color: var(--text); font-weight: 600; white-space: nowrap; background: #fff; border: 1px solid var(--line); }
.tabs a.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-bottom: 12px; }
.toolbar input[type=search] { max-width: 320px; } .toolbar select { max-width: 200px; }
.toolbar label { flex-direction: row; align-items: center; gap: 6px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); padding: 8px; border-bottom: 2px solid var(--line); }
.table td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr.inactive td { opacity: .5; }
.table tr.link { cursor: pointer; } .table tr.link:hover td { background: #f7f9fc; }
.sos-banner { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--bad); color: #fff; border-radius: 12px; padding: 12px 16px; margin-bottom: 10px; animation: pulse 1.6s infinite; }
.sos-banner a { color: #fff; }
.run-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 8px; cursor: pointer; }
.run-item.on { border-color: var(--blue); background: #fafcff; }
.stop-edit { list-style: none; padding: 0; margin: 8px 0; }
.stop-edit li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.stop-edit .grow { flex: 1; }
.event-list { list-style: none; padding: 0; margin: 0; max-height: 70vh; overflow: auto; }
.event-list li { padding: 7px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.event-list li.open { background: var(--bad-soft); padding: 8px; border-radius: 8px; }

/* Pencere */
.modal-wrap { position: fixed; inset: 0; z-index: 2000; background: rgba(10, 25, 45, .5); display: flex; align-items: flex-end; justify-content: center; padding: 0; }
@media (min-width: 640px) { .modal-wrap { align-items: center; padding: 20px; } }
.modal { background: #fff; width: 100%; max-width: 480px; max-height: 92vh; display: flex; flex-direction: column; border-radius: 18px 18px 0 0; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
@media (min-width: 640px) { .modal { border-radius: 18px; } }
.modal.wide { max-width: 860px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 6px; }
.modal-head h3 { margin: 0; }
.modal-body { padding: 6px 16px 10px; overflow: auto; }
.modal-foot { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; padding: 10px 16px calc(14px + var(--safe-bottom)); border-top: 1px solid var(--line); }
.modal-foot:empty { display: none; }

/* Bildirim balonu */
#toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translate(-50%, 150%); background: #1f2a37; color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 3000; max-width: min(92vw, 520px); box-shadow: 0 10px 30px rgba(0,0,0,.3); transition: transform .25s; font-size: .95rem; }
#toast.show { transform: translate(-50%, 0); }
#toast.error { background: var(--bad); } #toast.success { background: var(--ok); }
