:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --ink: #1a1f2b;
  --muted: #6b7280;
  --line: #e4e7ec;
  --brand: #0b3d91;
  --brand-ink: #ffffff;
  --danger: #c62828;
  --warn: #ef6c00;
  --ok: #2e7d32;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 14px; color: inherit; }
.brand:hover { text-decoration: none; }
.brand-logo {
  height: 40px;
  width: auto;
  display: block;
}
.brand-text {
  display: flex; flex-direction: column;
  padding-left: 14px;
  border-left: 1px solid var(--line);
}
.brand-text small { color: var(--muted); font-size: 12px; line-height: 1.3; }

.topbar nav a { margin-left: 16px; color: var(--ink); font-size: 14px; }

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px;
}

footer {
  text-align: center; color: var(--muted);
  padding: 24px; font-size: 12px;
}

h1 { font-size: 26px; margin: 0 0 8px; }
h2 { font-size: 20px; margin: 28px 0 12px; }
h3 { font-size: 16px; margin: 0 0 8px; }

.muted { color: var(--muted); font-size: 14px; }

.hero { text-align: center; margin-bottom: 32px; }
.hero p { max-width: 640px; margin: 0 auto 20px; color: var(--muted); }

.upload-card {
  background: var(--surface); padding: 24px; border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 560px; margin: 0 auto;
  display: grid; gap: 12px; text-align: left;
}
.upload-card label { font-weight: 600; }
.upload-card input[type=file] {
  padding: 10px; border: 1px dashed var(--line); border-radius: 8px;
  background: #fafbfc;
}
.upload-card button {
  background: var(--brand); color: white; border: 0;
  padding: 12px 18px; border-radius: 8px;
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.upload-card button:hover { background: #082d6c; }
.upload-card small { color: var(--muted); }

button.danger {
  background: transparent; color: var(--danger);
  border: 1px solid var(--danger); padding: 4px 10px;
  border-radius: 6px; font-size: 12px; cursor: pointer;
}
button.danger:hover { background: var(--danger); color: white; }

.btn-secondary {
  display: inline-block;
  padding: 8px 14px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--surface);
  color: var(--ink); font-size: 14px;
}
.btn-secondary:hover { border-color: var(--ink); text-decoration: none; }

table.data {
  width: 100%; border-collapse: collapse;
  background: var(--surface); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow);
}
table.data th, table.data td {
  padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line);
  font-size: 14px;
}
table.data th { background: #fafbfc; font-weight: 600; }
table.data tr:last-child td { border-bottom: 0; }

.dept-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.dept-card {
  background: var(--surface); padding: 16px;
  border-left: 4px solid;
  border-radius: var(--radius);
  display: grid; gap: 4px; box-shadow: var(--shadow);
}
.dept-card small { color: var(--muted); font-size: 13px; }

.dot {
  display: inline-block;
  width: 10px; height: 10px; border-radius: 50%;
  margin-right: 6px; vertical-align: middle;
}

.schedule-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; margin-bottom: 20px;
}
.schedule-header .actions { display: flex; gap: 8px; }

.dept-tabs {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-bottom: 28px;
}
.dept-tab {
  background: var(--surface); padding: 14px 16px;
  border-radius: var(--radius); border-left: 4px solid;
  display: grid; gap: 4px;
  color: var(--ink); box-shadow: var(--shadow);
}
.dept-tab:hover { text-decoration: none; transform: translateY(-1px); }
.dept-tab .count { color: var(--muted); font-size: 13px; }

.summary-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.summary-col {
  background: var(--surface); padding: 16px;
  border-radius: var(--radius); box-shadow: var(--shadow);
}

.day-block { margin-bottom: 16px; }
.day-label {
  font-weight: 600; font-size: 13px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--line); padding-bottom: 4px; margin-bottom: 6px;
}
.day-block ul { list-style: none; padding: 0; margin: 0; }
.day-block li { padding: 4px 0; font-size: 13.5px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.day-block li .aa { color: var(--muted); font-variant-numeric: tabular-nums; }
.day-block li .vehicle { font-weight: 500; }
.day-block li.more { color: var(--muted); font-style: italic; padding-top: 6px; }

.day-section { margin: 24px 0; }
.day-heading {
  background: var(--surface); padding: 8px 14px; border-radius: 8px;
  border-left: 4px solid var(--brand);
  margin-bottom: 8px;
}

.config { color: var(--muted); font-style: italic; }
.config-row td { background: #fbf7ee; color: #5b4710; font-style: italic; }
.extra-row td { background: #fff5f4; }

.chamber-config {
  font-size: 12px; color: var(--muted); margin-top: 2px;
}

.badge {
  display: inline-block;
  padding: 1px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
}
.badge.extra { background: #fde2e0; color: var(--danger); }

.status {
  display: inline-block;
  padding: 1px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
}
.status-assigned { background: #e3f2fd; color: #1565c0; }
.status-ready    { background: #e8f5e9; color: var(--ok); }
.status-pending  { background: #f3f4f6; color: var(--muted); }

.dept-link { color: inherit; transition: transform .12s ease, box-shadow .12s ease; }
.dept-link:hover { text-decoration: none; transform: translateY(-1px); box-shadow: 0 2px 4px rgba(0,0,0,.08), 0 12px 32px rgba(0,0,0,.06); }
.dept-url {
  display: inline-block;
  margin-top: 4px;
  background: #fafbfc; padding: 2px 6px; border-radius: 4px;
  font-size: 11px; color: var(--muted);
}

.live-badge {
  display: inline-block;
  margin-left: 12px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .05em;
  color: var(--ok);
  background: #e8f5e9;
  border-radius: 999px;
  vertical-align: middle;
  animation: livePulse 2s ease-in-out infinite;
}
@keyframes livePulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .55; }
}
.live-badge.refreshing { background: #fff4e5; color: var(--warn); }

.empty-state {
  background: var(--surface);
  padding: 32px;
  border-radius: var(--radius);
  border: 1px dashed var(--line);
  text-align: center;
  margin-top: 16px;
}

.logout-form { display: inline; margin: 0; }
.logout-btn {
  background: transparent; color: var(--ink);
  border: 1px solid var(--line);
  padding: 6px 12px; border-radius: 6px;
  font-size: 13px; cursor: pointer;
  margin-left: 4px;
}
.logout-btn:hover { border-color: var(--danger); color: var(--danger); }

/* ===== Login page ===== */
.login-body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(11, 61, 145, .12), transparent 60%),
    radial-gradient(1000px 500px at 110% 110%, rgba(11, 61, 145, .10), transparent 60%),
    var(--bg);
  display: grid; place-items: center;
  padding: 24px;
}
.login-shell {
  width: 100%; max-width: 420px;
  display: flex; flex-direction: column; align-items: center;
}
.login-card {
  width: 100%;
  background: var(--surface);
  padding: 36px 32px 32px;
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 24px 60px rgba(11, 61, 145, .12);
  text-align: center;
  border-top: 4px solid var(--brand);
}
.login-logo {
  width: 220px; height: auto;
  display: block; margin: 0 auto 18px;
}
.login-card h1 { font-size: 22px; margin: 0 0 4px; }
.login-card .muted { margin: 0 0 24px; font-size: 14px; }
.login-form {
  display: grid; gap: 8px;
  text-align: left;
}
.login-form label {
  font-size: 13px; font-weight: 600; color: var(--ink);
  margin-top: 6px;
}
.login-form input {
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 15px;
  background: #fafbfc;
  transition: border-color .12s ease, background .12s ease;
}
.login-form input:focus {
  outline: none;
  border-color: var(--brand);
  background: white;
  box-shadow: 0 0 0 3px rgba(11, 61, 145, .12);
}
.login-form button {
  margin-top: 14px;
  background: var(--brand); color: white; border: 0;
  padding: 12px 18px; border-radius: 8px;
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: background .12s ease;
}
.login-form button:hover { background: #082d6c; }
.login-error {
  background: #fde2e0;
  color: var(--danger);
  border: 1px solid #f5c2bf;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  text-align: left;
  margin-bottom: 16px;
}
.login-footer { margin-top: 18px; color: var(--muted); }

.error-card {
  background: var(--surface); padding: 28px; border-radius: var(--radius);
  box-shadow: var(--shadow); max-width: 560px; margin: 60px auto;
  text-align: center; border-top: 4px solid var(--danger);
}

@media print {
  .topbar, footer, .actions, button { display: none !important; }
  main { padding: 0; max-width: none; }
  body { background: white; }
  table.data { box-shadow: none; }
  .schedule-header { border-bottom: 2px solid var(--ink); padding-bottom: 8px; }
}
