/* 事業計画書アプリの画面。白地・濃いグレーの文字・差し色は紺1色。書体は OS 標準。 */
@page { size: A4; margin: 0; }

:root {
  --ink: #1f2933;
  --sub: #5b6672;
  --line: #d5dae1;
  --bg: #f1f3f6;
  --navy: #1b3a63;
  --navy-d: #142c4c;
  --warn-bg: #fdecea;
  --warn: #a61b1b;
  --tap: 44px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

.app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}
.app > * { flex: none; }

/* ---- 上の帯 ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  background: var(--navy);
  color: #fff;
}
.title-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: var(--tap);
  min-width: 0;
  max-width: 55%;
  padding: 0 8px;
  background: transparent;
  color: inherit;
  border: 0;
  border-radius: 6px;
  font: inherit;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
}
.title-btn:hover { background: rgba(255, 255, 255, 0.12); }
.prop-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.save-state { margin-left: auto; min-width: 0; font-size: 13px; opacity: 0.9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .btn.menu { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.55); }
.topbar .btn.menu:hover { background: rgba(255, 255, 255, 0.14); }

.notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #fff7e0;
  border-bottom: 1px solid #e9d08a;
  font-size: 14px;
}

.app > .content { flex: 1 1 auto; min-height: 0; position: relative; }

/* ---- ボタン ---- */
.btn {
  white-space: nowrap;
  min-height: var(--tap);
  padding: 0 14px;
  background: #fff;
  color: var(--navy);
  border: 1px solid var(--navy);
  border-radius: 6px;
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}
.btn:hover:not(:disabled) { background: #eef2f8; }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.primary { background: var(--navy); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--navy-d); }
.btn.small { padding: 0 10px; font-size: 14px; }
.btn.big { padding: 0 24px; font-size: 17px; font-weight: 700; }
.btn.icon { min-width: var(--tap); padding: 0 8px; font-size: 14px; }
.btn.danger { color: var(--warn); border-color: var(--warn); }
.btn.back { margin-bottom: 8px; }
.hidden { display: none; }

/* ---- 本体の2ペイン ---- */
.layout { height: 100%; display: grid; grid-template-columns: 480px minmax(0, 1fr); }
.pane-edit { min-height: 0; overflow-y: auto; background: var(--bg); border-right: 1px solid var(--line); }
.pane-preview { min-height: 0; overflow-y: auto; background: #9a9a9a; }
.tabbar { display: none; }

.tabs {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  gap: 2px;
  padding: 6px 8px 0;
  background: #fff;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  min-height: var(--tap);
  padding: 0 14px;
  background: transparent;
  color: var(--sub);
  border: 0;
  border-bottom: 3px solid transparent;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.tab[aria-selected="true"] { color: var(--navy); border-bottom-color: var(--navy); }

.screen { padding: 12px; }

/* ---- カードと入力欄 ---- */
.card {
  margin: 0 0 12px;
  padding: 12px 14px 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.card h3 { margin: 0 0 8px; font-size: 14px; color: var(--navy); letter-spacing: 0.03em; }
.hint { margin: 4px 0 8px; font-size: 13px; color: var(--sub); }

.field { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 0 0 8px; }
.field > label:first-child { flex: 0 0 38%; font-size: 14px; color: var(--sub); }
.field > .ctl { flex: 1 1 0; min-width: 0; }
.field.wide > label:first-child, .field.wide > .ctl { flex: 1 1 100%; }

.ctl { display: flex; align-items: center; gap: 6px; }
.ctl input[type="text"], .ctl input[type="date"], .ctl select, .preset {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  min-height: var(--tap);
  padding: 6px 10px;
  background: #fff;
  color: var(--ink);
  border: 1px solid #b8c0cb;
  border-radius: 6px;
  font: inherit;
  font-size: 16px;
}
.ctl input.num { text-align: right; font-variant-numeric: tabular-nums; }
.ctl input:focus, .ctl select:focus, .preset:focus, .btn:focus-visible, .tab:focus-visible { outline: 2px solid #3b6fb5; outline-offset: 1px; }
.ctl input.bad { border-color: var(--warn); background: var(--warn-bg); }
.ctl.auto input { background: #eef1f5; color: var(--sub); }
.unit { flex: 0 0 auto; min-width: 1.4em; font-size: 14px; color: var(--sub); }
.preset { flex: 1 1 100%; width: 100%; margin-top: 2px; font-size: 14px; }
.field > .btn { flex: 1 1 100%; }

.chk { display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); font-size: 14px; color: var(--ink); cursor: pointer; }
.chk input { width: 20px; height: 20px; margin: 0; }
.chk.page { font-weight: 600; }
.chk.sub { min-height: 36px; font-size: 13px; color: var(--sub); margin-right: 8px; }
.pagecheck { padding: 2px 0 6px; border-bottom: 1px dashed var(--line); }
.pagecheck:last-child { border-bottom: 0; }
.blocks { margin-left: 28px; display: flex; flex-wrap: wrap; }
.field.ov { margin-bottom: 10px; }
.field.ov .chk { flex: 1 1 100%; min-height: 36px; }
.radios { flex-wrap: wrap; }
.radios .ctl { flex: 1 1 100%; }

.add-row { display: flex; gap: 8px; margin: 4px 0 10px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }

.readout { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 8px 0; border-top: 1px solid #edf0f3; }
.readout:first-of-type { border-top: 0; }
.readout .lbl { font-size: 14px; color: var(--sub); }
.readout .val { font-variant-numeric: tabular-nums; text-align: right; }
.readout.strong .val { font-weight: 700; font-size: 17px; color: var(--navy); }
.totals { background: #f8fafc; }

/* ---- 部屋 ---- */
.room.vacant { border-left: 4px solid var(--warn); }
.room-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.room-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.grid .field { display: block; }
.grid .field > label:first-child { display: block; margin-bottom: 2px; }
.grid .field.wide { grid-column: 1 / -1; }

/* ---- 収支の行 ---- */
.lrow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px dashed var(--line); }
.lrow:last-child { border-bottom: 0; }
.lname { flex: 1 1 100%; }
.lamt { flex: 1 1 140px; }
.luntil { flex: 1 1 130px; }

/* ---- 物件一覧 ---- */
.view { height: 100%; overflow-y: auto; padding: 14px; max-width: 760px; margin: 0 auto; }
.view-title { margin: 0 0 12px; font-size: 18px; color: var(--navy); }
.plist { list-style: none; margin: 0; padding: 0; }
.prow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 8px; padding: 6px 8px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.prow.current { border-color: var(--navy); box-shadow: inset 3px 0 0 var(--navy); }
.pname { flex: 1 1 220px; display: flex; flex-direction: column; align-items: flex-start; min-height: var(--tap); padding: 4px 6px; background: transparent; border: 0; font: inherit; color: var(--ink); text-align: left; cursor: pointer; }
.pname .n { font-weight: 700; overflow-wrap: anywhere; }
.pname .d { font-size: 12px; color: var(--sub); }
.pactions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { padding: 16px; color: var(--sub); }
.fatal { color: var(--warn); font-weight: 600; overflow-wrap: anywhere; }
.login { text-align: center; padding-top: 48px; }
.login .add-row { justify-content: center; }

/* ---- プレビュー ---- */
.pv-warn { position: sticky; top: 0; z-index: 3; padding: 8px 12px; background: var(--warn-bg); color: var(--warn); font-weight: 700; font-size: 14px; border-bottom: 2px solid var(--warn); }
.pv-msg { margin: 12px; padding: 12px 14px; background: #fff; border-radius: 8px; color: var(--ink); }
.pv-frame { width: 100%; overflow: hidden; }
.pv-inner { width: 210mm; transform-origin: top left; }
.pv-host { display: block; }

.ver { padding: 2px 12px; font-size: 11px; color: var(--sub); background: var(--bg); border-top: 1px solid var(--line); text-align: right; }

/* ---- スマホ幅（1列・下の切り替えバー） ---- */
@media (max-width: 999px) {
  .layout { display: block; position: relative; }
  .pane-edit, .pane-preview { height: 100%; border-right: 0; }
  .layout[data-pane="edit"] .pane-preview,
  .layout[data-pane="preview"] .pane-edit { position: absolute; left: 0; top: 0; width: 100%; height: 0; overflow: hidden; visibility: hidden; pointer-events: none; }
  .tab[data-id="output"] { display: none; }
  .tabbar { display: grid; grid-template-columns: repeat(3, 1fr); background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .tabbar button { min-height: 52px; background: transparent; border: 0; border-top: 3px solid transparent; font: inherit; font-weight: 600; color: var(--sub); cursor: pointer; }
  .tabbar button[aria-current="true"] { color: var(--navy); border-top-color: var(--navy); }
  .save-state { font-size: 12px; }
  .field > label:first-child { flex-basis: 38%; font-size: 13px; }
}

/* ---- 印刷：アプリの画面を隠し、A4のシートだけを出す ---- */
@media print {
  html, body { height: auto; background: #fff; }
  .topbar, .notice, .tabbar, .ver, .pane-edit, .pv-warn, .pv-msg, .view { display: none !important; }
  .app { display: block; height: auto; }
  .content { overflow: visible; }
  .layout { display: block !important; height: auto; }
  .pane-preview {
    position: static !important;
    visibility: visible !important;
    width: auto !important;
    height: auto !important;
    overflow: visible !important;
    background: none;
  }
  .pv-frame { height: auto !important; overflow: visible !important; }
  .pv-inner { transform: none !important; margin: 0 !important; width: auto; }
}
