/*
 * 富士興業様の今の日報アプリと同じ見た目（会社カラーの鉄紺 #17184B・Noto Sans JP・18px 基準・角 4px）。
 * Excel 風：灰色の地・白いセル・罫線・条件付き書式の3色（良・悪・注意）・ライトのみ。
 */
:root {
  --radius: 4px;
  color-scheme: light;
  --background: #f3f3f3;
  --foreground: #2b2b2b;
  --card: #ffffff;
  --primary: #17184b;
  --primary-foreground: #ffffff;
  --primary-press: #0e0f33;
  --secondary: #f2f2f2;
  --muted: #f2f2f2;
  --muted-foreground: #5a5a5a;
  --accent: #eceef7;
  --destructive: #9c0006;
  --success: #0a6b2e;
  --warning: #7a5200;
  --info: #2f6fb0;
  --chrome: #fafafa;
  --border: #d9d9d9;
  --input: #8c8c8c;
  --ring: #17184b;
  --grid-strong: #949494;
  --stripe: #f7f7f7;
  --good: #c6efce;
  --good-foreground: #0a6b2e;
  --bad: #ffc7ce;
  --bad-foreground: #9c0006;
  --warn: #ffeb9c;
  --warn-foreground: #7a5200;
  --font-sans: 'Noto Sans JP', system-ui, -apple-system, 'Hiragino Kaku Gothic ProN', 'Yu Gothic', Meiryo, sans-serif;
}

/* 文字サイズ切替（標準18 / 大20 / 特大22px） */
html { font-size: 18px; }
html[data-size='lg'] { font-size: 20px; }
html[data-size='xl'] { font-size: 22px; }

*, *::before, *::after { box-sizing: border-box; border: 0 solid var(--border); }
body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; margin: 0; }
button { cursor: pointer; background: none; }
h1, h2, h3, p { margin: 0; }
a { color: var(--info); }
svg.i { width: 1em; height: 1em; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted-foreground); }
.xs { font-size: 0.75rem; }
.sm { font-size: 0.875rem; }
.lg { font-size: 1.125rem; }
.bold { font-weight: 700; }
.right { text-align: right; }
.row { display: flex; align-items: center; gap: 0.5rem; }
.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 0.75rem; }

/* ---------- Button（button.tsx） ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  height: 2.5rem; padding: 0 1rem; white-space: nowrap;
  font-size: 0.875rem; font-weight: 700;
  border: 1px solid var(--input); border-radius: var(--radius); background: var(--card);
  transition: background 0.15s;
}
.btn:hover { background: var(--accent); }
.btn:focus-visible { outline: 3px solid rgb(23 24 75 / 0.4); outline-offset: 0; }
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn .i { font-size: 1.05rem; }
.btn-primary { background: var(--primary); color: var(--primary-foreground); border-color: var(--primary-press); }
.btn-primary:hover { background: var(--primary-press); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--accent); }
.btn-danger { color: var(--destructive); }
.btn-sm { height: 2.25rem; padding: 0 0.75rem; }
.btn-lg { height: 2.75rem; padding: 0 1.5rem; }
.btn-xl { height: 3.5rem; padding: 0 1.25rem; font-size: 1rem; width: 100%; }
.btn-icon { width: 2.5rem; padding: 0; }

/* ---------- Badge（badge.tsx / status.tsx） ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 0.25rem; width: fit-content;
  padding: 0.125rem 0.5rem; font-size: 0.75rem; font-weight: 700; white-space: nowrap;
  border: 1px solid transparent; border-radius: 1px;
}
.badge .i { font-size: 0.85rem; }
.badge-good { background: var(--good); color: var(--good-foreground); border-color: rgb(10 107 46 / 0.2); }
.badge-bad { background: var(--bad); color: var(--bad-foreground); border-color: rgb(156 0 6 / 0.2); }
.badge-warn { background: var(--warn); color: var(--warn-foreground); border-color: rgb(122 82 0 / 0.2); }
.badge-outline { border-color: var(--border); }
.badge-primary { background: var(--primary); color: #fff; }
.badge-info { background: #e3eefa; color: var(--info); border-color: rgb(47 111 176 / 0.25); }

/* ---------- Section（section.tsx：緑の帯の見出し） ---------- */
.section { background: var(--card); border: 1px solid var(--border); }
.section-head {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  padding: 0.5rem 0.75rem; background: var(--primary); color: var(--primary-foreground);
  border-bottom: 1px solid var(--primary-press);
}
.section-head h2 { font-size: 0.875rem; font-weight: 700; letter-spacing: 0.025em; display: flex; align-items: center; gap: 0.4rem; }
.section-body { padding: 1rem; }
.section-body.flush { padding: 0; }

/* ---------- PageHeader ---------- */
.page-header {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem;
  margin-bottom: 0.75rem; padding: 0.5rem 0.75rem;
  background: var(--muted); border: 1px solid var(--border);
}
.page-header h1 { font-size: 1.25rem; font-weight: 700; }
.page-header p { margin-top: 0.125rem; font-size: 0.875rem; color: var(--muted-foreground); }

/* ---------- FigureStrip（figure.tsx） ---------- */
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); }
.figure { background: var(--card); padding: 0.75rem 1rem; }
.figure .label { font-size: 0.75rem; color: var(--muted-foreground); }
.figure .value { font-size: 1.5rem; font-weight: 700; line-height: 1; margin-top: 0.35rem; font-variant-numeric: tabular-nums; }
.figure .unit { font-size: 0.875rem; color: var(--muted-foreground); font-weight: 400; margin-left: 0.15rem; }
.figure.is-bad .value { color: var(--destructive); }
.figure.is-warn .value { color: var(--warning); }

/* ---------- FieldList（field-list.tsx） ---------- */
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); font-size: 0.875rem; }
.fields > div { background: var(--card); padding: 0.5rem 0.75rem; }
.fields dt { font-size: 0.75rem; color: var(--muted-foreground); }
.fields dd { margin: 0.125rem 0 0; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- RuledTable（ruled-table.tsx） ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--grid-strong); background: var(--card); }
table.ruled { width: 100%; border-collapse: collapse; font-size: 0.9rem; line-height: 1.25; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ruled th {
  background: var(--muted); font-weight: 700; text-align: left;
  border: 1px solid var(--border); border-bottom-color: var(--grid-strong);
  padding: 0.3rem 0.5rem; position: sticky; top: 0; z-index: 1;
}
.ruled td { border: 1px solid var(--border); padding: 0.3rem 0.5rem; }
.ruled tbody tr:nth-child(even) { background: var(--stripe); }
.ruled tbody tr:hover { background: var(--accent); }
.ruled tr.clickable { cursor: pointer; }
.ruled td.n, .ruled th.n { text-align: right; }
.ruled tr.group td { background: var(--secondary); font-weight: 700; }
.ruled tr.total td { background: var(--card); font-weight: 700; border-top: 2px solid var(--grid-strong); }
.ruled tr.grand td { background: var(--accent); font-weight: 700; border-top: 2px solid var(--primary); }
.ruled td.cf-good { background: var(--good); color: var(--good-foreground); }
.ruled td.cf-bad { background: var(--bad); color: var(--bad-foreground); font-weight: 700; }
.ruled td.cf-warn { background: var(--warn); color: var(--warn-foreground); }
.ruled .sub { display: block; font-size: 0.7rem; color: var(--muted-foreground); }

/* ---------- Bar（Bar.tsx） ---------- */
.bar { height: 0.55rem; background: var(--muted); border: 1px solid var(--border); min-width: 5rem; }
.bar > span { display: block; height: 100%; background: var(--primary); }
.bar.is-warn > span { background: #d9a300; }
.bar.is-bad > span { background: var(--destructive); }

/* ---------- シートタブ（ProjectLayout：Excel のシート見出し風） ---------- */
.sheet-tabs { display: flex; gap: 1px; overflow-x: auto; border-bottom: 1px solid var(--grid-strong); margin-bottom: 1rem; }
.sheet-tabs button {
  margin-bottom: -1px; padding: 0.5rem 0.75rem; font-size: 0.875rem; white-space: nowrap;
  border: 1px solid var(--border); border-bottom: 0; background: var(--muted); color: var(--muted-foreground);
}
.sheet-tabs button:hover { background: var(--accent); }
.sheet-tabs button[aria-selected='true'] { background: var(--primary); color: #fff; font-weight: 700; }

/* ---------- 下線式タブ（status.tsx） ---------- */
.line-tabs { display: flex; flex-wrap: wrap; gap: 0.25rem; border-bottom: 1px solid var(--border); margin-bottom: 0.75rem; }
.line-tabs button { height: 2.5rem; padding: 0 0.875rem; font-size: 0.875rem; font-weight: 700; color: var(--muted-foreground); border-bottom: 2px solid transparent; }
.line-tabs button[aria-selected='true'] { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- Input / Select ---------- */
.input, .select {
  height: 2.5rem; width: 100%; padding: 0 0.6rem; font-size: 0.9rem;
  border: 1px solid var(--input); border-radius: var(--radius); background: var(--card);
}
.input:focus-visible, .select:focus-visible { outline: 2px solid rgb(23 24 75 / 0.35); border-color: var(--ring); background: rgb(236 238 247 / 0.6); }
.label { display: block; font-size: 0.8rem; font-weight: 700; margin-bottom: 0.25rem; }

/* ---------- Modal（modal.tsx） ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgb(0 0 0 / 0.5); display: grid; place-items: center; padding: 1rem; }
.modal {
  width: min(92vw, 34rem); max-height: 90vh; overflow: auto;
  background: var(--background); border: 1px solid var(--border); border-radius: 2px;
  padding: 1rem; box-shadow: 0 10px 30px rgb(0 0 0 / 0.25);
}
.modal > * + * { margin-top: 0.75rem; }
.modal h3 { font-size: 1rem; font-weight: 700; }
.modal-foot { display: flex; justify-content: flex-end; gap: 0.5rem; padding-top: 0.25rem; }

/* ---------- 警告の帯・トースト ---------- */
.notice { padding: 0.5rem 0.75rem; font-size: 0.875rem; border: 1px solid; display: flex; gap: 0.5rem; align-items: flex-start; }
.notice .i { margin-top: 0.2em; }
.notice-warn { background: var(--warn); color: var(--warn-foreground); border-color: rgb(122 82 0 / 0.2); }
.notice-good { background: var(--good); color: var(--good-foreground); border-color: rgb(10 107 46 / 0.2); }
.notice-info { background: #e3eefa; color: #1f4f80; border-color: rgb(47 111 176 / 0.25); }
.notice-bad { background: var(--bad); color: var(--bad-foreground); border-color: rgb(156 0 6 / 0.2); }

.toasts { position: fixed; top: 0.75rem; left: 50%; transform: translateX(-50%); z-index: 60; display: grid; gap: 0.5rem; pointer-events: none; }
.toast {
  min-width: 16rem; max-width: 90vw; padding: 0.6rem 0.9rem; font-size: 0.9rem; font-weight: 700;
  background: var(--card); border: 1px solid var(--grid-strong); border-left: 4px solid var(--primary);
  box-shadow: 0 6px 18px rgb(0 0 0 / 0.15); display: flex; gap: 0.5rem; align-items: center;
  animation: toast-in 0.2s ease-out;
}
.toast.is-warn { border-left-color: #d9a300; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } }

/* ---------- 印刷（A4 横） ---------- */
@media print {
  @page { size: A4 landscape; margin: 8mm; }
  html { font-size: 10px; }
  * { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .no-print { display: none !important; }
}
