/* =========================================================
   重説作成工房 — style.css（Claudeオレンジテーマ）
   画面UI（オレンジ×温白のSaaSダッシュボード）＋ A4書面・印刷基盤
   ※ A4書面（.sheet / .f-*）は実務書式に寄せたモノトーンを維持
   ========================================================= */

:root {
  --ink: #241a13;
  --ink-soft: #77685b;
  --bg: #faf5ef;
  --panel: #ffffff;
  --ora: #ea5a0b;
  --ora-deep: #c2410c;
  --ora-dark: #7c2d12;
  --amber: #f59e0b;
  --peach: #fff0e3;
  --peach-2: #ffe3cd;
  --line: #efe1d3;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --err: #b91c1c;
  --err-bg: #fee2e2;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(124, 45, 18, .08);
  --shadow-lg: 0 18px 46px rgba(124, 45, 18, .14);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Noto Sans JP', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', sans-serif;
  background:
    radial-gradient(900px 420px at 88% -10%, rgba(234, 90, 11, .07), transparent 60%),
    radial-gradient(700px 380px at -10% 8%, rgba(245, 158, 11, .06), transparent 55%),
    var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.65;
  font-feature-settings: 'palt';
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 13px; color: var(--ink); }

/* ---------- アプリシェル ---------- */
.shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}
.side {
  background:
    radial-gradient(420px 260px at 20% -6%, rgba(234, 90, 11, .35), transparent 60%),
    linear-gradient(168deg, #33190c 0%, #4a1f0c 52%, #6b2710 100%);
  color: #fff;
  padding: 24px 16px;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
}
.brand { padding: 0 10px 20px; }
.brand .logo {
  display: flex; align-items: center; gap: 10px;
  font-weight: 900; font-size: 17.5px; letter-spacing: .02em;
}
.brand .logo .mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--amber), var(--ora) 70%);
  display: grid; place-items: center;
  font-size: 16px;
  box-shadow: 0 6px 14px rgba(234, 90, 11, .45), inset 0 -2px 0 rgba(0, 0, 0, .18);
}
.brand .tag { font-size: 10.5px; opacity: .72; margin-top: 6px; letter-spacing: .1em; }
.side nav { display: flex; flex-direction: column; gap: 3px; }
.side nav a {
  display: flex; align-items: center; gap: 10px;
  color: #fff; text-decoration: none;
  padding: 11px 13px; border-radius: 11px;
  font-size: 13.5px; font-weight: 700;
  opacity: .72; transition: .16s;
  position: relative;
}
.side nav a:hover { opacity: 1; background: rgba(255, 255, 255, .07); transform: translateX(2px); }
.side nav a.on {
  opacity: 1;
  background: linear-gradient(120deg, rgba(234, 90, 11, .95), rgba(194, 65, 12, .9));
  box-shadow: 0 8px 18px rgba(234, 90, 11, .35);
}
.side .foot { margin-top: auto; font-size: 10px; opacity: .62; padding: 0 10px; line-height: 1.7; }

.main { padding: 30px 34px 70px; min-width: 0; }
.topbar {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; margin-bottom: 22px;
}
.topbar h1 {
  font-size: 23px; font-weight: 900; letter-spacing: .01em;
  display: flex; align-items: center; gap: 10px;
}
.topbar h1::before {
  content: '';
  width: 6px; height: 24px; border-radius: 4px;
  background: linear-gradient(180deg, var(--amber), var(--ora-deep));
}
.topbar .sub { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.topbar .co {
  font-size: 12px; font-weight: 700; color: var(--ora-dark);
  background: linear-gradient(120deg, var(--peach), #fff);
  border: 1px solid var(--peach-2);
  padding: 8px 15px; border-radius: 999px;
  box-shadow: var(--shadow);
}

/* ---------- ページ切替 ---------- */
.page { display: none; }
.page.on { display: block; animation: fadein .22s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

/* ---------- 汎用パーツ ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px;
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 13px;
  position: relative; overflow: hidden;
  transition: .18s;
}
.card::after {
  content: '';
  position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, var(--amber), var(--ora-deep));
  opacity: 0; transition: .18s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.card:hover::after { opacity: 1; }
.card .ic {
  width: 46px; height: 46px; border-radius: 13px; flex-shrink: 0;
  background: linear-gradient(140deg, var(--peach), var(--peach-2));
  display: grid; place-items: center; font-size: 21px;
}
.card .k { font-size: 11.5px; color: var(--ink-soft); font-weight: 700; }
.card .v { font-size: 27px; font-weight: 900; line-height: 1.2; font-variant-numeric: tabular-nums; }
.card .v small { font-size: 12px; font-weight: 700; color: var(--ink-soft); margin-left: 3px; }

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 22px; margin-top: 18px;
}
.panel > h2 {
  font-size: 14.5px; font-weight: 900; margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.panel > h2::before {
  content: '';
  width: 5px; height: 15px; border-radius: 3px;
  background: linear-gradient(180deg, var(--amber), var(--ora-deep));
}
.panel > h2 .spacer { flex: 1; }

.btn {
  border: 1.5px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 10px; padding: 8px 15px; font-size: 12.5px; font-weight: 800;
  transition: .16s;
}
.btn:hover { border-color: var(--ora); color: var(--ora-deep); transform: translateY(-1px); }
.btn.pri {
  background: linear-gradient(135deg, var(--ora), var(--ora-deep));
  border-color: transparent; color: #fff;
  box-shadow: 0 8px 18px rgba(234, 90, 11, .32);
}
.btn.pri:hover { color: #fff; filter: brightness(1.08); box-shadow: 0 10px 22px rgba(234, 90, 11, .42); }
.btn.ai {
  background: linear-gradient(120deg, #f59e0b, #ea5a0b 55%, #c026d3 130%);
  border: none; color: #fff;
  box-shadow: 0 8px 18px rgba(234, 90, 11, .3);
}
.btn.ai:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 11px; font-size: 11.5px; border-radius: 8px; }
.btn.danger:hover { border-color: var(--err); color: var(--err); }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 800;
  padding: 2px 10px; border-radius: 999px;
  background: var(--peach); color: var(--ora-dark);
}
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.err  { background: var(--err-bg);  color: var(--err); }
.chip.ok   { background: var(--ok-bg);   color: var(--ok); }
.chip.mut  { background: #f3ece4; color: var(--ink-soft); }

/* ---------- テーブル（画面用） ---------- */
.tblwrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th {
  text-align: left; font-size: 10.5px; letter-spacing: .04em; color: var(--ink-soft);
  border-bottom: 2px solid var(--peach-2); padding: 8px 10px; white-space: nowrap;
}
.tbl td { border-bottom: 1px solid var(--line); padding: 10px; vertical-align: top; }
.tbl tr:hover td { background: #fdf7f0; }
.tbl td .nm { font-weight: 800; }
.tbl td .mut { color: var(--ink-soft); font-size: 11px; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.f-right { text-align: right !important; }

/* ---------- アラート ---------- */
.alerts { display: flex; flex-direction: column; gap: 8px; }
.alert {
  display: flex; gap: 10px; align-items: flex-start;
  border-radius: 12px; padding: 11px 15px; font-size: 12.5px;
  border: 1px solid transparent;
  box-shadow: 0 2px 8px rgba(124, 45, 18, .05);
}
.alert.err  { background: var(--err-bg);  border-color: #fecaca; color: #7f1d1d; }
.alert.warn { background: var(--warn-bg); border-color: #fde68a; color: #78350f; }
.alert.ok   { background: var(--ok-bg);   border-color: #bbf7d0; color: #14532d; }
.alert b { font-weight: 800; }
.alert .ic { flex-shrink: 0; }

/* ---------- ドロワー ---------- */
.drawer-veil {
  position: fixed; inset: 0; background: rgba(51, 25, 12, .45);
  backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none; transition: .2s; z-index: 40;
}
.drawer {
  position: fixed; top: 0; right: -580px; width: min(560px, 94vw); height: 100vh;
  background: var(--panel); z-index: 41; transition: right .24s cubic-bezier(.2, .8, .3, 1);
  box-shadow: -18px 0 50px rgba(70, 30, 10, .22);
  display: flex; flex-direction: column;
}
body.drawer-open .drawer-veil { opacity: 1; pointer-events: auto; }
body.drawer-open .drawer { right: 0; }
.drawer .dhead {
  padding: 17px 24px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(120deg, var(--peach), #fff 65%);
}
.drawer .dhead h3 { font-size: 15px; font-weight: 900; flex: 1; }
.drawer .dbody { padding: 20px 24px; overflow-y: auto; flex: 1; }
.drawer .dfoot {
  padding: 14px 24px; border-top: 1px solid var(--line);
  display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap;
}
.fgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px 12px; }
.fgrid .wide { grid-column: 1 / -1; }
.field label { display: block; font-size: 11px; font-weight: 800; color: var(--ink-soft); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: 9px;
  padding: 8px 11px; background: #fff; transition: .14s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--ora);
  box-shadow: 0 0 0 3px rgba(234, 90, 11, .16);
}
.fsec {
  grid-column: 1 / -1;
  font-size: 11.5px; font-weight: 900; color: var(--ora-dark);
  border-bottom: 2px solid var(--peach-2);
  padding: 10px 0 5px; margin-top: 4px;
  letter-spacing: .04em;
}

/* ---------- AIデモ演出 ---------- */
.ai-box {
  border: 1.5px dashed #f0b285; border-radius: 13px;
  background: linear-gradient(120deg, #fff7ef, #fff); padding: 13px 15px; font-size: 12px; margin-bottom: 14px;
}
.ai-box .ai-log { font-size: 12px; line-height: 1.9; min-height: 20px; white-space: pre-wrap; }
.ai-box .cursor { display: inline-block; width: 7px; height: 13px; background: var(--ora); vertical-align: -2px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.ai-note { font-size: 10.5px; color: var(--ink-soft); margin-top: 6px; }

/* ---------- 特約ライブラリピッカー ---------- */
.tokupick { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.tokupick .tp {
  display: flex; gap: 10px; align-items: flex-start;
  border: 1.5px solid var(--line); border-radius: 13px; padding: 11px 13px;
  background: #fff; cursor: pointer; transition: .14s;
}
.tokupick .tp:hover { border-color: var(--ora); transform: translateY(-1px); box-shadow: var(--shadow); }
.tokupick .tp.sel {
  border-color: var(--ora);
  background: linear-gradient(130deg, var(--peach), #fff 70%);
  box-shadow: 0 6px 16px rgba(234, 90, 11, .16);
}
.tokupick .tp input { margin-top: 3px; accent-color: var(--ora); }
.tokupick .tp .t { font-weight: 800; font-size: 12.5px; }
.tokupick .tp .cat { font-size: 10px; color: var(--ora-deep); font-weight: 800; }
.tokupick .tp .d { font-size: 11px; color: var(--ink-soft); margin-top: 2px; line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- 書類AI読み取り（新規案件ドロワー） ---------- */
.impbox {
  border: 1.5px dashed #f0b285; border-radius: 13px;
  background: linear-gradient(120deg, #fff7ef, #fff);
  padding: 13px 15px; margin-bottom: 14px;
}
.impbox .impt { font-weight: 900; font-size: 12.5px; color: var(--ora-dark); }
.impbox input[type="file"] {
  border: 1.5px solid var(--line); border-radius: 9px; background: #fff;
  padding: 6px 8px; font-size: 11px;
}
.imp-filled { background: #fdf6d8 !important; transition: background .4s; }

/* ---------- 書類ピッカーのカテゴリ見出し ---------- */
.doccat {
  font-size: 11.5px; font-weight: 900; color: var(--ora-dark);
  letter-spacing: .06em; margin: 16px 0 9px;
  display: flex; align-items: center; gap: 10px;
}
.doccat:first-child { margin-top: 2px; }
.doccat::after { content: ''; flex: 1; height: 2px; background: var(--peach-2); border-radius: 2px; }

/* ダッシュボードの案件×書類マトリクス（書類名ヘッダを折返し可・幅制限） */
#caseBoard .tbl th { white-space: normal; text-align: center; vertical-align: top; min-width: 56px; max-width: 88px; line-height: 1.3; }
#caseBoard .tbl th:first-child { text-align: left; min-width: 220px; max-width: none; }
#caseBoard .tbl td:first-child { min-width: 220px; }

/* ---------- 種別バッジ ---------- */
.typebadge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 900; padding: 3px 10px; border-radius: 8px;
}
.typebadge.tochi   { background: #fef9c3; color: #854d0e; }
.typebadge.kodate  { background: #dbeafe; color: #1e40af; }
.typebadge.mansion { background: #ede9fe; color: #5b21b6; }
.typebadge.chintai { background: #ffe4e6; color: #9f1239; }

/* ---------- 作成ステップ ---------- */
.stepnav {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 4px;
}
.stepnav .st {
  font-size: 11.5px; font-weight: 800; color: var(--ink-soft);
  background: #fff; border: 1.5px solid var(--line); border-radius: 999px;
  padding: 5px 13px;
}
.stepnav .st.on { color: #fff; background: linear-gradient(120deg, var(--ora), var(--ora-deep)); border-color: transparent; }

.preview-strip {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 5;
  background: var(--bg); padding: 10px 0; margin-top: 8px;
}
.sheetbox { overflow-x: auto; padding: 14px 4px 8px; }
.sheetzone { margin-top: 6px; }
.sheet-item { margin-top: 28px; }
.sheet-item .sh-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 9px;
}
.sheet-item .sh-head .t { font-weight: 900; font-size: 13.5px; }

/* ---------- A4 書面（実務書式に寄せたモノトーン・変更しない） ---------- */
.sheet {
  background: #fff; color: #111;
  box-shadow: 0 4px 22px rgba(70, 30, 10, .16);
  padding: 12mm;
  margin: 0 auto 14px;
  font-size: 9.5px; line-height: 1.55;
  position: relative;
}
.sheet.portrait  { width: 210mm; min-height: 296mm; }
.sheet.landscape { width: 297mm; min-height: 209mm; }

.f-no { position: absolute; top: 6mm; left: 12mm; font-size: 9px; }
.f-page { position: absolute; top: 6mm; right: 12mm; font-size: 8.5px; color: #555; }
.f-title { text-align: center; font-size: 16px; font-weight: 800; letter-spacing: .3em; padding: 2mm 0 1mm; }
.f-sub { text-align: center; font-size: 9px; margin-bottom: 3mm; color: #333; }

/* セクション見出し */
.f-sec {
  display: flex; align-items: center; gap: 2.5mm;
  margin: 3.5mm 0 1.5mm;
  font-size: 10.5px; font-weight: 800; letter-spacing: .08em;
  border-left: 1.2mm solid #333; padding-left: 2mm;
}
.f-sec .n { font-size: 9px; border: 1px solid #333; border-radius: 1mm; padding: 0 1.5mm; }

table.f-table { width: 100%; border-collapse: collapse; table-layout: fixed; margin-bottom: 1.5mm; }
.f-table th, .f-table td {
  border: 1px solid #333; padding: 1.2mm 1.8mm;
  font-size: 9px; font-weight: 400; text-align: left; vertical-align: middle;
  word-break: break-all; overflow-wrap: anywhere;
}
.f-table th, .f-label { background: #f0f2ee; font-weight: 700; }
.f-small { font-size: 7.8px; line-height: 1.4; }
.f-center { text-align: center !important; }
.f-nb { border: none !important; background: none !important; }

.f-seal {
  width: 11mm; height: 11mm; border: 1.6px solid #c0392b; border-radius: 1mm;
  color: #c0392b; display: grid; place-items: center;
  writing-mode: vertical-rl; text-orientation: upright;
  font-size: 7.5px; font-weight: 700; letter-spacing: .05em;
  transform: rotate(-3deg); opacity: .88;
}
.f-foot { margin-top: 3mm; font-size: 7.5px; color: #333; line-height: 1.6; }
.f-notice {
  border: 1px solid #333; padding: 2mm 3mm; margin-top: 2mm;
  font-size: 8px; line-height: 1.6;
}
/* デモ用スタンプ: 全シート共通で右下に架空表記（印刷にも載る） */
.sheet::after {
  content: '【デモ】本書面に記載の会社・人物・物件・番号はすべて架空です';
  position: absolute; bottom: 2.5mm; right: 12mm;
  font-size: 6.5px; color: #999; letter-spacing: .02em;
}

/* ---------- 印刷 ---------- */
@media print {
  body { background: #fff; }
  .side, .topbar, .panel > h2 .spacer, .noprint, .preview-strip,
  .drawer, .drawer-veil, .tokupick, .alerts, .stepnav { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; }
  .panel { border: none; box-shadow: none; padding: 0; margin: 0; }
  .sheetbox { overflow: visible; padding: 0; }
  .shell, .main, .page, .panel, .sheetzone, .sheet-item, .sheetbox {
    margin: 0 !important; padding: 0 !important; min-height: 0 !important;
  }
  .sheet { box-shadow: none; margin: 0; page-break-after: always; }
  .sheet:last-child { page-break-after: auto; }
  body[data-print] .sheet-item { display: none; }
  body[data-print] .sheet-item.print-target { display: block; }
  body[data-print] .page { display: none !important; }
  body[data-print] .page.on { display: block !important; }
  .sheet-item .sh-head { display: none; }
}

/* ---------- レスポンシブ ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side {
    position: static; height: auto; flex-direction: column;
    padding: 14px 12px;
  }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .side nav a { padding: 8px 10px; font-size: 12px; }
  .side .foot { display: none; }
  .main { padding: 18px 14px 50px; }
  .fgrid { grid-template-columns: minmax(0, 1fr); }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tokupick { grid-template-columns: minmax(0, 1fr); }
}
