:root {
  --primary: #37474F; --accent: #BF5B3C; --accent-ink: #9c4528; --amber: #F9A825; --warn-bg: #fff4e0; --warn-ink: #6b4300;
  --bg: #f4f6f7; --card: #ffffff; --ink: #1d2529; --muted: #5b6770; --line: #d9e0e4; --hero: #37474F; --hero-ink: #ffffff;
  --chip: #e8edf0; --hold: #e3e7ea; --clash: #fde3dc;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --primary: #90a4ae; --accent: #e08a6c; --accent-ink: #e08a6c; --amber: #ffc83d; --warn-bg: #3a2c12; --warn-ink: #ffd99a;
    --bg: #0f1416; --card: #1a2126; --ink: #e6ebee; --muted: #a2adb4; --line: #2c373e; --hero: #263238; --hero-ink: #ffffff;
    --chip: #253038; --hold: #2a3238; --clash: #4a2a22;
    color-scheme: dark; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
a { color: var(--accent-ink); }
button, input, select { font: inherit; color: inherit; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.grow { flex: 1; }

header.top { background: var(--hero); color: var(--hero-ink); }
.bar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand img { width: 32px; height: 32px; border-radius: 8px; }
.acct-btn { min-height: 40px; padding: 0 16px; border-radius: 10px; border: 2px solid rgba(255,255,255,.7); background: transparent; color: #fff; font-weight: 650; cursor: pointer; }
.head { padding: 8px 16px 26px; }
.head h1 { margin: 0 0 6px; font-size: clamp(26px, 5vw, 38px); line-height: 1.15; }
.head p { margin: 0; max-width: 760px; opacity: .92; }

.acct { margin-top: 16px; }
.acct .card { display: grid; gap: 10px; }
.signin-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
/* Sign-in panel: Apple and Google buttons the same width and height, stacked, so neither looks preferred. */
.acct-card { max-width: 560px; }
.acct-title { margin: 0; font-size: 20px; }
.signin-stack { display: grid; gap: 10px; justify-items: start; }
.apple-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 320px; max-width: 100%; height: 40px; padding: 0 16px; border-radius: 4px; border: 1px solid #000; background: #000; color: #fff; font: 500 14px/1 -apple-system, system-ui, sans-serif; cursor: pointer; }
.apple-btn:focus-visible, .acct-btn:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
/* Google draws its button in a frame 20px wider and 4px taller with -10px/-2px margins. color-scheme: light stops the browser painting
   that frame white on a dark page, so only Google's 320x40 button shows, lined up with the Apple button. */
.g-btn { width: 320px; max-width: 100%; min-height: 40px; color-scheme: light; }
/* Every full-size button in the account panel: one width, height and corner, stacked, like the sign-in buttons. */
.acct-acts { display: grid; gap: 10px; justify-items: start; }
.acct-acts .btn { width: 320px; max-width: 100%; min-height: 40px; border-radius: 4px; padding: 8px 16px; font-size: 14px; line-height: 1.25; }
.btn.danger-line { background: transparent; border: 1px solid #b3261e; color: #b3261e; }
.acct-pick { margin: 0; font-size: 14px; }
.acct-who { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.acct-name { display: grid; gap: 2px; min-width: 0; }
.acct-name .muted { font-size: 14px; overflow-wrap: anywhere; }
.acct-badge { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: #fff; color: #000; flex: none; }
.acct-badge svg { width: 20px; height: 20px; }
.acct-badge.apple { background: #000; color: #fff; border-color: #000; }
.acct-mark { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #fff; color: #000; margin-right: 8px; vertical-align: -5px; }
.acct-mark svg { width: 14px; height: 14px; }
.acct-btn { display: inline-flex; align-items: center; }
.pill { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 14px; font-weight: 600; background: var(--chip); color: var(--ink); }
.pill.on { background: #e3f3e6; color: #1e5b2a; }
.acct-status { margin: 0; font-weight: 600; }
.acct-ways { display: grid; gap: 6px; border-top: 1px solid var(--line); padding-top: 10px; }
.ways { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.way { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 40px; }
.way .acct-mark { margin-right: 0; border: 1px solid var(--line); }
.way .acct-mark.apple { background: #000; color: #fff; border-color: #000; }
@media (prefers-color-scheme: dark) {
  .apple-btn { background: #fff; color: #000; border-color: #fff; }
  .acct-badge.apple { background: #fff; color: #000; border-color: #fff; }
  .pill.on { background: #1f3a25; color: #bfe8c8; }
}

.layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; margin-top: 20px; align-items: start; }
.tools-nav { position: sticky; top: 12px; display: grid; gap: 4px; }
.tools-nav h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 8px 4px; }
.tools-nav h2:first-child { margin-top: 0; }
.tools-nav a { display: block; padding: 8px 12px; border-radius: 10px; color: var(--ink); text-decoration: none; }
.tools-nav a[aria-current="page"] { background: var(--primary); color: #fff; font-weight: 650; }
@media (prefers-color-scheme: dark) { .tools-nav a[aria-current="page"] { color: #0f1416; } }
@media (max-width: 760px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .tools-nav { position: static; display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
  .tools-nav h2 { display: none; }
  .tools-nav a { flex: none; background: var(--chip); white-space: nowrap; }
}

main { min-width: 0; outline: none; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 14px; }
.card h2 { margin: 0 0 4px; font-size: 22px; }
.card h3 { margin: 0 0 8px; font-size: 17px; }
.notice { background: var(--warn-bg); color: var(--warn-ink); border-radius: 12px; padding: 10px 14px; margin: 0 0 14px; font-size: 15px; }

.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px 12px; }
.field { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
.field input, .field select { min-height: 42px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); color: var(--ink); width: 100%; font-size: 16px; }
.field.check { grid-template-columns: auto 1fr; align-items: center; gap: 8px; color: var(--ink); font-size: 15px; }
.field.check input { width: 22px; height: 22px; min-height: 0; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin: 6px 0 12px; }
.seg button { border: 0; background: transparent; padding: 8px 14px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--primary); color: #fff; }
@media (prefers-color-scheme: dark) { .seg button[aria-pressed="true"] { color: #0f1416; } }

.rows { display: grid; gap: 10px; margin-bottom: 10px; }
.row { border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: grid; gap: 8px; }
.row-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.row-head strong { font-size: 15px; }

.btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.btn { min-height: 42px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; font-weight: 600; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.small { min-height: 34px; padding: 0 10px; font-weight: 500; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.danger { background: #b3261e; border-color: #b3261e; color: #fff; }
.acct-delete { display: grid; gap: 10px; border-top: 1px solid var(--line); padding-top: 12px; }
.acct-delete p { margin: 0; }
.acct-del-title { margin: 0; font-size: 18px; }
@media (prefers-color-scheme: dark) { .btn.danger-line { border-color: #ff8a80; color: #ff8a80; } }
.link-btn { background: none; border: 0; color: var(--accent-ink); cursor: pointer; padding: 4px; font-size: 14px; }

table.res { width: 100%; border-collapse: collapse; }
table.res td, table.res th { padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; text-align: left; }
table.res th { font-size: 13px; color: var(--muted); font-weight: 600; }
table.res td.q { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 650; }
table.res .note { display: block; font-size: 13px; color: var(--muted); }
table.res tr.deadline td { background: var(--warn-bg); color: var(--warn-ink); }
table.res tr.deadline .note { color: var(--warn-ink); }
table.res input { width: 100%; min-height: 36px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); font-size: 15px; }
table.res input[type="checkbox"] { width: 22px; height: 22px; min-height: 0; }
.total { text-align: right; font-weight: 700; font-size: 18px; margin-top: 10px; }
.src { font-size: 13px; color: var(--muted); }
.sub { font-size: 14px; color: var(--muted); margin: 6px 0 0; }

.grid-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 12px; }
table.cal { border-collapse: collapse; min-width: 100%; font-size: 14px; }
table.cal th, table.cal td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 6px; min-width: 86px; vertical-align: top; }
table.cal th:first-child, table.cal td:first-child { position: sticky; left: 0; background: var(--card); min-width: 96px; font-weight: 650; z-index: 1; }
table.cal th button { border: 0; background: none; cursor: pointer; font-weight: 600; padding: 2px; text-align: left; width: 100%; }
table.cal .held { background: var(--hold); color: var(--muted); }
table.cal .clash { background: var(--clash); }
table.cal .job { display: block; background: var(--chip); border-radius: 6px; padding: 2px 6px; margin-bottom: 3px; }
table.cal .free { color: var(--muted); }

.foot { color: var(--muted); font-size: 14px; padding-top: 18px; padding-bottom: 40px; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 15px; z-index: 10; }

@media print {
  header.top .bar, .tools-nav, .acct, .btns, .foot p:last-child, .toast, .no-print { display: none !important; }
  header.top { background: none; color: #000; }
  .layout { display: block; }
  .card { border: 0; padding: 0; }
  body { background: #fff; color: #000; }
}
