:root {
  --ink: #1c1915;
  --muted: #6e675c;
  --paper: #f3efe6;
  --card: #fbf8f2;
  --line: #ddd4c6;
  --navy: #1b2a4a;
  --navy-2: #2c4168;
  --crimson: #9e2b3a;
  --lunch: #c47a32;
  --dinner: #6a3546;
  --road: #1b2a4a;
  --ok: #2f5d50;
  --danger: #9e2b3a;
  --shadow: 0 18px 50px rgba(28, 25, 21, 0.12);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Source Han Sans SC", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #fff8ea 0%, transparent 50%),
    var(--paper);
}

.hidden { display: none !important; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.ghost, .primary, .danger, .login-card button {
  border: 0;
  border-radius: 6px;
  padding: 8px 14px;
}
.ghost { background: #efe8da; color: var(--ink); }
.ghost:hover { background: #e5dccb; }
.primary { background: var(--navy); color: #fff; }
.danger { background: var(--danger); color: #fff; }
.error { color: var(--danger); min-height: 1.2em; }

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 36px 32px 28px;
  display: grid;
  gap: 12px;
}
.login-kicker {
  margin: 0;
  letter-spacing: 0.28em;
  font-size: 12px;
  color: var(--crimson);
  text-transform: none;
}
.login-card h1 { margin: 0; font-size: 28px; letter-spacing: 0.08em; }
.login-sub { margin: 0 0 8px; color: var(--muted); }
.login-card label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.login-card input[type="password"] {
  border: 1px solid var(--line);
  background: #fff;
  padding: 10px 12px;
  border-radius: 6px;
}
.login-help { margin: 0; font-size: 13px; }
.login-help a { color: var(--navy); }
.check { display: flex; align-items: center; gap: 8px; }
.top-actions a.ghost {
  display: inline-block;
  text-decoration: none;
  line-height: 1.2;
}
.login-card button { background: var(--navy); color: #fff; padding: 11px; }

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--navy);
  color: #f6f1e6;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand-home {
  color: #e2c48a;
  text-decoration: none;
  font-size: 12px;
  letter-spacing: 0.08em;
}
.brand-home:hover { text-decoration: underline; }
.brand-mark { font-size: 12px; letter-spacing: 0.22em; color: #e2c48a; }
.tabs { display: flex; background: #132038; padding: 4px; border-radius: 8px; }
.tab {
  background: transparent;
  color: #c9d3e5;
  border: 0;
  padding: 8px 18px;
  border-radius: 6px;
}
.tab.is-on { background: #f3efe6; color: var(--navy); }
.top-actions { justify-self: end; display: flex; gap: 8px; }
.top-actions .ghost { background: #2c4168; color: #f6f1e6; }

main { padding: 16px 20px 32px; }
.week-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.week-bar h2 { margin: 0 0 0 8px; font-size: 18px; font-weight: 600; }
.week-bar .primary { margin-left: auto; }

.grid-wrap {
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  max-height: calc(100vh - 140px);
}
.road-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 980px;
  table-layout: fixed;
  font-size: 12px;
}
.road-table th, .road-table td {
  border: 1px solid var(--line);
  vertical-align: top;
}
.road-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #ebe4d6;
  padding: 8px 6px;
  font-weight: 600;
}
.hd-week, .hd-date { display: inline; }
.hd-week::after { content: " "; }
.day-region {
  display: block;
  width: 100%;
  max-width: 100%;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--navy);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 4px;
}

.cal-caption {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
}
.cal-picked {
  font-size: 12px;
  color: var(--navy);
  margin-bottom: 8px;
}
.cal-mon {
  display: block;
  font-size: 10px;
  line-height: 1.1;
  opacity: 0.75;
}
.cal-day { display: block; font-size: 13px; line-height: 1.2; }
.cal button {
  display: grid;
  justify-items: center;
  padding: 4px 0;
}

@media (max-width: 820px) {
  .topbar {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 8px 10px;
  }
  .brand { flex-wrap: wrap; gap: 6px; }
  .brand-home { font-size: 11px; }
  .top-actions { justify-self: stretch; }
  .top-actions .ghost, .tab { padding: 6px 10px; font-size: 13px; }
  main { padding: 8px 8px 16px; }
  .week-bar { flex-wrap: wrap; gap: 6px; }
  .week-bar h2 { margin: 0; font-size: 13px; width: 100%; }
  .ghost, .primary { padding: 6px 10px; font-size: 13px; }

  .grid-wrap {
    overflow-x: hidden;
    overflow-y: auto;
    max-height: calc(100dvh - 168px);
    border-radius: 8px;
  }
  .road-table {
    min-width: 0;
    width: 100%;
    font-size: 10px;
  }
  .road-table thead th {
    padding: 4px 1px;
    line-height: 1.15;
  }
  .hd-week, .hd-date { display: block; }
  .hd-week::after { content: none; }
  .hd-week { font-size: 10px; }
  .hd-date { font-size: 9px; font-weight: 500; color: var(--muted); }
  .day-region {
    margin-top: 2px;
    font-size: 9px;
    padding: 0 1px;
  }
  .road-table .time {
    width: 32px;
    font-size: 9px;
    padding: 0 1px;
  }
  .road-table td.slot { height: 22px; }
  .block {
    padding: 1px 2px;
    min-height: 20px;
    font-size: 9px;
    overflow: hidden;
    line-height: 1.15;
  }
  .block small { display: none; }

  .modal { padding: 8px; }
  .modal-card { padding: 14px; }
  .form-row { grid-template-columns: 1fr; }
  .data-table { font-size: 12px; }
  .data-table th, .data-table td { padding: 8px 6px; }
}
.road-table .time {
  width: 44px;
  padding-left: 2px;
  padding-right: 2px;
  text-align: center;
  color: var(--muted);
  background: #f7f3ea;
  font-variant-numeric: tabular-nums;
}
.road-table td.slot {
  height: 28px;
  cursor: pointer;
  background: #fff;
}
.road-table td.slot:hover { background: #fff7e8; }
.block {
  display: block;
  height: 100%;
  min-height: 26px;
  padding: 4px 6px;
  color: #fff;
  border: 0;
  width: 100%;
  text-align: left;
  border-radius: 3px;
  line-height: 1.25;
}
.block.t-路演 { background: var(--road); }
.block.t-午餐 { background: var(--lunch); }
.block.t-晚餐 { background: var(--dinner); }
.block small { display: block; opacity: 0.85; font-weight: 400; }
.blk-org, .blk-client {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.blk-client { opacity: 0.9; font-weight: 400; }

.table-wrap {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: auto;
}
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
}
.data-table tbody tr { cursor: pointer; }
.data-table tbody tr:hover { background: #fff7e8; }
.week-head td {
  background: #ebe4d6;
  font-weight: 600;
  color: var(--navy);
  user-select: none;
}
.week-head:hover td { background: #e3d9c8; }
.week-caret { display: inline-block; width: 1.2em; }
.week-count { color: var(--muted); font-weight: 500; margin-left: 8px; }
.data-table tbody tr.is-collapsed { display: none; }
.empty { text-align: center; color: var(--muted); cursor: default !important; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(27, 42, 74, 0.38);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 24px 16px;
  z-index: 20;
}
.modal-card {
  width: min(520px, 100%);
  margin: auto;
  background: var(--card);
  border-radius: 12px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.modal-card h3 { margin: 0 0 14px; }
.form { display: grid; gap: 10px; }
.form label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.form input, .form select, .form textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
.suggest { position: relative; }
.suggest-list {
  position: absolute;
  left: 0; right: 0; top: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  max-height: 220px;
  overflow: auto;
  z-index: 5;
  margin: 0;
  padding: 4px 0;
  list-style: none;
}
.suggest-list li { padding: 7px 10px; cursor: pointer; }
.suggest-list li:hover, .suggest-list li.is-on { background: #fff1d6; }
.suggest-list .sub { color: var(--muted); font-size: 12px; margin-left: 8px; }

.cal {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-top: 6px;
}
.cal b, .cal button {
  text-align: center;
  font-size: 12px;
  padding: 6px 0;
}
.cal b { color: var(--muted); font-weight: 500; }
.cal button {
  border: 1px solid transparent;
  background: #fff;
  border-radius: 4px;
}
.cal button:hover { border-color: var(--navy); }
.cal button.is-on { background: var(--navy); color: #fff; }
.cal button:disabled { opacity: 0.3; }

.checks { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.checks label { display: flex; align-items: center; gap: 6px; color: var(--ink); }
