:root {
  --bg: #1e1f22;
  --panel: #2a2c31;
  --border: #3a3d44;
  --fg: #e8e8e8;
  --muted: #9aa0a6;
  --accent: #4f8cff;
  --weekend: rgba(255, 255, 255, 0.05);
  --lock: #7a4a00;
  --lock-fg: #ffe1a8;
  --error: #6b1d1d;
  --status: #1f4d3a;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f5f7; --panel: #ffffff; --border: #d9dce1; --fg: #1d1d1f; --muted: #5f6368;
    --weekend: rgba(0, 0, 0, 0.04); --lock: #ffe9c2; --lock-fg: #5b3a00; --error: #ffd7d7; --status: #d9f2e6;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.4 "Segoe UI", system-ui, sans-serif; background: var(--bg); color: var(--fg); }
.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--border); }
.brand { font-weight: 600; font-size: 16px; }
.brand span { color: var(--accent); }
.who { flex: 1; color: var(--muted); }
.link { color: var(--accent); text-decoration: none; }
main { padding: 12px 16px 32px; max-width: 1400px; margin: 0 auto; }
/* BGM-BTK-REQ3610: bottom row (WinUI row 8): calendar fixed-width left, active projects stretch right. */
.bottom-panels { display: flex; gap: 16px; align-items: flex-start; margin-top: 12px; }
.bottom-panels .calendar { flex: 0 0 auto; }
.bottom-panels .active { flex: 1 1 auto; min-width: 0; margin-top: 0; width: auto; }
.muted { color: var(--muted); }

/* BGM-BTK-REQ3603: month calendar. Cell metrics follow WinUI (48x36 day, bar = 8h full, overtime above). */
.calendar { background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 8px; }
.cal-nav { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 6px; }
.cal-nav button { padding: 2px 8px; }
.cal-title { font-weight: 600; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 48px); gap: 2px; }
.cal-head { text-align: center; font-size: 11px; color: var(--muted); padding-bottom: 2px; }
.cal-day { position: relative; height: 36px; border: 1px solid transparent; border-radius: 3px; background: var(--bg); cursor: pointer; padding: 1px 3px; font-size: 12px; }
.cal-day:hover { border-color: var(--muted); }
.cal-day .num { position: absolute; top: 1px; left: 4px; }
.cal-day .hrs { position: absolute; top: 1px; right: 4px; font-size: 11px; color: var(--muted); }
.cal-day .bar { position: absolute; left: 3px; right: 3px; bottom: 2px; height: 5px; background: var(--border); border-radius: 2px; overflow: hidden; }
.cal-day .bar i { display: block; height: 100%; background: var(--accent); }
.cal-day .ot { position: absolute; left: 3px; right: 3px; bottom: 8px; height: 4px; border-radius: 2px; overflow: hidden; }
.cal-day .ot i { display: block; height: 100%; background: #e8742a; }
.cal-day.weekend { background: var(--weekend); }
.cal-day.other { opacity: 0.45; }
.cal-day.today { background: rgba(216, 191, 216, 0.35); }
.cal-day.locked { background-image: repeating-linear-gradient(135deg, transparent 0 6px, rgba(255, 200, 120, 0.12) 6px 8px); }
.cal-day.inweek { border-color: rgba(79, 140, 255, 0.55); }
.cal-day.selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-week-hidden { display: none; }

/* BGM-BTK-REQ3606: active projects panel */
.active { background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 8px; margin-top: 12px; width: 352px; }
.active h2 { font-size: 13px; font-weight: 600; margin: 0 0 6px; color: var(--muted); }
.active-list { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow-y: auto; }
.active-list li { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 6px; padding: 4px 2px; border-bottom: 1px solid var(--border); }
.active-list li:last-child { border-bottom: 0; }
.active-list .lbl { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.active-list .sub { display: block; font-weight: 400; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.active-list button { padding: 2px 8px; font-size: 12px; }
.active-list button.del { color: var(--muted); }
.active .empty { padding: 0; font-size: 12px; margin: 6px 2px; }
@media (max-width: 900px) { .bottom-panels { flex-direction: column; } .bottom-panels .active { width: 100%; } }

/* BGM-BTK-REQ3627: phone layout. Table hidden, one day at a time as cards. */
.mobile-week { display: none; }
@media (max-width: 699px) {
  main { padding: 8px 8px 24px; }
  .topbar { flex-wrap: wrap; gap: 8px 12px; padding: 8px 10px; }
  .topbar .who { flex: 1 1 100%; order: 3; font-size: 12px; }
  #downloadLink { display: none; } /* BGM-BTK-REQ3636: Windows installer is pointless on a phone */
  .week-nav { flex-wrap: wrap; }
  .week-nav h1 { flex: 1 1 100%; margin: 4px 0 0; font-size: 16px; }
  .add-row { flex-wrap: wrap; align-items: stretch; }
  .add-row label { flex: 1 1 100%; }
  .add-row select { min-width: 0; width: 100%; }
  .add-row button { flex: 1 1 45%; }
  .grid-wrap { overflow: visible; background: transparent; border: 0; }
  .grid, #emptyRows { display: none; }
  .mobile-week { display: block; }
  .day-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 8px; }
  .day-tab { display: flex; flex-direction: column; align-items: center; padding: 6px 0; font-size: 11px; line-height: 1.2; background: var(--panel); }
  .day-tab .dom { font-weight: 600; font-size: 13px; }
  .day-tab .tot { color: var(--muted); min-height: 13px; }
  .day-tab.weekend { background: var(--weekend); }
  .day-tab.locked { opacity: 0.6; }
  .day-tab.selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
  .day-summary { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); padding: 2px 4px 8px; }
  .day-summary b { color: var(--fg); }
  .day-cards { display: flex; flex-direction: column; gap: 8px; }
  .day-card { background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 10px; }
  .day-card.readonly { opacity: 0.7; }
  .card-head { display: flex; align-items: center; gap: 10px; }
  .card-proj { flex: 1 1 auto; min-width: 0; }
  .card-proj .sub { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .card-hours { width: 88px; font-size: 20px; text-align: center; padding: 8px 4px; }
  .card-meta { display: grid; grid-template-columns: 76px 1fr 36px; gap: 8px; margin-top: 8px; }
  .card-code { width: 100%; }
  .card-desc { width: 100%; min-width: 0; }
  .cal-grid { grid-template-columns: repeat(7, 1fr); }
  .cal-day { height: 40px; }
  .active { width: 100%; }
  .bottom-panels .calendar { width: 100%; }
}
.week-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.week-nav h1 { font-size: 18px; font-weight: 600; margin: 0 0 0 12px; }
button, select, input { font: inherit; color: var(--fg); background: var(--panel); border: 1px solid var(--border); border-radius: 4px; padding: 6px 10px; }
button { cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled, input:disabled, select:disabled { opacity: 0.5; cursor: not-allowed; }
.banner { padding: 10px 12px; border-radius: 6px; margin-bottom: 10px; }
.banner.lock { background: var(--lock); color: var(--lock-fg); }
.banner.error { background: var(--error); }
.banner.status { background: var(--status); }
.add-row { display: flex; gap: 12px; align-items: end; padding: 10px 12px; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; margin-bottom: 12px; }
.add-row label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; }
.add-row select { min-width: 220px; }
.grid-wrap { background: var(--panel); border: 1px solid var(--border); border-radius: 6px; overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; }
.grid th, .grid td { padding: 6px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.grid th { font-weight: 600; }
.grid th.col-day, .grid td.col-day, .grid th.col-total, .grid td.col-total { text-align: center; width: 64px; }
.grid .col-proj { width: 120px; font-weight: 600; }
.grid .col-code { width: 90px; }
/* REQ3596: fixed closed width so swapping option text to the long label while open doesn't shift the grid. */
.grid .col-code select { width: 72px; text-overflow: ellipsis; }
.grid .col-desc { min-width: 200px; }
.grid .col-desc input { width: 100%; }
.grid .col-del { width: 40px; }
.grid td.col-day input { width: 56px; text-align: center; padding: 4px; }
.grid .weekend { background: var(--weekend); }
.grid tfoot td { font-weight: 600; }
.grid tr.readonly td { opacity: 0.7; }
.empty { padding: 16px; color: var(--muted); margin: 0; }
.del { background: transparent; border: none; color: var(--muted); font-size: 16px; padding: 2px 6px; }

/* BGM-BTK-REQ4091: anonymous landing page and access help pages. */
.brand { display: flex; align-items: center; gap: 8px; }
.brand .logo { width: 28px; height: 28px; }
.landing { max-width: 960px; }
.landing h1 { font-size: 24px; margin: 16px 0 4px; }
.landing .hero { display: flex; align-items: center; gap: 20px; margin-top: 12px; }
.landing .hero h1 { margin: 0 0 4px; }
.landing .hero .hero-logo { width: 96px; height: 96px; flex: 0 0 auto; }
@media (max-width: 699px) { .landing .hero .hero-logo { width: 64px; height: 64px; } }
.landing .foot { margin-top: 24px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-top: 16px; }
.card { display: flex; flex-direction: column; gap: 10px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 18px; }
.card h2 { margin: 0; font-size: 18px; }
.card p { margin: 0; flex: 1 1 auto; }
.card .cta button { width: 100%; padding: 10px 12px; font-weight: 600; background: var(--accent); color: #fff; border-color: var(--accent); }
.card .cta button:disabled { background: var(--border); color: var(--muted); border-color: var(--border); }
.card .help { font-size: 13px; }
.help-page .steps { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 14px 18px; margin-top: 14px; }
.help-page .steps h2 { font-size: 16px; margin: 0 0 8px; }
.help-page .steps ol, .help-page .steps ul { margin: 0; padding-left: 22px; }
.help-page .steps li { margin: 6px 0; }
.del:hover:not(:disabled) { color: #ff6b6b; }
