@import "tailwindcss";

:root {
  --ink: #17233c;
  --muted: #667085;
  --line: #d9e0ea;
  --paper: #ffffff;
  --canvas: #f3f6fa;
  --blue: #2157d8;
  --blue-dark: #163b94;
  --cyan: #17a4c4;
  --green: #087f5b;
  --red: #c83b3b;
  --amber: #c26a12;
}

* { box-sizing: border-box; }

html { background: var(--canvas); }

body {
  margin: 0;
  background:
    radial-gradient(circle at 10% -10%, rgba(33, 87, 216, 0.11), transparent 28rem),
    var(--canvas);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
  font-feature-settings: "palt";
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; padding-bottom: 64px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 22px clamp(20px, 5vw, 72px); background: rgba(255,255,255,.94);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(12px);
}
.brand-block, .top-actions, .hero-actions, .snapshot-head, .panel-heading, .report-header { display: flex; align-items: center; }
.brand-block { gap: 14px; }
.brand-mark {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 13px;
  background: linear-gradient(145deg, var(--blue), var(--blue-dark)); color: white; font-weight: 800;
  letter-spacing: -.03em; box-shadow: 0 8px 20px rgba(33,87,216,.25);
}
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(18px, 2vw, 24px); letter-spacing: -.04em; }
.eyebrow { margin-bottom: 5px; color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.top-actions { gap: 10px; }
.button { border: 0; border-radius: 10px; padding: 11px 16px; font-weight: 750; transition: .18s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: .65; transform: none; }
.button.primary { background: var(--blue); color: white; box-shadow: 0 7px 18px rgba(33,87,216,.22); }
.button.ghost { background: #edf1f7; color: #344054; }
.button.alert { background: #fff1eb; color: #a23b16; border: 1px solid #ffd0bc; }
.button.full { width: 100%; }
.text-button { background: none; border: 0; color: var(--blue); font-weight: 750; padding: 10px 0; }

.notice {
  display: flex; align-items: center; gap: 10px; max-width: 1440px; margin: 18px auto 0;
  padding: 11px 16px; color: #344054; font-size: 13px;
}
.notice-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px rgba(8,127,91,.1); }
.intake-panel { width: min(100% - 40px, 1296px); margin: 14px auto 24px; padding: 26px; border: 1px solid #cbd8e7; border-radius: 18px; background: white; box-shadow: 0 10px 28px rgba(23,35,60,.06); }
.intake-panel.loaded { border-color: #a7d9c7; background: linear-gradient(135deg,#ffffff,#f4fbf8); }
.intake-heading { display:flex; align-items:flex-start; justify-content:space-between; gap:24px; }
.intake-heading h2 { margin-bottom:8px; font-size:24px; letter-spacing:-.04em; }
.intake-heading p:last-child { max-width:760px; margin-bottom:0; color:var(--muted); line-height:1.75; }
.safe-badge { flex:0 0 auto; padding:8px 12px; border-radius:999px; background:#eef7f4; color:var(--green); font-size:11px; font-weight:800; }
.source-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:10px; margin-top:20px; }
.source-grid article { position:relative; display:flex; align-items:flex-start; gap:10px; min-width:0; padding:14px; border:1px solid #e1e8f0; border-radius:11px; background:#f8fafc; }
.source-grid article > span { display:grid; place-items:center; flex:0 0 38px; height:32px; border-radius:6px; background:#dce9f5; color:var(--blue-dark); font-size:9px; font-weight:900; }
.source-grid article div { min-width:0; }
.source-grid strong { display:block; margin-bottom:4px; font-size:13px; }
.source-grid p { overflow:hidden; margin:0 0 5px; color:#496078; font-size:10px; text-overflow:ellipsis; white-space:nowrap; }
.source-grid small { color:var(--muted); font-size:9px; line-height:1.5; }
.source-grid article > b { position:absolute; top:8px; right:8px; padding:3px 6px; border-radius:5px; background:#e4f5ed; color:var(--green); font-size:8px; }
.intake-actions { display:flex; flex-wrap:wrap; gap:10px; margin-top:18px; }
.intake-success { margin:14px 0 0; color:var(--green); font-size:12px; font-weight:700; }
.view-tabs { max-width: 1440px; margin: 8px auto 0; padding: 0 clamp(20px, 5vw, 72px); display: flex; gap: 4px; }
.view-tabs button { border: 0; border-bottom: 3px solid transparent; background: none; padding: 13px 15px; color: var(--muted); font-weight: 700; }
.view-tabs button.active { color: var(--blue); border-color: var(--blue); }
.view-tabs span { display: inline-grid; place-items: center; min-width: 22px; height: 22px; margin-left: 4px; border-radius: 11px; background: #e8edf5; font-size: 11px; }

.hero-grid, .metric-grid, .content-grid, .changes-panel, .report-page {
  width: min(100% - 40px, 1296px); margin-inline: auto;
}
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, .7fr); gap: 24px; margin-top: 28px; }
.hero-copy {
  min-height: 300px; padding: clamp(28px, 5vw, 54px); border-radius: 22px; color: white; overflow: hidden;
  background: linear-gradient(120deg, #152c64 0%, #2157d8 58%, #1687b6 100%); position: relative;
  box-shadow: 0 20px 45px rgba(23,35,60,.18);
}
.hero-copy::after { content: ""; position: absolute; width: 320px; height: 320px; border: 1px solid rgba(255,255,255,.17); border-radius: 50%; right: -90px; top: -120px; box-shadow: 0 0 0 55px rgba(255,255,255,.04), 0 0 0 110px rgba(255,255,255,.03); }
.hero-copy .eyebrow { color: #b9dcff; }
.hero-copy h2 { position: relative; z-index: 1; margin: 10px 0 6px; font-size: clamp(40px, 7vw, 72px); line-height: 1; letter-spacing: -.065em; }
.hero-copy h2 span { display:block; margin-bottom:10px; font-size:13px; letter-spacing:.04em; }
.hero-delta { position: relative; z-index: 1; margin-bottom: 24px; font-size: 15px; font-weight: 800; }
.hero-copy .negative { color: #ffd1c9; }
.hero-description { position: relative; z-index: 1; max-width: 640px; margin-bottom: 24px; color: #e8f0ff; line-height: 1.8; }
.hero-actions { position: relative; z-index: 1; gap: 18px; }
.hero-actions .text-button { color: white; }
.snapshot-card { display: flex; flex-direction: column; justify-content: center; padding: 30px; background: var(--paper); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 16px 38px rgba(23,35,60,.08); }
.snapshot-head { justify-content: space-between; gap: 12px; color: var(--muted); font-weight: 750; }
.locked { padding: 5px 8px; border-radius: 6px; background: #e7f6f0; color: var(--green); font-size: 11px; }
.snapshot-card > strong { margin: 24px 0 6px; font-size: clamp(30px, 4vw, 46px); letter-spacing: -.05em; }
.snapshot-card > p { color: var(--muted); font-size: 12px; }
.snapshot-diff { display: flex; justify-content: space-between; align-items: center; padding-top: 20px; border-top: 1px solid var(--line); font-size: 13px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 18px; }
.metric-card { padding: 20px; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 7px 18px rgba(23,35,60,.04); }
.metric-card p { margin-bottom: 12px; color: var(--muted); font-size: 12px; font-weight: 700; }
.metric-card strong { display: block; margin-bottom: 6px; font-size: 25px; letter-spacing: -.04em; }
.metric-card small { color: var(--muted); }
.warning-card { background: #fffaf3; border-color: #f3d9b7; }
.progress, .bar { overflow: hidden; background: #e9eef5; border-radius: 20px; }
.progress { height: 7px; margin-top: 16px; }
.progress span, .bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--cyan)); border-radius: inherit; }

.content-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, .65fr); gap: 18px; margin-top: 18px; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 9px 24px rgba(23,35,60,.05); }
.unit-panel, .update-panel, .changes-panel { padding: 24px; }
.panel-heading { justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.panel-heading h2, .panel-heading h3 { margin-bottom: 0; letter-spacing: -.035em; }
.panel-heading > div > p:last-child { margin: 8px 0 0; color: var(--muted); }
.unit-label { color: var(--muted); font-size: 11px; }
.unit-list { display: grid; gap: 10px; }
.unit-row { display: grid; grid-template-columns: minmax(190px, 1.2fr) minmax(190px, 1fr); gap: 10px 18px; padding: 16px; border: 1px solid #e5eaf1; border-radius: 12px; }
.unit-row.changed { border-color: #efb08d; background: #fff9f5; }
.unit-main, .unit-values, .unit-kpi { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.unit-main div { display: flex; flex-direction: column; gap: 4px; }
.unit-main span, .unit-values span, .unit-kpi span { color: var(--muted); font-size: 11px; }
.unit-main em { color: var(--red); font-size: 10px; font-style: normal; font-weight: 800; }
.unit-values b { font-size: 22px; }
.unit-values span:last-child { min-width: 52px; text-align: right; font-weight: 800; }
.bar { height: 6px; }
.bar-label { display:flex; justify-content:space-between; color:var(--muted); font-size:9px; }
.unit-kpi { color: #344054; font-size: 12px; }
.update-guide { margin:-4px 0 18px; padding:13px 14px; border-left:4px solid var(--blue); background:#f2f6fd; color:#496078; font-size:11px; line-height:1.7; }
.update-panel label { display: grid; gap: 7px; margin-bottom: 15px; color: #344054; font-size: 12px; font-weight: 750; }
.update-panel input, .update-panel select, .update-panel textarea { width: 100%; border: 1px solid #cfd7e4; border-radius: 9px; background: white; padding: 11px 12px; color: var(--ink); outline: none; }
.update-panel input:focus, .update-panel select:focus, .update-panel textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(33,87,216,.1); }
.required { color: var(--red); font-size: 10px; }
.helper { margin: 12px 0 0; color: var(--muted); font-size: 11px; line-height: 1.6; }

.changes-panel { margin-top: 28px; }
.empty-state { padding: 70px 20px; text-align: center; background: #f8fafc; border: 1px dashed #cfd7e4; border-radius: 14px; }
.empty-state strong { display: block; margin-bottom: 8px; font-size: 18px; }
.empty-state p { margin: 0; color: var(--muted); }
.change-list { display: grid; gap: 12px; }
.change-item { display: grid; grid-template-columns: 130px 1fr; gap: 20px; padding: 20px; border: 1px solid #f0c9b8; border-left: 4px solid var(--red); border-radius: 12px; }
.change-time { color: var(--muted); font-size: 12px; }
.change-time span { display: block; width: fit-content; margin-top: 8px; padding: 4px 7px; border-radius: 5px; background: #fff0ea; color: var(--red); font-weight: 800; }
.change-body h3 { margin-bottom: 8px; }
.change-body p { margin: 12px 0 0; color: #475467; line-height: 1.7; }
.before-after { display: flex; align-items: center; gap: 13px; }
.before-after span { color: var(--muted); text-decoration: line-through; }
.before-after strong { font-size: 22px; }
.before-after em { margin-left: auto; font-style: normal; font-weight: 800; }

.report-page { margin-top: 28px; padding: 42px; background: white; border: 1px solid var(--line); box-shadow: 0 15px 45px rgba(23,35,60,.08); }
.report-header { justify-content: space-between; gap: 24px; padding-bottom: 24px; border-bottom: 3px solid var(--ink); }
.report-header h2 { margin-bottom: 7px; font-size: 28px; }
.report-header p:last-child { margin-bottom: 0; color: var(--muted); font-size: 12px; }
.report-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 24px 0; }
.report-summary div { padding: 17px; background: #f5f7fb; border-radius: 9px; }
.report-summary span { display: block; margin-bottom: 8px; color: var(--muted); font-size: 11px; }
.report-summary strong { font-size: 19px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { padding: 12px 10px; background: #eef2f8; color: #475467; text-align: right; }
th:first-child, td:first-child { text-align: left; }
td { padding: 14px 10px; border-bottom: 1px solid var(--line); text-align: right; }
.report-comment { margin-top: 28px; padding: 22px; border-left: 4px solid var(--blue); background: #f4f7fd; }
.report-comment h3 { margin-bottom: 14px; }
.report-comment p { margin-bottom: 8px; color: #344054; line-height: 1.6; }
.report-footer { margin-top: 34px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; text-align: center; }
.positive { color: var(--green) !important; }
.negative { color: var(--red) !important; }

@media (max-width: 920px) {
  .topbar { align-items: flex-start; }
  .top-actions { flex-wrap: wrap; justify-content: flex-end; }
  .hero-grid, .content-grid { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .unit-row { grid-template-columns: 1fr; }
  .report-summary { grid-template-columns: repeat(2, 1fr); }
  .source-grid { grid-template-columns: repeat(2,1fr); }
}

@media (max-width: 620px) {
  .topbar { position: static; flex-direction: column; padding: 18px 20px; }
  .top-actions { width: 100%; }
  .top-actions .button { flex: 1; }
  .view-tabs { overflow-x: auto; }
  .view-tabs button { flex: 0 0 auto; }
  .hero-grid, .metric-grid, .content-grid, .changes-panel, .report-page, .intake-panel { width: min(100% - 24px, 1296px); }
  .intake-panel { padding:20px 16px; }
  .intake-heading { flex-direction:column; }
  .source-grid { grid-template-columns:1fr; }
  .hero-copy { min-height: auto; padding: 30px 22px; }
  .hero-copy h2 { font-size: 44px; }
  .hero-actions { align-items: flex-start; flex-direction: column; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .metric-card { padding: 15px; }
  .metric-card strong { font-size: 19px; }
  .change-item { grid-template-columns: 1fr; }
  .before-after { flex-wrap: wrap; }
  .before-after em { margin-left: 0; width: 100%; }
  .report-page { padding: 22px 16px; overflow-x: auto; }
  .report-header { align-items: flex-start; flex-direction: column; }
  .report-summary { grid-template-columns: 1fr 1fr; }
  table { min-width: 700px; }
}

@media print {
  body { background: white; }
  .no-print { display: none !important; }
  .app-shell { padding: 0; }
  .report-page { width: 100%; margin: 0; padding: 12mm; border: 0; box-shadow: none; }
  .report-summary { break-inside: avoid; }
  table { font-size: 10px; }
}
