:root {
  color-scheme: light;
  --ink: #0d0e12;
  --surface: #ffffff;
  --page: #f7f4ee;
  --line: #e4ded2;
  --muted: #5b6168;
  --yellow: #f0b843;
  --orange: #ee6236;
  --blue: #186fd5;
  --green: #56be7e;
  --ok: #1f7a4d;
  --ok-bg: #e5f4ea;
  --bad: #b42318;
  --bad-bg: #fde8e4;
  --warn: #8a5300;
  --warn-bg: #fdf1d8;
  --info: #13539e;
  --info-bg: #e5effb;
  --radius: 10px;
  font-family: "Inter", "SF Pro Text", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--page); color: var(--ink); font-size: 15px; line-height: 1.5; }
body.signed-in { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
a { color: var(--ink); }
h1 { font-size: 28px; line-height: 1.15; margin: 0 0 6px; letter-spacing: -0.01em; }
h2 { font-size: 19px; margin: 28px 0 10px; }
h3 { font-size: 16px; margin: 18px 0 8px; }
p { margin: 0 0 10px; }
small, .small { font-size: 13px; }
.muted { color: var(--muted); }
code { font-size: 13px; background: #efebe3; padding: 1px 5px; border-radius: 4px; }

.sidebar { background: var(--ink); color: #f2f2f2; padding: 20px 14px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; }
.sidebar a { color: inherit; text-decoration: none; }
.brand { display: flex; gap: 10px; align-items: center; }
.brand strong { display: block; font-size: 14px; }
.brand small { display: block; color: #b7babf; font-size: 12px; }
.brand-mark { display: inline-grid; grid-template-columns: repeat(2, 9px); gap: 3px; }
.brand-mark i { width: 9px; height: 9px; border-radius: 50%; display: block; }
.brand-mark i:nth-child(1) { background: var(--yellow); }
.brand-mark i:nth-child(2) { background: var(--orange); }
.brand-mark i:nth-child(3) { background: var(--blue); }
.brand-mark i:nth-child(4) { background: var(--green); }
.brand-mark.large { grid-template-columns: repeat(2, 16px); gap: 5px; margin-bottom: 16px; }
.brand-mark.large i { width: 16px; height: 16px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { padding: 8px 10px; border-radius: 8px; color: #d5d7da; display: flex; justify-content: space-between; align-items: center; }
.sidebar nav a:hover { background: #1c1f26; color: #fff; }
.sidebar nav a.active { background: var(--yellow); color: var(--ink); font-weight: 600; }
.sidebar .count { background: var(--orange); color: #fff; border-radius: 999px; font-size: 12px; padding: 0 7px; font-weight: 600; }
.sidebar nav a.active .count { background: var(--ink); }
.sidebar-foot { margin-top: auto; font-size: 12px; color: #b7babf; display: flex; flex-direction: column; gap: 4px; overflow: hidden; }
.sidebar-foot span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot .link { color: #f2f2f2; padding: 0; }

.main { padding: 32px 36px 120px; max-width: 1240px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 0; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.card + .card { margin-top: 14px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 14px 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; display: block; }
.stat strong { display: block; font-size: 26px; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 13px; }
.stat.ok strong { color: var(--ok); }
.stat.bad strong { color: var(--bad); }
.stat.warn strong { color: var(--warn); }

table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; font-size: 14px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid #efeae1; vertical-align: top; }
th { background: #faf8f4; font-weight: 600; font-size: 13px; color: #3b3f45; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody tr:hover { background: #fcfbf8; }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge { background: #ece7dd; color: #3b3f45; }
.badge.complete, .badge.ok, .badge.done, .badge.recognized, .badge.discovered, .badge.resolved, .badge.ended { background: var(--ok-bg); color: var(--ok); }
.badge.listed, .badge.normalized, .badge.discovering, .badge.in_progress { background: var(--info-bg); color: var(--info); }
.badge.missing { background: #ece7dd; color: var(--muted); }
.badge.incomplete, .badge.error, .badge.failed { background: var(--bad-bg); color: var(--bad); }
.badge.needs_review, .badge.review, .badge.warning, .badge.pending, .badge.running, .badge.queued { background: var(--warn-bg); color: var(--warn); }
.badge.info, .badge.not_needed, .badge.neutral { background: var(--info-bg); color: var(--info); }
.badge.error, .badge.warning { padding: 1px 9px; border-radius: 999px; }
.sections { display: grid; gap: 14px; margin-top: 14px; }
.sections > .card { margin: 0; }

button, .button { font: inherit; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 7px 14px; cursor: pointer; text-decoration: none; display: inline-block; }
button:hover, .button:hover { border-color: #c9c1b2; }
button.primary, .button.primary { background: var(--yellow); border-color: var(--yellow); font-weight: 600; }
button.primary:hover, .button.primary:hover { background: #e9ab2c; }
button.danger { color: var(--bad); }
button.link { background: none; border: 0; padding: 0; text-decoration: underline; color: inherit; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
input, select, textarea { font: inherit; border: 1px solid #cfc7b8; border-radius: 8px; padding: 7px 10px; background: #fff; color: var(--ink); }
textarea { width: 100%; resize: vertical; }
label { font-weight: 600; font-size: 14px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row input.link-field { flex: 1 1 320px; min-width: 0; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin: 12px 0 14px; }
.filters label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; font-weight: 600; color: var(--muted); }
.filters select { max-width: 230px; }
.filters label.check { flex-direction: row; align-items: center; gap: 6px; padding-bottom: 9px; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-bottom: 14px; }
.report-grid .card + .card { margin-top: 0; }
.card.report { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.card.report p { flex: 1; margin: 0; }
.download-list { display: flex; gap: 6px; align-items: center; }

.form-table td { vertical-align: middle; }
.form-table input[type="text"] { width: 100%; min-width: 140px; }
.form-table input.wide, .form-table td:first-child input[type="text"] { min-width: 230px; }
.form-table input.amount { width: 110px; min-width: 0; text-align: right; }
.nowrap { white-space: nowrap; }
label.inline { font-weight: 400; display: inline-flex; gap: 4px; align-items: center; margin-right: 10px; }
.add-row { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; margin-bottom: 14px; }
.settings-grid label { display: flex; flex-direction: column; gap: 4px; }
.settings-grid .span-2 { grid-column: span 2; }
.settings-grid .small { font-weight: 400; }
ul.columns { columns: 2; padding-left: 18px; }

.notice { background: var(--info-bg); color: var(--info); padding: 10px 14px; border-radius: 8px; }
.error { background: var(--bad-bg); color: var(--bad); padding: 10px 14px; border-radius: 8px; }
.warning { background: var(--warn-bg); color: var(--warn); padding: 10px 14px; border-radius: 8px; }
.ok-box { background: var(--ok-bg); color: var(--ok); padding: 10px 14px; border-radius: 8px; }

.login { max-width: 380px; margin: 12vh auto 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 32px; }

.progress { height: 10px; background: #ece6da; border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--yellow); width: 0; transition: width 0.2s ease; }
.log { max-height: 260px; overflow-y: auto; font-size: 13px; background: #faf8f4; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
.log p { margin: 2px 0; }

.split { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, 1fr); gap: 16px; align-items: start; }
.viewer-wrap { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 6px; }
.viewer-bar { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.viewer-bar > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer { background: #2b2d33; border-radius: var(--radius); overflow: hidden; height: 76vh; }
.viewer iframe, .viewer img { width: 100%; height: 100%; border: 0; object-fit: contain; background: #2b2d33; display: block; }
.viewer iframe.sheet-frame { background: #fff; }
.viewer-message { color: #f2f2f2; padding: 24px; }
.error-text { color: var(--bad); }
.sheet-body { background: #fff; display: flex; flex-direction: column; height: 100vh; }
.sheet-tabs { display: flex; gap: 2px; padding: 6px 6px 0; background: #f3f0ea; border-bottom: 1px solid var(--line); overflow-x: auto; flex: none; }
.sheet-tabs a { padding: 5px 12px; border-radius: 6px 6px 0 0; text-decoration: none; font-size: 13px; white-space: nowrap; color: var(--muted); }
.sheet-tabs a.active { background: #fff; color: var(--ink); font-weight: 600; border: 1px solid var(--line); border-bottom-color: #fff; margin-bottom: -1px; }
.sheet-scroll { overflow: auto; flex: 1; }
.sheet-grid { border: 0; border-radius: 0; font-size: 12px; width: auto; min-width: 100%; }
.sheet-grid th, .sheet-grid td { border: 1px solid #ebe6dc; padding: 3px 7px; white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.sheet-grid thead th { position: sticky; top: 0; z-index: 1; text-align: center; }
.sheet-grid tbody th { position: sticky; left: 0; background: #faf8f4; color: var(--muted); font-weight: 500; text-align: right; }
.sheet-note { padding: 6px 10px; margin: 0; flex: none; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 6px 0 16px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; text-decoration: none; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.tabs a.active { color: var(--ink); font-weight: 600; box-shadow: inset 0 -3px 0 var(--yellow); }
.tabs .count { background: #ece7dd; color: var(--ink); border-radius: 999px; font-size: 12px; padding: 0 8px; font-weight: 600; }
.tabs a.active .count { background: var(--yellow); }
h2.flush { margin-top: 0; }
.card.focus { border-color: var(--yellow); box-shadow: 0 0 0 3px #f8e3b4; }
label.choice { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
label.choice:hover { border-color: #c9c1b2; }
label.choice:has(input:checked) { border-color: var(--yellow); background: #fffaf0; }
label.choice > input { margin-top: 4px; }
label.choice > span { display: flex; flex-direction: column; gap: 3px; flex: 1; }
label.choice input[type="text"] { margin-top: 4px; width: 100%; }
details.waive, details.inline-edit { margin-top: 10px; }
details.waive summary, details.inline-edit summary { cursor: pointer; color: var(--muted); }
details.inline-edit form { margin-top: 6px; }
.split.even { grid-template-columns: minmax(0, 1fr) minmax(380px, 1fr); }
table.compact th, table.compact td { padding: 5px 8px; }
table.compact th.tick { font-size: 12px; }
th.tick, td.tick { text-align: center; }
table.compact select { padding: 3px 6px; }
td.edited { background: var(--info-bg); box-shadow: inset 0 0 0 2px var(--blue); }
tr.unsure td { background: var(--warn-bg); }

.months { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.months > .card { margin: 0; }
.month-card h3 { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 0 0 10px; }
.month-facts { grid-template-columns: 72px 1fr; gap: 2px 10px; font-size: 13px; margin: 12px 0 8px; }
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.calendar .weekday { font-size: 11px; color: var(--muted); text-align: center; }
.day { height: 26px; border-radius: 4px; font-size: 11px; display: flex; align-items: center; justify-content: center; background: #eee9df; color: #555; text-decoration: none; font-variant-numeric: tabular-nums; }
a.day:hover { box-shadow: inset 0 0 0 1px currentColor; }
.day.present, .day.training, .day.wfh { background: var(--ok-bg); color: var(--ok); }
.day.leave, .day.sick { background: var(--info-bg); color: var(--info); }
.day.absent, .day.blank { background: var(--bad-bg); color: var(--bad); }
.day.off { background: transparent; color: #a9a397; }
.day.none { background: transparent; color: var(--bad); outline: 1px dashed rgba(180, 35, 24, 0.5); outline-offset: -1px; }
.day.unsigned { outline: 2px solid var(--orange); outline-offset: -2px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .day { width: 16px; height: 16px; box-shadow: inset 0 0 0 1px rgba(13, 14, 18, 0.08); }
.legend .day.none, .legend .day.unsigned { box-shadow: none; }

.chat-toggle { position: fixed; right: 22px; bottom: 22px; background: var(--ink); color: #fff; border: 0; border-radius: 999px; padding: 12px 20px; font-weight: 600; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18); z-index: 20; }
.chat-panel { position: fixed; right: 18px; bottom: 18px; width: min(460px, calc(100vw - 36px)); height: min(680px, calc(100vh - 36px)); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2); display: flex; flex-direction: column; z-index: 30; }
.chat-panel[hidden] { display: none; }
.chat-panel header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.chat-panel header div { display: flex; gap: 14px; font-size: 13px; }
.chat-log { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.chat-log .msg { padding: 9px 12px; border-radius: 10px; max-width: 92%; overflow-wrap: anywhere; }
.chat-log .msg.user { background: var(--yellow); align-self: flex-end; white-space: pre-wrap; }
.chat-log .msg.assistant { background: #f3f0ea; align-self: flex-start; }
.chat-log .msg.assistant table { font-size: 12px; margin: 6px 0; }
.chat-log .msg.assistant th, .chat-log .msg.assistant td { padding: 4px 6px; }
.chat-log .msg.assistant p { margin: 0 0 6px; }
.chat-log .msg.assistant ul { margin: 4px 0 6px; padding-left: 18px; }
.chat-log .tool { font-size: 12px; color: var(--muted); margin: 2px 0 6px; }
.chat-log .tool::after { content: "…"; }
.chat-log .tool.pending::after { display: inline-block; width: 1.2em; text-align: left; animation: chat-dots 1.2s steps(4, end) infinite; content: "…"; overflow: hidden; vertical-align: bottom; }
@keyframes chat-dots { from { width: 0; } to { width: 1.2em; } }
.chat-log .msg.assistant .table-wrap { overflow-x: auto; }
.chat-log .msg.assistant table { overflow-wrap: normal; }
.chat-log .msg.assistant td.num { white-space: nowrap; }
.chat-log .msg.assistant code { font-size: 12px; background: rgba(13, 14, 18, 0.06); padding: 0 4px; border-radius: 4px; }
.chat-log .msg.assistant ol { margin: 4px 0 6px; padding-left: 20px; }
.chat-log .chat-file { display: inline-block; margin: 4px 6px 4px 0; padding: 6px 10px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); font-weight: 600; font-size: 13px; }
.chat-log .chat-error { color: var(--bad); font-size: 13px; margin: 4px 0 0; }
@media (prefers-reduced-motion: reduce) { .chat-log .tool.pending::after { animation: none; } }
.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); align-items: flex-end; }
.chat-form textarea { flex: 1; min-height: 44px; max-height: 140px; }

@media (max-width: 900px) {
  body.signed-in { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .split { grid-template-columns: 1fr; }
  .viewer-wrap { position: static; }
  .viewer { height: 60vh; }
  .main { padding: 20px 16px 120px; }
}
