/* ==========================================================================
   M&A brokerage site — shared stylesheet (public site + /admin)
   ========================================================================== */

:root {
    --navy: #12263f;
    --navy-soft: #1e3a5f;
    --accent: #0b6b62;
    --accent-hover: #095a52;
    --ink: #1f2933;
    --muted: #6b7785;
    --line: #dfe3e8;
    --bg: #f5f7fa;
    --panel: #ffffff;
    --warn: #b26a00;
    --danger: #b3261e;
    --ok: #1b6e3c;
    --radius: 6px;
    /* A single 1px offset with no blur: a hairline that separates a panel from the
       page without the soft halo. Every panel, card and stat uses this variable,
       so changing it here changes all of them. */
    --shadow: 0 1px 0 rgba(18, 38, 63, .10);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN",
        "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
    font-size: 15px;
    line-height: 1.7;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { line-height: 1.4; margin: 0 0 .6em; font-weight: 600; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

p { margin: 0 0 1em; }

/* Work screens use the window. The cap is high enough to be "full width" on any
   normal display and only bites on ultra-wide monitors, where a six-column table
   stretched to 3000px stops being readable. */
.container { max-width: 1800px; margin: 0 auto; padding: 0 20px; }
/* Single-column forms only (login, profile, the seller's own listing form):
   a text field 1800px wide is worse, not better. */
.container-narrow { max-width: 760px; margin: 0 auto; padding: 0 20px; }

/* ---------- Header ---------- */

.site-header {
    background: var(--navy);
    color: #fff;
    box-shadow: var(--shadow);
}
.site-header .container {
    display: flex;
    align-items: center;
    gap: 24px;
    min-height: 62px;
    flex-wrap: wrap;
}
.site-logo {
    color: #fff;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: .04em;
    white-space: nowrap;
}
.site-logo:hover { text-decoration: none; opacity: .85; }
.site-logo small {
    display: block;
    font-size: .62rem;
    font-weight: 400;
    letter-spacing: .18em;
    opacity: .7;
}
.site-nav { display: flex; gap: 18px; align-items: center; margin-left: auto; flex-wrap: wrap; }
.site-nav a { color: rgba(255, 255, 255, .88); font-size: .9rem; }
.site-nav a:hover { color: #fff; }
.site-nav .avatar {
    width: 28px; height: 28px; border-radius: 50%; vertical-align: middle;
    border: 1px solid rgba(255, 255, 255, .35);
}

/* ---------- Layout blocks ---------- */

.page { padding: 28px 0 64px; }
.page-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 16px; flex-wrap: wrap; margin-bottom: 20px;
}
.page-head p { color: var(--muted); margin: 0; font-size: .9rem; }

/* パンくず。区切りは CSS で入れるので、マークアップは項目だけを並べる。
   最後の項目（現在のページ）はリンクにしないため span になる。 */
.crumbs {
    display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
    font-size: .78rem; color: var(--muted); margin-bottom: 4px;
}
.crumbs > * + *::before {
    content: '\203a'; /* › */
    /* --line より一段濃く。区切りが見えないとパンくずが単語の羅列に見える。 */
    margin-right: 6px; color: #b8c1cb;
}
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent); }
.crumbs [aria-current='page'] { color: var(--ink); font-weight: 600; }

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}
.panel > :last-child { margin-bottom: 0; }
.panel-title {
    font-size: 1rem; font-weight: 600; margin: 0 0 14px;
    padding-bottom: 10px; border-bottom: 1px solid var(--line);
}
/* 見出しの下に置く、その表の範囲や前提の一行。 */
.panel-note { margin: 10px 18px 0; font-size: .78rem; color: var(--muted); }

.grid { display: grid; gap: 16px; }
.grid-cards { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

/* ---------- Buttons ---------- */

.btn {
    display: inline-block;
    padding: 9px 18px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    background: var(--accent);
    color: #fff;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    font-family: inherit;
    line-height: 1.4;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; color: #fff; }
.btn-outline { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn-outline:hover { background: rgba(11, 107, 98, .07); color: var(--accent); }
.btn-muted { background: #eceff3; color: var(--ink); border-color: var(--line); }
.btn-muted:hover { background: #e2e6ec; color: var(--ink); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #8f1d17; }
.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn-block { display: block; width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.btn-google {
    background: #fff; color: #3c4043; border: 1px solid #dadce0;
    display: inline-flex; align-items: center; gap: 12px;
    padding: 11px 22px; font-size: .95rem;
}
.btn-google:hover { background: #f7f8f8; color: #3c4043; }
.btn-google svg { width: 18px; height: 18px; flex: none; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-form { display: inline; }

/* ---------- Badges ---------- */

.badge {
    display: inline-block; padding: 2px 9px; border-radius: 999px;
    font-size: .74rem; font-weight: 600; line-height: 1.6;
    background: #eceff3; color: var(--muted); white-space: nowrap;
}
.badge-draft { background: #eceff3; color: #55606d; }
.badge-pending { background: #fff3dc; color: var(--warn); }
.badge-published { background: #e3f4ea; color: var(--ok); }
.badge-rejected { background: #fde8e6; color: var(--danger); }
.badge-closed { background: #e6e8eb; color: #55606d; }
.badge-approved { background: #e3f4ea; color: var(--ok); }
.badge-open { background: #fff3dc; color: var(--warn); }
.badge-answered { background: #e3f4ea; color: var(--ok); }
.badge-admin { background: var(--navy); color: #fff; }
.badge-seller { background: #e7ecf5; color: var(--navy-soft); }
.badge-buyer { background: #ecf3f2; color: var(--accent); }
.badge-active { background: #e3f4ea; color: var(--ok); }
.badge-suspended { background: #fde8e6; color: var(--danger); }
/* 操作ログの環境。見ている環境は既定の扱い（灰）で、それ以外＝別のホストで
   行われた操作だけを色で立たせる。本番の一覧で開発の操作を見落とさないため。 */
.env-tag { font-weight: 500; }
.env-self { background: #e7ecf5; color: var(--navy-soft); }
.env-other { background: #fff3dc; color: var(--warn); }
.env-unknown { background: #eceff3; color: var(--muted); }
/* financial statement extraction states */
.badge-processing { background: #e7eff7; color: #1d4468; }
.badge-extracted { background: #fff3dc; color: var(--warn); }
.badge-failed { background: #fde8e6; color: var(--danger); }
.badge-confirmed { background: #e3f4ea; color: var(--ok); }

input[type=file] {
    width: 100%; padding: 8px; border: 1px dashed #c6ccd4; border-radius: var(--radius);
    background: #fbfcfd; font-size: .88rem;
}
input[type=date] {
    padding: 9px 11px; border: 1px solid #c6ccd4; border-radius: var(--radius);
    font-size: .92rem; font-family: inherit; width: 100%;
}

/* ---------- Listing cards ---------- */

.card {
    background: var(--panel); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
    display: flex; flex-direction: column; gap: 10px;
}
.card-code { font-size: .74rem; color: var(--muted); letter-spacing: .06em; font-family: ui-monospace, monospace; }
.card-title { font-size: 1.02rem; font-weight: 600; margin: 0; }
.card-title a { color: var(--navy); }
.card-meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); }
.card-summary {
    font-size: .87rem; color: #4a5560; margin: 0;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.card-figures {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
    border-top: 1px solid var(--line); padding-top: 10px; margin-top: auto;
}
.card-figures div { font-size: .8rem; }
.card-figures dt { color: var(--muted); font-size: .72rem; }
.card-figures dd { margin: 0; font-weight: 600; }

/* ---------- Definition list ---------- */

.dl { display: grid; grid-template-columns: 190px 1fr; gap: 0; margin: 0; }
.dl dt {
    padding: 11px 14px; background: #f8fafb; border-bottom: 1px solid var(--line);
    font-size: .84rem; color: var(--muted); font-weight: 600;
}
.dl dd { padding: 11px 14px; border-bottom: 1px solid var(--line); margin: 0; }
.dl dt:last-of-type, .dl dd:last-of-type { border-bottom: 0; }
@media (max-width: 640px) {
    .dl { grid-template-columns: 1fr; }
    .dl dt { border-bottom: 0; padding-bottom: 2px; }
}

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data {
    width: 100%; border-collapse: collapse; font-size: .875rem;
    background: var(--panel);
}
table.data th, table.data td {
    padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left;
    vertical-align: top;
}
table.data th {
    background: #f8fafb; font-weight: 600; font-size: .8rem; color: var(--muted);
    white-space: nowrap;
}
table.data tbody tr:hover { background: #fbfcfd; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }

/* ---------- Forms ---------- */

.form-row { margin-bottom: 18px; }
.form-row > label, .label {
    display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; color: #3a4550;
}
.form-row .hint { font-size: .78rem; color: var(--muted); margin: 4px 0 0; }
input[type=text], input[type=email], input[type=number], input[type=tel],
input[type=search], select, textarea {
    width: 100%; padding: 9px 11px; border: 1px solid #c6ccd4; border-radius: var(--radius);
    font-size: .92rem; font-family: inherit; background: #fff; color: var(--ink);
}
textarea { min-height: 120px; resize: vertical; line-height: 1.7; }
input:focus, select:focus, textarea:focus {
    outline: 2px solid rgba(11, 107, 98, .3); outline-offset: 0; border-color: var(--accent);
}
.input.radio, .radio-group { display: flex; gap: 16px; flex-wrap: wrap; }
.radio-group label { font-weight: 400; display: flex; align-items: center; gap: 6px; }
.radio-group input { width: auto; }
.error-message { color: var(--danger); font-size: .8rem; margin-top: 4px; }
.input.error input, .input.error select, .input.error textarea { border-color: var(--danger); }
.required > label::after { content: " *"; color: var(--danger); }

.filter-bar {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px; align-items: end;
}
.filter-bar .form-row { margin-bottom: 0; }

/* ---------- Flash ---------- */

.flash-wrap { margin: 16px auto 0; }
.message {
    padding: 12px 16px; border-radius: var(--radius); margin-bottom: 12px;
    font-size: .9rem; border: 1px solid transparent; cursor: pointer;
}
.message.success { background: #e3f4ea; border-color: #b8e0c8; color: #10502c; }
.message.error   { background: #fde8e6; border-color: #f4c3be; color: #8f1d17; }
.message.warning { background: #fff3dc; border-color: #f0d9a8; color: #7a4900; }
.message.info    { background: #e7eff7; border-color: #c3d6e8; color: #1d4468; }

/* ---------- Confidential block ---------- */

.locked {
    border: 1px dashed #c6ccd4; border-radius: var(--radius);
    background: repeating-linear-gradient(45deg, #fafbfc, #fafbfc 10px, #f4f6f8 10px, #f4f6f8 20px);
    padding: 28px 22px; text-align: center;
}
.locked h3 { margin-bottom: 6px; }
.locked p { color: var(--muted); font-size: .88rem; max-width: 520px; margin: 0 auto 16px; }

/* Prose keeps a readable measure even when its panel is very wide: past roughly
   80 characters the eye loses the line it is on. Tables and figures are not
   capped — they benefit from every pixel. */
.detail-body { white-space: pre-wrap; line-height: 1.85; max-width: 80ch; }
.compact .hint, .compact .panel > p:not([class]) { max-width: 96ch; }

/* ---------- Stats ---------- */

.stat {
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 16px 18px; box-shadow: var(--shadow);
}
.stat .stat-label { font-size: .78rem; color: var(--muted); margin: 0 0 4px; }
.stat .stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1.2; color: var(--navy); }
.stat.alert .stat-value { color: var(--warn); }
.stat a { display: block; }
.stat a:hover { text-decoration: none; }

/* ---------- Pagination ---------- */

.pagination { display: flex; gap: 4px; list-style: none; padding: 0; margin: 22px 0 0; flex-wrap: wrap; }
.pagination li a, .pagination li.active a {
    display: block; padding: 6px 12px; border: 1px solid var(--line);
    border-radius: var(--radius); background: #fff; font-size: .85rem;
}
.pagination li.active a { background: var(--navy); color: #fff; border-color: var(--navy); }
.pagination li.disabled a { color: #b6bec7; pointer-events: none; }
.paginator-counter { color: var(--muted); font-size: .82rem; margin-top: 10px; }

/* ---------- Empty state ---------- */

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty p { margin: 0 0 14px; }

/* ---------- Footer ---------- */

.site-footer {
    border-top: 1px solid var(--line); background: #fff; padding: 24px 0;
    color: var(--muted); font-size: .82rem; margin-top: 40px;
}

/* ==========================================================================
   Admin
   ========================================================================== */

body.admin { background: #eef1f5; }

.admin-header { background: #0d1b2a; }
.admin-header .site-logo small { color: #7fb8ae; opacity: 1; }

.admin-shell { display: flex; align-items: flex-start; gap: 0; min-height: calc(100vh - 62px); }

.admin-side {
    width: 218px; flex: none; background: #16283d; color: #cbd5e1;
    min-height: calc(100vh - 62px); padding: 18px 0;
}
.admin-side .side-head {
    font-size: .7rem; letter-spacing: .12em; color: #7d8fa3;
    padding: 10px 20px 6px; text-transform: uppercase;
}
.admin-side a {
    display: flex; justify-content: space-between; align-items: center; gap: 8px;
    padding: 9px 20px; color: #cbd5e1; font-size: .88rem;
}
.admin-side a:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.admin-side a.active { background: var(--accent); color: #fff; font-weight: 600; }
.admin-side .pill {
    background: var(--warn); color: #fff; border-radius: 999px;
    font-size: .68rem; padding: 1px 7px; font-weight: 700;
}
.admin-side a.active .pill { background: rgba(0, 0, 0, .3); }
/* 「最終更新」— リンクではないので、押せるものと見分けがつくよう淡く小さく。 */
.admin-side .side-note {
    margin: 2px 0 0; padding: 0 20px; font-size: .7rem; color: #7d8fa3;
}
/* バージョン。メニュー項目ではなく脚注として読ませたいので、区切り線で離す。 */
.admin-side .side-version {
    margin: 14px 0 0; padding: 10px 20px 0; font-size: .7rem; color: #62748c;
    border-top: 1px solid rgba(255, 255, 255, .08);
}

.admin-main { flex: 1; padding: 26px 28px 64px; min-width: 0; }

@media (max-width: 860px) {
    .admin-shell { flex-direction: column; }
    .admin-side { width: 100%; min-height: 0; display: flex; flex-wrap: wrap; padding: 8px; }
    .admin-side .side-head { display: none; }
    .admin-side a { padding: 7px 12px; }
    /* 横並びになるとメニュー項目の間に挟まって読めないため落とす。 */
    .admin-side .side-note { display: none; }
    /* バージョンは残す。項目に挟まらないよう、行を独占させる。 */
    .admin-side .side-version {
        width: 100%; margin: 6px 0 0; padding: 6px 12px 0; border-top: none;
    }
    .admin-main { padding: 18px 16px 48px; }
}

/* ---------- アップデート履歴 ---------- */

.changelog { display: flex; flex-direction: column; gap: 14px; max-width: 860px; }
.changelog-head {
    display: flex; align-items: center; gap: 10px;
    font-size: .8rem; color: var(--muted); margin-bottom: 2px;
}
.changelog-title { font-size: 1.05rem; margin: 0 0 6px; }
.changelog-summary { color: var(--muted); font-size: .88rem; margin: 0 0 12px; }

.changelog-items { list-style: none; margin: 0; padding: 0; }
.changelog-items li {
    display: flex; gap: 10px; align-items: baseline;
    padding: 7px 0; border-top: 1px solid var(--line);
}
.changelog-items li:first-child { border-top: 0; }
.log-text { font-size: .9rem; line-height: 1.65; }
/* 種別のタグ。幅を固定して本文の頭を縦に揃える — 項目数が多いので、
   ラベル長で本文がずれると流し読みできない。 */
.log-tag {
    flex: none; width: 5.6rem; text-align: center;
    border-radius: 4px; padding: 2px 6px;
    font-size: .7rem; font-weight: 700; color: #fff; white-space: nowrap;
}
.log-added { background: #2f855a; }
.log-changed { background: #2b6cb0; }
.log-fixed { background: #975a16; }
/* セキュリティだけ赤。流し読みでも目に入る必要がある。 */
.log-security { background: #b64b4b; }

@media (max-width: 640px) {
    /* 幅が足りないと本文が1文字ずつ折り返すため、タグを上に出す。 */
    .changelog-items li { flex-direction: column; gap: 4px; }
    .log-tag { width: auto; align-self: flex-start; padding: 2px 8px; }
}

/* ---------- Drag & drop upload ---------- */

.dropzone {
    border: 2px dashed #c6ccd4;
    border-radius: var(--radius);
    background: #fbfcfd;
    padding: 26px 20px;
    text-align: center;
    transition: border-color .12s ease, background .12s ease;
}
/* Only advertise dropping once the script has confirmed it can accept files. */
.dropzone.dropzone-ready { cursor: pointer; }
.dropzone.dropzone-ready:hover { border-color: var(--accent); background: #f6faf9; }
.dropzone.is-dragover {
    border-color: var(--accent);
    background: #eef7f5;
    box-shadow: inset 0 0 0 1px rgba(11, 107, 98, .18);
}
.dropzone:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.dropzone .dropzone-icon { font-size: 1.8rem; line-height: 1; display: block; margin-bottom: 8px; }
.dropzone .dropzone-lead { font-weight: 600; margin: 0 0 4px; }
.dropzone .dropzone-sub { font-size: .82rem; color: var(--muted); margin: 0 0 14px; }
/* Kept visible so the picker still works without JS. */
.dropzone input[type=file] {
    border: 0; background: transparent; padding: 0;
    width: auto; max-width: 100%; font-size: .85rem;
}
.dropzone.dropzone-ready input[type=file] { cursor: pointer; }

.dropzone-files { margin-top: 14px; text-align: left; }
.dropzone-files .dropzone-count {
    font-size: .84rem; font-weight: 600; color: var(--accent); margin: 0 0 6px;
}
.dropzone-files ul { list-style: none; margin: 0; padding: 0; }
.dropzone-files li {
    display: flex; justify-content: space-between; gap: 12px;
    font-size: .84rem; padding: 5px 10px; background: #fff;
    border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 4px;
}
.dropzone-files .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropzone-files .fsize { color: var(--muted); flex: none; font-variant-numeric: tabular-nums; }
.dropzone.has-files { border-style: solid; border-color: var(--accent); background: #fff; }

/* ---------- Header user menu ---------- */

.user-menu { position: relative; }
.user-menu-trigger {
    display: inline-flex; align-items: center; gap: 7px;
    cursor: pointer; list-style: none; padding: 6px 4px;
    color: inherit; white-space: nowrap;
}
/* Hide the native disclosure triangle; the caret below replaces it. */
.user-menu-trigger::-webkit-details-marker { display: none; }
.user-menu-trigger::marker { content: ''; }
.user-menu-caret { font-size: .7rem; opacity: .8; transition: transform .12s ease; }
.user-menu[open] .user-menu-caret { transform: rotate(180deg); }
.user-menu-trigger:hover { opacity: .85; }
.user-menu-trigger:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; border-radius: 4px; }

.user-menu-list {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 40;
    min-width: 190px; padding: 6px;
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.user-menu-list a, .user-menu-list button {
    display: block; width: 100%; text-align: left;
    padding: 9px 12px; border: 0; background: none; cursor: pointer;
    color: var(--ink); font-size: .88rem; font-family: inherit; border-radius: var(--radius);
}
.user-menu-list a:hover, .user-menu-list button:hover { background: #eef2f5; text-decoration: none; }
.user-menu-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.user-menu-list .user-menu-logout { color: var(--danger); }

/* A form locked while a background job is about to overwrite it. Readable, but
   clearly not editable, so nothing typed now is lost when the draft lands. */
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.is-locked { opacity: .62; }
fieldset.is-locked input, fieldset.is-locked textarea, fieldset.is-locked select {
    background: #f4f6f8; cursor: not-allowed;
}

/* ---------- Error pages ---------- */

/* 403 and 404 are ordinary outcomes here — a buyer opening a case they are not
   party to, or a stale link — so they get a plain explanation and a way out. */
.err-body { background: var(--bg); }
.err { padding: 64px 0 80px; text-align: center; }
.err-code {
    font-size: 3.4rem; font-weight: 700; line-height: 1; margin: 0 0 6px;
    color: #c6ccd4; font-variant-numeric: tabular-nums;
}
.err-title { font-size: 1.35rem; margin: 0 0 12px; }
.err-lead { color: var(--muted); margin: 0 auto 8px; max-width: 46ch; text-align: left; }
.err-detail {
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 10px 14px; margin: 14px 0 0; font-size: .88rem; text-align: left;
}
.err-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 22px; }
.err-debug {
    margin-top: 32px; text-align: left; font-size: .82rem; color: var(--muted);
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 12px 14px;
}
.err-debug summary { cursor: pointer; font-weight: 600; }
.err-debug p { margin: 8px 0 0; word-break: break-all; }

/* ---------- Compact admin screens ---------- */

/* Admin pages stack a lot of panels; this tightens every vertical gap so a
   screen fits without much scrolling at 1440x900. Applied by wrapping the page
   (or the form) in .compact. */
.compact .panel { padding: 16px 18px; margin-bottom: 14px; }
.compact .panel-title { margin-bottom: 12px; padding-bottom: 8px; font-size: .95rem; }
.compact .form-row { margin-bottom: 12px; }
.compact .grid { gap: 12px 16px; }
.compact .form-row .hint { margin-top: 3px; }
.compact .hint { margin: 6px 0 0; font-size: .78rem; }
.compact textarea { min-height: 0; }
.compact textarea.ta-sm { line-height: 1.6; }
.compact .actions { margin-top: 4px; }

/* Denser definition lists, and a narrower label column so two can sit
   side by side without the values being squeezed. */
.compact .dl { grid-template-columns: 130px 1fr; }
.compact .dl dt, .compact .dl dd { padding: 6px 10px; font-size: .84rem; }
.compact .detail-body { line-height: 1.7; font-size: .88rem; }
.compact table.data th, .compact table.data td { padding: 7px 10px; }

/* ---------- Edit beside a preview ---------- */

/* Used by the document review screen (scan | extracted figures) and by the report
   editor (rendered report | the fields that produce it). In both the work is a
   comparison, so the left pane stays put while the right one scrolls. */
/* 追従する操作バー。この画面は縦に長く、下の入力欄を触っているあいだ保存ボタンは
   画面外にあるため、上に残す。--report-bar-h はプレビューの sticky 位置と共有する
   ので、バーの高さを変えるときはここだけ直せばよい。 */
:root { --report-bar-h: 52px; }
.report-bar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; flex-wrap: wrap;
    min-height: var(--report-bar-h);
    margin: 0 0 12px; padding: 8px 14px;
    background: var(--panel); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: 0 1px 6px rgba(15, 30, 50, .08);
}
/* 案件番号・会社名・生成時刻・確認状態。見出し下にあった行をここへ移した
   ので、スクロール中も「未確認」かどうかが見えている。 */
.report-bar-who {
    display: flex; align-items: center; gap: 10px;
    min-width: 0; font-size: .85rem; color: var(--muted);
}
.report-bar-who strong {
    flex: none;
    font-family: ui-monospace, monospace; font-size: .78rem; color: var(--muted);
}
/* 会社名だけが可変。長い社名はここで詰める。 */
.rb-company {
    color: var(--ink); font-weight: 600;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rb-meta { flex: none; white-space: nowrap; }
.report-bar .actions { margin: 0; flex: none; }

.review-split { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; }
/* 操作バーの下に潜らせない。 */
.review-doc > .panel { position: sticky; top: calc(var(--report-bar-h) + 12px); }
.doc-frame {
    display: block; width: 100%; height: 78vh; min-height: 420px;
    border: 0; border-top: 1px solid var(--line); background: #f4f6f8;
    overflow: auto;
}
@media (max-width: 900px) {
    .review-split { grid-template-columns: 1fr; }
    .review-doc > .panel { position: static; }
    .doc-frame { height: 50vh; }
}
@media (max-width: 1100px) {
    /* 生成時刻から先に落とす。会社名と確認状態のほうが判断に使う。 */
    .rb-meta { display: none; }
}
@media (max-width: 640px) {
    /* ここまで狭いと1行に収まらない。バーが本文を圧迫するのでボタンだけ残す。 */
    .report-bar { padding: 8px 12px; }
    .report-bar-who { display: none; }
    .report-bar .actions { flex: 1; }
}

/* Which report the preview pane is showing. */
.preview-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.preview-tabs a {
    padding: 5px 12px; font-size: .8rem; border-radius: 999px;
    border: 1px solid var(--line); color: var(--muted); background: #fff;
}
.preview-tabs a:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.preview-tabs a.is-current {
    background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
}
/* The narrative fields, stacked in the right-hand pane. */
.narrative-fields .form-row { margin-bottom: 10px; }
.narrative-fields textarea { font-size: .86rem; line-height: 1.6; }
.narrative-fields label { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.narrative-fields .field-where { font-weight: 400; font-size: .72rem; color: var(--muted); }
/* The label's jump control: reads as the destination, behaves as a button. */
.field-jump {
    border: 1px solid var(--line); background: #fff; color: var(--muted);
    font: inherit; font-size: .72rem; font-weight: 400;
    padding: 2px 8px; border-radius: 999px; cursor: pointer; white-space: nowrap;
}
.field-jump:hover { border-color: var(--accent); color: var(--accent); }
.field-jump:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
fieldset.is-locked .field-jump { cursor: not-allowed; }
/* A section with columns: shown so the reviewer knows it exists and where it
   lands, but not editable here — a textarea cannot hold a table. */
.table-section {
    background: #f6f8fa; border: 1px dashed var(--line);
    border-radius: var(--radius); padding: 8px 10px;
}

/* The locked panel, on a page that is already tight. */
.locked-slim { padding: 16px 18px; }
.locked-slim h3 { font-size: 1rem; margin: 0 0 4px; }
.locked-slim p { margin-bottom: 12px; }

/* Panels that pair up on a wide screen and stack on a narrow one. */
.panel-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.panel-pair > .panel { margin-bottom: 0; }
@media (max-width: 900px) {
    .panel-pair { grid-template-columns: 1fr; }
}

/* The compact page head: title and actions on one line. */
.compact .page-head { margin-bottom: 14px; }
.compact .page-head h1 { font-size: 1.25rem; margin: 2px 0 4px; }

/* The admin area already loses width to the sidebar, so its content uses what is
   left. Long prose is handled by .detail-body below rather than by narrowing the
   whole page. */
.admin-main .compact { max-width: none; }

/* Kept for the registration form, which uses the same rules. */
.form-compact .panel { padding: 16px 18px; margin-bottom: 14px; }
.form-compact .panel-title { margin-bottom: 12px; padding-bottom: 8px; }
.form-compact .form-row { margin-bottom: 12px; }
.form-compact .grid { gap: 12px 16px; }
.form-compact .form-row .hint { margin-top: 3px; }
.form-compact .hint { margin: 6px 0 0; font-size: .78rem; }
.form-compact textarea { min-height: 0; }
.form-compact textarea.ta-sm { line-height: 1.6; }
.form-compact .actions { margin-top: 4px; }

/* Confirmed figures on the edit form, inline rather than stacked. */
.form-compact .figures {
    display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
    border-top: 1px solid var(--line); padding-top: 12px; margin-top: 4px;
}
.form-compact .figures .label { margin: 0 6px 0 0; display: inline; }
.form-compact .figures strong { font-weight: 600; }

/* ---------- Compact upload row ---------- */

/* Drop target and submit on one line, so the upload takes a fraction of the
   height and the list of already-uploaded documents stays in view. */
.upload-panel { padding: 14px 16px; }
.upload-row { display: flex; align-items: stretch; gap: 12px; }
.upload-row .dropzone { flex: 1; min-width: 0; }
.upload-row .btn { flex: none; align-self: center; }
.upload-note { margin: 8px 0 0; }
/* The website URL: one line under the drop target, deliberately quiet — it is
   optional, but it is the only qualitative input the reports get. */
.upload-url { margin: 10px 0 0; }
.upload-url > label { font-size: .8rem; }
.upload-url input { max-width: 460px; }

.dropzone-mini {
    padding: 10px 14px;
    display: flex; align-items: center; justify-content: center;
    gap: 12px; flex-wrap: wrap; text-align: center;
}
.dropzone-mini .dropzone-lead { font-size: .88rem; font-weight: 600; margin: 0; }
.dropzone-mini input[type=file] { font-size: .8rem; }
/* Selected files list back to full width under the row. */
.dropzone-mini .dropzone-files { flex-basis: 100%; margin-top: 8px; }
@media (max-width: 640px) {
    .upload-row { flex-direction: column; }
    .upload-row .btn { align-self: stretch; }
}

/* Slim dropzone: same target, a third of the height. */
.dropzone-slim { padding: 14px 16px; }
.dropzone-slim .dropzone-lead { font-size: .92rem; margin-bottom: 3px; }
.dropzone-slim .dropzone-sub { margin-bottom: 8px; }
.dropzone-slim .dropzone-files { margin-top: 10px; }

/* ---------- Background progress ---------- */

/* Shown while an upload is in flight and while the worker reads the files, so
   the page reports progress itself instead of the browser's loading spinner. */
.progress-panel {
    margin-top: 14px; padding: 14px 16px;
    background: #f6faf9; border: 1px solid var(--line); border-radius: var(--radius);
}
.progress-head { font-weight: 600; margin: 0 0 8px; font-size: .92rem; }
.progress-track {
    height: 6px; background: #dfe5e8; border-radius: 999px; overflow: hidden; margin-bottom: 8px;
}
.progress-fill {
    height: 100%; width: 0; background: var(--accent);
    border-radius: 999px; transition: width .25s ease;
}
.progress-note { font-size: .8rem; color: var(--muted); margin: 0; }
.progress-files { list-style: none; margin: 10px 0 0; padding: 0; }
.progress-file {
    display: flex; justify-content: space-between; gap: 12px; align-items: baseline;
    font-size: .82rem; padding: 5px 10px; background: #fff;
    border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 4px;
}
.progress-file .pf-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress-file .pf-state { flex: none; color: var(--muted); }
.progress-file.is-processing .pf-state { color: var(--accent); font-weight: 600; }
.progress-file.is-extracted .pf-state,
.progress-file.is-confirmed .pf-state { color: var(--ink); }
.progress-file.is-failed { border-color: #d8b4b4; background: #fdf6f6; }
.progress-file.is-failed .pf-state { color: #b64b4b; font-weight: 600; }
