:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --ink: #1f2328;
  --ink-2: #57606a;
  --ink-3: #8b949e;
  --line: #e3e1da;
  --accent: #2f6f5e;
  --accent-soft: #dcebe5;
  --warn: #9a4b00;
  --warn-soft: #fbe7cf;
  --track: #ecebe5;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --surface: #1d2024;
    --ink: #e6e6e3;
    --ink-2: #a5abb3;
    --ink-3: #757c85;
    --line: #2d3137;
    --accent: #6fc2a8;
    --accent-soft: #1f3a32;
    --warn: #f0a85b;
    --warn-soft: #3d2a14;
    --track: #2a2e33;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.top h1 { margin: 0; font-size: 18px; letter-spacing: 0.04em; }
.who { display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-size: 13px; min-width: 0; }
#who-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { max-width: 880px; margin: 0 auto; padding: 16px; }

h2 { font-size: 16px; margin: 24px 0 10px; }
h3 { font-size: 14px; margin: 22px 0 8px; color: var(--ink-2); }
.sub { color: var(--ink-3); font-size: 12px; font-weight: normal; }
.note, .empty { color: var(--ink-3); font-size: 13px; }

button {
  font: inherit;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--surface);
  border-radius: 6px;
  padding: 8px 16px;
  cursor: pointer;
}
button.quiet { background: transparent; color: var(--ink-2); border-color: var(--line); padding: 4px 10px; font-size: 13px; }
button:disabled { opacity: 0.4; cursor: default; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 24px 16px; }
.center { text-align: center; }

.message {
  background: var(--warn-soft);
  color: var(--warn);
  border-radius: 6px;
  padding: 10px 12px;
  margin: 0 0 12px;
  font-size: 14px;
}

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs button {
  background: transparent;
  color: var(--ink-2);
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 8px 14px;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
th { color: var(--ink-3); font-size: 12px; font-weight: 600; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.cancelled td { color: var(--ink-3); text-decoration: line-through; }
tr.cancelled td .badge { text-decoration: none; }

.badge { display: inline-block; font-size: 11px; line-height: 1.6; padding: 0 7px; border-radius: 999px; white-space: nowrap; vertical-align: 1px; }
.badge.ok { background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.badge.muted { background: var(--track); color: var(--ink-2); }

.meter { height: 6px; background: var(--track); border-radius: 3px; margin-top: 4px; min-width: 120px; }
.meter-fill { height: 100%; background: var(--accent); border-radius: 3px; }
.meter.low .meter-fill { background: var(--warn); }
.meter-text { font-variant-numeric: tabular-nums; white-space: nowrap; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.tile-label { color: var(--ink-3); font-size: 12px; }
.tile-value { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }

.month-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 16px 0 12px; }
.month-bar h2 { margin: 0; }

.breakdown { display: grid; gap: 6px; }
.bar-row { display: grid; grid-template-columns: 6.5em 1fr auto; align-items: center; gap: 10px; font-size: 13px; }
.bar-label { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 12px; }
.bar { height: 100%; min-width: 2px; background: var(--accent); border-radius: 0 4px 4px 0; }
.bar-value { font-variant-numeric: tabular-nums; white-space: nowrap; }

@media (max-width: 520px) {
  .top h1 { font-size: 16px; }
  th, td { padding: 8px; }
  .tiles { grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 8px; }
  .tile { padding: 10px; }
  .tile-value { font-size: 16px; }
}

/* ---- 記録・訂正（AWS-23） ---- */

.message.ok { background: var(--accent-soft); color: var(--accent); }

.readonly .write-only,
.readonly .op-col { display: none; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 12px; }
th.op-col, td.op-col { width: 1%; white-space: nowrap; text-align: right; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

dialog {
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px 18px 16px;
  background: var(--surface);
  color: var(--ink);
}
dialog::backdrop { background: rgb(0 0 0 / 0.45); }
dialog h2 { margin: 0 0 6px; }
dialog .message { margin: 12px 0 0; }

.fields { display: grid; gap: 12px; margin-top: 12px; }
.field { display: grid; gap: 4px; }
.field.check { display: flex; align-items: center; gap: 8px; }
.field-label { font-size: 13px; color: var(--ink-2); }
.field-hint { font-size: 12px; color: var(--ink-3); }
.field input:not([type="checkbox"]),
.field select,
.field textarea {
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
  width: 100%;
}
.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.field input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }

.choices { display: grid; gap: 8px; }
button.choice {
  display: grid;
  gap: 2px;
  text-align: left;
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
button.choice:hover:not(:disabled) { border-color: var(--accent); }

.confirm-lead { margin: 12px 0 6px; font-size: 14px; }
.summary { margin: 0; padding: 10px 12px 10px 28px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; }
.summary li + li { margin-top: 4px; }

.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.dialog-actions button.quiet { padding: 8px 14px; font-size: 14px; }
