:root {
  --bg: #eef1f6;
  --card: #ffffff;
  --card2: #f6f8fb;
  --border: #dde1e8;
  --text: #161b26;
  --muted: #5f677c;
  --brand: #0d2a5e;
  --brand-mid: #1b4fa0;
  --brand-light: #e5ecf8;
  --accent: #d4820a;
  --accent-light: #fff4e0;
  --accent-border: #f0d090;
  --accent-text: #6e4800;
  --dead: #b83030;
  --dead-bg: #fdf2f2;
  --dead-border: #f0c8c8;
  --live: #1a6b3c;
  --live-bg: #f0faf4;
  --live-border: #b8e8ca;
  --on-brand: #ffffff;
  --backdrop: rgba(22, 27, 38, 0.55);
  --shadow-card: 0 1px 3px rgba(13, 42, 94, 0.06);
  --shadow-pop: 0 8px 24px rgba(0, 0, 0, 0.22);
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --tone-blue: #2a78d6; --tone-orange: #eb6834; --tone-teal: #1baf7a; --tone-amber: #eda100;
  --tone-magenta: #e87ba4; --tone-green: #008300; --tone-purple: #4a3aa7; --tone-red: #e34948; --tone-grey: #898781;
  --tone-ink: #161b26;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-mid); }
.wrap { max-width: 1840px; margin: 0 auto; padding: 0 12px; }
@media (min-width: 700px) { .wrap { padding: 0 20px; } }

.top { position: sticky; top: 0; z-index: 50; background: var(--brand); color: var(--on-brand); border-bottom: 3px solid var(--accent); }
.top .wrap { display: flex; align-items: center; gap: 10px; min-height: 56px; }
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; margin-right: auto; color: inherit; text-decoration: none; }
.brand-name { font-weight: 800; font-size: 16px; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { display: block; font-size: 11px; font-weight: 600; opacity: 0.75; }
.nav { display: flex; gap: 2px; }
.nav a { display: flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 8px; color: var(--on-brand); text-decoration: none; font-weight: 600; white-space: nowrap; }
.nav a:hover { background: rgba(255, 255, 255, 0.1); }
.nav a.active { background: rgba(255, 255, 255, 0.16); box-shadow: inset 0 -3px 0 var(--accent); }
.menu-btn { display: none; min-height: 44px; padding: 0 12px; border: 1px solid rgba(255, 255, 255, 0.4); border-radius: 8px; background: transparent; color: var(--on-brand); font-weight: 700; }
.user-btn { min-width: 44px; min-height: 44px; padding: 0 10px; border: 0; border-radius: 99px; background: var(--accent); color: var(--on-brand); font-weight: 800; }
@media (max-width: 899px) {
  .menu-btn { display: block; }
  .nav { display: none; position: absolute; top: 59px; left: 0; right: 0; flex-direction: column; gap: 0; padding: 6px 12px 12px; background: var(--brand); box-shadow: var(--shadow-pop); }
  .nav.open { display: flex; }
  .nav a { min-height: 48px; }
}
.user-menu { position: absolute; right: 12px; top: 62px; z-index: 60; min-width: 220px; padding: 8px; border-radius: 10px; background: var(--card); color: var(--text); box-shadow: var(--shadow-pop); }
.user-menu .who { padding: 6px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.user-menu .who small { display: block; color: var(--muted); }
.user-menu button { display: block; width: 100%; min-height: 44px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; text-align: left; }
.user-menu button:hover { background: var(--brand-light); }

main.wrap { padding-top: 14px; padding-bottom: 40px; }
.page-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 4px 0 12px; }
.page-title h1 { margin: 0; font-size: 22px; color: var(--brand); }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-card); padding: 14px; }
.card + .card { margin-top: 14px; }
.card h2 { margin: 0 0 10px; font-size: 17px; color: var(--brand); }
.card h3 { margin: 16px 0 6px; font-size: 15px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px; border: 0; border-radius: 8px; background: var(--brand); color: var(--on-brand); font-weight: 700; cursor: pointer; text-decoration: none; }
.btn:hover:not(:disabled) { background: var(--brand-mid); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.secondary { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover:not(:disabled) { background: var(--card2); }
.btn.danger { background: var(--dead); }
.btn.accent { background: var(--accent); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.spacer { flex: 1; }
label { display: block; font-weight: 600; font-size: 14px; }
.field { margin-bottom: 12px; }
.field small, .hint { display: block; color: var(--muted); font-size: 13px; font-weight: 400; margin-top: 4px; }
input[type="text"], input[type="password"], input[type="date"], input[type="datetime-local"], input[type="number"], input[type="tel"], input[type="email"], input[type="search"], select, textarea {
  display: block; width: 100%; min-height: 44px; margin-top: 4px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); font-size: 16px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.check { display: flex; align-items: flex-start; gap: 10px; min-height: 36px; padding: 4px 0; font-weight: 400; }
.check input { flex: none; width: 20px; height: 20px; margin: 2px 0 0; }
.check.disabled { color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 0 14px; }
@media (min-width: 640px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.msg { margin: 10px 0; padding: 10px 12px; border: 1px solid var(--accent-border); border-radius: 8px; background: var(--accent-light); color: var(--accent-text); }
.msg.bad { border-color: var(--dead-border); background: var(--dead-bg); color: var(--dead); }
.msg.good { border-color: var(--live-border); background: var(--live-bg); color: var(--live); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; background: var(--brand-light); color: var(--brand); font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge.warn { background: var(--accent-light); color: var(--accent-text); }
.badge.bad { background: var(--dead-bg); color: var(--dead); }
.badge.later { background: var(--card2); color: var(--muted); border: 1px dashed var(--border); }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { padding: 10px 8px; border-top: 1px solid var(--border); text-align: left; vertical-align: top; }
table.list th { font-size: 13px; color: var(--muted); border-top: 0; }
table.list td.hint, table.list th.hint { display: table-cell; }
.empty { padding: 24px 8px; color: var(--muted); text-align: center; }
.loading { display: flex; justify-content: center; padding: 48px 0; }
.loading img { width: 56px; height: 56px; border-radius: 12px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.45; transform: scale(0.94); } 50% { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .loading img { animation: none; } }

.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 16px 8px; background: var(--backdrop); overflow-y: auto; }
.modal-box { width: 100%; max-width: 560px; margin: auto 0; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow-pop); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 18px; color: var(--brand); flex: 1; }
.modal-body { padding: 14px; }
.modal-foot { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border); }
@media (max-width: 520px) {
  .modal { padding: 0; align-items: stretch; }
  .modal-box { max-width: none; min-height: 100%; border-radius: 0; }
  .modal-foot .btn { flex: 1; }
}

.center-screen { display: flex; align-items: center; justify-content: center; min-height: calc(100vh - 60px); padding: 20px 12px; }
.signin { width: 100%; max-width: 400px; }
.signin .logo { display: block; width: 64px; height: 64px; margin: 0 auto 10px; border-radius: 14px; }
.signin h1 { margin: 0 0 4px; text-align: center; font-size: 22px; color: var(--brand); }
.signin p.sub { margin: 0 0 16px; text-align: center; color: var(--muted); }
.or { display: flex; align-items: center; gap: 10px; margin: 16px 0; color: var(--muted); font-size: 13px; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.full { width: 100%; }

.tone { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 700; color: var(--on-brand); }
.tone-blue { background: var(--tone-blue); } .tone-orange { background: var(--tone-orange); } .tone-teal { background: var(--tone-teal); }
.tone-amber { background: var(--tone-amber); } .tone-magenta { background: var(--tone-magenta); } .tone-green { background: var(--tone-green); }
.tone-purple { background: var(--tone-purple); } .tone-red { background: var(--tone-red); } .tone-grey { background: var(--tone-grey); }
.tone-amber, .tone-magenta, .tone-teal { color: var(--tone-ink); }
.swatch { display: inline-block; width: 22px; height: 22px; border-radius: 6px; vertical-align: middle; }

.toolbar { margin-bottom: 8px; }
.toolbar input[type="search"] { flex: 1 1 240px; margin-top: 0; }
label.inline { display: inline-flex; align-items: center; gap: 6px; margin: 0; white-space: nowrap; }
label.inline select { width: auto; margin-top: 0; }
.check.inline { display: inline-flex; min-height: 44px; align-items: center; padding: 0 10px 0 0; }
.check.inline input { margin: 0; }
.th-sort { padding: 0; border: 0; background: none; color: inherit; font: inherit; font-weight: 700; cursor: pointer; white-space: nowrap; }
.th-sort.on { color: var(--brand); }
table.list td.pick, table.list th.pick { width: 36px; padding-right: 0; }
table.list td.pick input, table.list th.pick input { width: 20px; height: 20px; margin: 2px 0 0; }
table.list tr.dim td { color: var(--muted); }
.batch-bar { position: sticky; bottom: 0; z-index: 40; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; padding: 10px 12px; border-radius: var(--radius); background: var(--brand); color: var(--on-brand); box-shadow: var(--shadow-pop); }
.batch-bar .btn.secondary { background: rgba(255, 255, 255, 0.12); color: var(--on-brand); border-color: rgba(255, 255, 255, 0.35); }
.grid3 { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
@media (min-width: 640px) { .grid3 { grid-template-columns: 1.3fr 1fr 1fr; } }
fieldset.emergency { margin: 0 0 10px; padding: 8px 12px 0; border: 1px solid var(--border); border-radius: 10px; }
fieldset.emergency legend { padding: 0 6px; font-weight: 700; font-size: 14px; }

.dir-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--border); }
.card h2 + .dir-row, .card > .dir-row:first-child { border-top: 0; }
.dir-who { flex: 1; min-width: 150px; }

.nav-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; margin-left: 6px; padding: 0 6px; border-radius: 99px; background: var(--accent); color: var(--on-brand); font-size: 12px; font-weight: 800; }
.req { padding: 10px 0; border-top: 1px solid var(--border); }
.req:first-of-type { border-top: 0; }
.req-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.req-head strong { margin-right: auto; }
.req .overlaps { margin: 6px 0 0; padding: 6px 10px; border-radius: 8px; background: var(--card2); font-size: 14px; }
.req .actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.badge.good { background: var(--live-bg); color: var(--live); }
.req-section { margin: 14px 0 4px; padding-top: 10px; border-top: 2px solid var(--border); font-size: 15px; color: var(--brand); }
.card h2 + .req-section { margin-top: 0; padding-top: 0; border-top: 0; }
.req-section.cancel { color: #b00000; }

.brand-logo { display: block; height: 38px; width: auto; flex: none; }
.brand .brand-name { font-size: 13px; font-weight: 700; opacity: 0.9; padding-left: 10px; border-left: 1px solid rgba(255, 255, 255, 0.35); }
@media (max-width: 400px) { .brand-logo { height: 30px; } .brand .brand-name { font-size: 12px; padding-left: 8px; } }
.signin .logo-wide { display: block; width: 220px; max-width: 80%; height: auto; margin: 4px auto 12px; }
.hint.center { text-align: center; }
.user-menu .menu-link { display: flex; align-items: center; min-height: 44px; padding: 0 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.user-menu .menu-link:hover { background: var(--brand-light); }
.terms-card { width: 100%; max-width: 760px; }
.terms-card h1 { margin: 0 0 4px; font-size: 22px; color: var(--brand); }
.terms-card .sub { margin: 0 0 12px; color: var(--muted); }
.terms-scroll { max-height: min(55vh, 520px); overflow-y: auto; margin-bottom: 12px; padding: 4px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--card2); font-size: 14px; }
.terms-scroll h2 { font-size: 16px; }
.terms-scroll h3, .terms-doc h3 { margin: 14px 0 4px; font-size: 15px; color: var(--brand); }
.terms-page main { padding: 16px 12px 40px; }
.terms-doc { max-width: 860px; margin: 0 auto; }
.terms-doc h2 { margin-top: 0; color: var(--brand); }
.terms-meta { color: var(--muted); font-size: 13px; }
.terms-foot { color: var(--muted); font-size: 13px; }
ol.steps { margin: 8px 0; padding-left: 22px; }
ol.steps li { margin: 4px 0; }
input[type="time"] { display: block; width: 100%; min-height: 44px; margin-top: 4px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); font-size: 16px; }
