:root {
  --navy: #071633;
  --blue: #1e3a8a;
  --blue-bright: #2563eb;
  --red: #e53935;
  --red-dark: #c62828;
  --gold: #fbbf24;
  --bg: #f3f5fb;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --ok: #047857;
  --ok-bg: #ecfdf5;
  --err: #991b1b;
  --err-bg: #fef2f2;
  --shadow: 0 18px 50px rgba(7, 22, 51, 0.18);
  --radius: 18px;
  --tap: 48px;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; }
img { max-width: 100%; height: auto; }
a { color: var(--blue); }
button, input, select, textarea { font: inherit; }
:focus-visible { outline: 3px solid #93c5fd; outline-offset: 2px; }
h1, h2 { font-weight: 700; letter-spacing: -0.02em; }
h1 { margin: 0; font-size: 1.7rem; }
h2 { margin: 0 0 12px; font-size: 1.05rem; }
p { margin: 0; }

.auth-body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 16px calc(28px + env(safe-area-inset-bottom));
  background:
    radial-gradient(circle at 12% 8%, rgba(251, 191, 36, 0.38), transparent 26%),
    radial-gradient(circle at 92% 100%, rgba(229, 57, 53, 0.42), transparent 32%),
    linear-gradient(165deg, #071633 0%, #16357a 58%, #0b1f4b 100%);
}
.auth-wrap { width: min(100%, 420px); }
.auth-logo { display: block; width: min(100%, 340px); margin: 0 auto 8px; filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.25)); }
.auth-kicker {
  margin: 4px 0 14px;
  text-align: center;
  color: var(--red);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.auth-card, .panel, .person, .log-card, .stat-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.auth-card { padding: 22px 18px 18px; }
.auth-card h1 { color: var(--navy); }
.lead, .muted, .hint { color: var(--muted); }
.lead { margin: 6px 0 16px; font-size: 15px; }
.hint { margin: 4px 0 14px; font-size: 13px; }

.field-label, .filters label > span:not(.select2) {
  display: block;
  margin: 12px 0 6px;
  font-size: 13px;
  font-weight: 700;
  color: #374151;
}
.field {
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  font-size: 16px;
}
.field:focus { border-color: var(--blue-bright); box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15); outline: none; }
.area { min-height: 96px; resize: vertical; }
.password-field { position: relative; }
.password-field .field { padding-right: 56px; }
.eye-btn {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #4b5563;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.eye-btn:hover, .eye-btn[aria-pressed="true"] { background: #eff6ff; color: var(--blue); }
.eye-btn .ico { width: 22px; height: 22px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0 18px;
  border-radius: 14px;
  border: 1.5px solid transparent;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.btn-primary { width: 100%; margin-top: 8px; background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); }
.btn-ghost { background: #fff; color: var(--navy); border-color: var(--line); }
.page-head .btn-primary, .filters .btn { width: auto; margin-top: 0; }

.alert {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--err-bg);
  color: var(--err);
  font-size: 14px;
  font-weight: 600;
}
.alert.ok { background: var(--ok-bg); color: var(--ok); }

.shell { min-height: 100dvh; }
.sidebar { display: none; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
}
.brand-mark img { width: 118px; display: block; }
.who {
  margin-left: auto;
  max-width: 42vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  font-size: 14px;
}
.topbar button, .side-foot button {
  min-height: 40px;
  border: 0;
  border-radius: 999px;
  background: #f3f4f6;
  color: var(--navy);
  font-weight: 700;
  padding: 0 14px;
  cursor: pointer;
}
.page { width: min(100%, 920px); margin: 0 auto; padding: 18px 16px calc(108px + env(safe-area-inset-bottom)); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.page-head h1 { font-size: 1.55rem; }
.kicker { margin: 0 0 4px; color: var(--red); font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.hero-block { margin-bottom: 16px; }
.hero-block h1 { font-size: 1.85rem; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.stat-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 108px;
  padding: 16px;
  text-decoration: none;
  color: var(--text);
  box-shadow: 0 8px 24px rgba(17, 24, 39, 0.06);
}
.stat-card span { color: var(--muted); font-size: 13px; font-weight: 700; }
.stat-card strong { font-size: 2rem; letter-spacing: -0.04em; }
.stat-card.wide { grid-column: 1 / -1; background: linear-gradient(135deg, #fff, #eef4ff); }
.stat-card:active { transform: scale(0.98); }

.panel { padding: 16px; margin-bottom: 16px; box-shadow: 0 8px 24px rgba(17, 24, 39, 0.06); }
.panel .btn-primary { margin-top: 8px; }
.narrow { max-width: 460px; }
.stack { display: grid; gap: 10px; }
.person, .log-card { padding: 14px; box-shadow: 0 8px 24px rgba(17, 24, 39, 0.05); }
.person { display: flex; justify-content: space-between; gap: 12px; }
.person div, .log-card { display: grid; gap: 4px; }
.person strong, .log-card strong { font-size: 16px; }
.person span, .log-card p { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.person-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; justify-content: center; }
.person-side form button { color: var(--red); }
.person-side a, .person-side button {
  border: 0;
  background: transparent;
  color: var(--blue);
  font-weight: 700;
  text-decoration: none;
  min-height: 32px;
  cursor: pointer;
  padding: 0;
}
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: #ecfdf5;
  color: var(--ok);
  font-size: 12px;
  font-weight: 700;
}
.pill.off, .pill.jadwal { background: #f3f4f6; color: #4b5563; }
.pill.live { background: #fff1f2; color: var(--red-dark); }
.pill.selesai { background: var(--ok-bg); color: var(--ok); }
.log-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.log-top time, .log-list time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.log-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.log-list li { display: flex; justify-content: space-between; gap: 12px; }
.log-list li div { display: grid; gap: 2px; }
.log-list span { color: var(--muted); font-size: 13px; }

.filters { display: flex; gap: 8px; margin-bottom: 14px; align-items: end; }
.filters .field { min-height: 46px; }
.filters.columns { display: grid; grid-template-columns: 1fr 1fr; }
.filters.columns .btn { grid-column: 1 / -1; width: 100%; }
.empty { padding: 28px 8px; text-align: center; color: var(--muted); }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 16px 0; font-weight: 700; }
.pager a { text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; }

.perm-group { border: 1px solid var(--line); border-radius: 14px; margin: 0 0 12px; padding: 8px 12px 12px; }
.perm-group legend { font-weight: 700; padding: 0 6px; }
.check-grid { display: grid; gap: 8px; }
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-size: 15px;
}
.check input { width: 20px; height: 20px; accent-color: var(--red); }

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 52px;
  color: #6b7280;
  text-decoration: none;
  font-size: 11px;
  font-weight: 700;
  border-radius: 12px;
}
.tabbar a.active { color: var(--red); background: #fff1f2; }
.tabbar .ico, .side-nav .ico { width: 22px; height: 22px; }

.segments { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.segments.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.segments.four a { font-size: 12px; padding: 0 4px; text-align: center; }
.segments a {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: #fff;
  border: 1.5px solid var(--line);
  color: var(--navy);
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
}
.segments a.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.filters.trip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 6px;
}
.filters.trip:has(input[type="date"]) {
  grid-template-columns: minmax(0, 1fr) 8.75rem auto;
  gap: 4px;
}
.filters.trip input[type="date"] {
  width: 100%;
  min-width: 0;
}
.filters.trip label {
  display: grid;
  align-content: end;
  min-width: 0;
  margin: 0;
  font-size: 0;
  line-height: 0;
}
.filters.trip .btn { align-self: end; }
.filters.trip select.field {
  min-height: 0 !important;
  height: 1px !important;
}
.filters.trip label > span:not(.select2) {
  display: block;
  margin: 0 0 6px;
  font-size: 12px;
  line-height: 1.2;
}
.filters.trip .field,
.filters.trip .btn,
.filters.trip .select2-container--default .select2-selection--single {
  height: 48px;
  min-height: 48px;
}
.filters.trip .field { padding: 0 8px; font-size: 16px; line-height: normal; }
.filters.trip .btn { width: auto; padding: 0 10px; font-size: 14px; line-height: normal; white-space: nowrap; }
.filters.trip .select2-container {
  display: block;
  width: 100% !important;
  margin: 0;
  font-size: 15px;
}
.filters.trip .select2-container--default .select2-selection--single {
  display: flex;
  align-items: center;
}
.filters.trip .select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 1.2;
  padding-left: 12px;
  padding-right: 4px;
}
.filters.trip .select2-container--default .select2-selection--single .select2-selection__arrow {
  position: relative;
  top: auto;
  right: auto;
  height: 48px;
  width: 28px;
  flex: none;
}
.trip-card {
  display: grid;
  gap: 6px;
  padding: 14px;
  text-decoration: none;
  color: inherit;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(17, 24, 39, 0.05);
}
.pill.go { background: #fff1f2; color: var(--red-dark); }
.pill.back { background: #eff6ff; color: var(--blue); }
.choice { border: 0; margin: 0 0 8px; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice legend { font-weight: 700; margin-bottom: 8px; }
.choice-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 12px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: #fff;
}
.choice-item input { width: 18px; height: 18px; accent-color: var(--red); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.group-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.group-head h2 { margin: 0; }
.text-actions { display: flex; gap: 12px; flex: none; }
.text-btn { border: 0; background: transparent; color: var(--blue); font-weight: 700; min-height: 44px; padding: 0; cursor: pointer; }

.select2-container { font-size: 16px; max-width: 100%; }
.select2-container--default .select2-selection--single {
  height: 48px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: #fff;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 46px;
  padding-left: 14px;
  padding-right: 36px;
  color: var(--text);
}
.select2-container--default .select2-selection--single .select2-selection__placeholder { color: var(--muted); }
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 46px; right: 6px; width: 28px; }
.select2-container--default .select2-selection--multiple {
  min-height: 48px;
  max-height: 240px;
  overflow-y: auto;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 4px 8px 8px;
}
.select2-container--default .select2-selection--multiple .select2-selection__rendered {
  display: block;
  padding: 0;
  white-space: normal;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice {
  float: none;
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  margin: 6px 6px 0 0;
  padding: 6px 10px;
  border: 0;
  border-radius: 999px;
  background: #eff6ff;
  color: var(--navy);
  font-size: 14px;
  font-weight: 700;
  white-space: normal;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
  color: var(--blue);
  margin-right: 6px;
}
.select2-container--default .select2-selection--multiple .select2-search--inline { float: none; display: block; }
.select2-container--default .select2-selection--multiple .select2-search--inline .select2-search__field {
  width: 100% !important;
  min-height: 36px;
  margin-top: 6px;
  font-size: 16px;
}
.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--focus .select2-selection--multiple,
.select2-container--default.select2-container--open .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--multiple {
  border-color: var(--blue-bright);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
}
.select2-dropdown {
  border: 1.5px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.select2-container--open { z-index: 40; }
.select2-search--dropdown { padding: 8px; }
.select2-container--default .select2-search--dropdown .select2-search__field {
  min-height: 44px;
  padding: 8px 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-size: 16px;
}
.select2-container--default .select2-results > .select2-results__options { max-height: min(280px, 46vh); }
.select2-container--default .select2-results__option { min-height: 44px; padding: 10px 14px; font-size: 16px; }
.select2-container--default .select2-results__option--highlighted[aria-selected] { background: var(--navy); color: #fff; }
.pick-warn, .warn-line { color: #b45309; }
.warn-line { font-weight: 700; }
.select2-results__option--highlighted .pick-warn { color: #fde68a; }
.roster { display: grid; gap: 8px; }
.person-pick {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 8px 12px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: #fff;
}
.person-pick[hidden] { display: none; }
.person-pick input { width: 22px; height: 22px; accent-color: var(--red); flex: none; }
.person-pick span { display: grid; gap: 2px; }
.person-pick small { color: var(--muted); font-size: 12px; }
.person-pick .warn { color: #b45309; }
.form-actions {
  position: sticky;
  bottom: calc(76px + env(safe-area-inset-bottom));
  padding-top: 12px;
  background: linear-gradient(transparent, #fff 30%);
}
.route { font-size: 1.15rem; font-weight: 700; }
.note, .count-line { margin-top: 8px; }
.row-actions { display: flex; gap: 8px; margin-top: 14px; }
.row-actions .btn, .row-actions form { flex: 1; }
.row-actions .btn { width: 100%; margin: 0; }
.btn-danger { background: #fff; color: var(--red); border-color: #fecaca; }
.manifest { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.manifest li { display: grid; gap: 2px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.manifest span, .manifest a { color: var(--muted); font-size: 14px; }
.back-link { margin: 4px 0 12px; }
.tabbar a { font-size: 10px; padding: 0 1px; }
.tabbar a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-final { margin-top: 8px; font-size: 1.6rem; font-weight: 800; letter-spacing: -0.03em; }
.medal { margin-top: 8px; font-weight: 800; }
.medal.emas { color: #a16207; }
.medal.perak { color: #475569; }
.medal.perunggu { color: #9a3412; }
.scoreboard { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.score-side {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 10px 12px;
  text-align: center;
}
.score-side.ours { box-shadow: inset 0 4px 0 var(--red); }
.score-side h2 { margin: 0; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-side p { min-height: 2.6em; margin-top: 4px; color: var(--muted); font-size: 12px; }
.score-num { margin: 8px 0 12px; font-size: 64px; font-weight: 800; line-height: 1; letter-spacing: -0.04em; }
.score-num.empty { font-weight: 500; color: #9ca3af; }
.score-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.score-controls form { margin: 0; }
.score-controls button {
  width: 100%;
  min-height: 64px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--navy);
  font-size: 32px;
  font-weight: 700;
  cursor: pointer;
}
.score-controls button.plus { background: var(--navy); color: #fff; border-color: var(--navy); }
.score-controls button:disabled { opacity: 0.35; cursor: default; }
.panel > form .btn-danger { width: 100%; margin-top: 8px; }

@media (min-width: 960px) {
  .shell { display: grid; grid-template-columns: 260px 1fr; }
  .sidebar {
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100dvh;
    padding: 18px 14px;
    background: var(--navy);
    color: #fff;
  }
  .brand { display: block; background: #fff; border-radius: 16px; padding: 10px; }
  .brand img { width: 100%; display: block; }
  .side-nav { display: grid; gap: 6px; margin-top: 18px; }
  .side-nav a, .side-foot a {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 46px;
    padding: 0 12px;
    border-radius: 12px;
    color: #dbe4ff;
    text-decoration: none;
    font-weight: 700;
  }
  .side-nav a.active, .side-foot a.active { background: rgba(255, 255, 255, 0.12); color: #fff; }
  .side-foot { margin-top: auto; display: grid; gap: 8px; }
  .side-foot button { width: 100%; background: rgba(255, 255, 255, 0.1); color: #fff; }
  .topbar, .tabbar { display: none; }
  .page { padding: 32px 36px 48px; }
  .filters.columns { grid-template-columns: 1.2fr 0.8fr 0.8fr 0.7fr 0.7fr auto; }
  .filters.columns .btn { grid-column: auto; width: auto; }
  .filters.trip:has(input[type="date"]) { grid-template-columns: minmax(220px, 1.4fr) minmax(180px, 0.8fr) auto; }
  .form-actions { bottom: 0; }
}
