/* CaseSurvey - the catalogue page.
 * Archive cabinet: the macro-areas on the left as folder tabs, the open folder on the right with
 * its case types as files. On a phone the list and the folder are two screens (C12). */

.stats { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.stats .stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; min-width: 96px; }
.stats .stat b { display: block; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.stats .stat span { font-size: .78rem; color: var(--ink-2); }
.saved { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 600; color: #a9f0d1; padding: 0 8px; white-space: nowrap; }
.saved.busy { color: #c9d6e3; }
.saved.err { color: #fca5a5; }

.shell { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; }
.rail { position: sticky; top: calc(var(--bar-h) + 14px); display: flex; flex-direction: column; gap: 8px; }
.rail-title { font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 2px; }
.area-btn {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; width: 100%; text-align: left;
    background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 10px;
    padding: 10px 12px; min-height: 56px; color: var(--ink);
}
.area-btn:hover { border-color: var(--blue); }
.area-btn[aria-current="true"] { border-color: var(--blue); border-left-color: var(--blue); background: var(--blue-soft); }
.area-btn .nm { font-weight: 600; }
.area-btn .ct { font-size: .78rem; color: var(--ink-3); align-self: center; font-variant-numeric: tabular-nums; }
.area-btn .bar { grid-column: 1 / -1; height: 4px; border-radius: 2px; background: var(--line-2); overflow: hidden; margin-top: 4px; }
.area-btn .bar i { display: block; height: 100%; background: var(--teal); }

.pane { min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.pane .back-btn { display: none; align-self: flex-start; }
.area-head { padding: 16px; display: grid; gap: 12px; }
.area-head .row { align-items: flex-end; flex-wrap: wrap; }
.area-head .row .field { flex: 1 1 260px; }
.area-head .field { margin-bottom: 0; }
.input.title-in { font-size: 1.2rem; font-weight: 700; }
.tools { display: flex; gap: 2px; flex: none; }
.section-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-h h2 { font-size: 1.1rem; margin: 0; display: flex; align-items: center; gap: 8px; }
.section-h h3 { font-size: 1rem; margin: 0; display: flex; align-items: center; gap: 8px; }
.section-h h3 i { color: var(--blue); }
.count { font-size: .78rem; padding: 2px 8px; border-radius: 999px; background: var(--line-2); color: var(--ink-2); font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }

.ctype .ctype-head { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 14px; min-height: 60px; }
.ctype-toggle { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; background: none; border: 0; text-align: left; padding: 6px 0; min-height: 44px; color: var(--ink); }
.ctype-toggle .chev { color: var(--ink-3); transition: transform .15s; width: 14px; flex: none; }
.ctype.open .ctype-toggle .chev { transform: rotate(90deg); }
.ctype-toggle .tt { font-weight: 600; }
.ctype-toggle .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.ctype-body { border-top: 1px solid var(--line-2); padding: 16px 14px; display: grid; gap: 20px; }
.ctype-body .field { margin-bottom: 0; }
.block { display: grid; gap: 10px; }

.fields-head, .field-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr) 140px minmax(0, 2fr) 140px; gap: 8px; align-items: center; }
.fields-head { font-size: .78rem; font-weight: 700; color: var(--ink-3); padding: 0 10px; }
.field-row { background: #f6f8fb; border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 10px; }
.field-row .fl { display: none; font-size: .78rem; font-weight: 700; color: var(--ink-3); margin-bottom: 4px; }
.field-row label.check { min-height: 44px; font-weight: 500; font-size: .9rem; }
.row-tools { display: flex; justify-content: flex-end; }
.empty-mini { padding: 14px; border: 1px dashed var(--line); border-radius: 10px; color: var(--ink-3); font-size: .92rem; background: var(--card); }

.docs { display: grid; gap: 10px; }
.doc { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: start; background: #f6f8fb; border: 1px solid var(--line-2); border-radius: 10px; padding: 12px; }
.doc .ico { width: 44px; height: 52px; border-radius: 6px; background: var(--red-soft); color: var(--red); display: grid; place-items: center; font-size: 1.3rem; }
.doc .body { display: grid; gap: 10px; min-width: 0; }
.doc .body .field { margin-bottom: 0; }
.doc .fname { font-size: .84rem; color: var(--ink-3); display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.doc .fname a { display: inline-flex; gap: 6px; align-items: center; min-height: 36px; font-weight: 600; text-decoration: none; }
.doc .fname a:hover { text-decoration: underline; }
.drop { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px; border: 1.5px dashed #c4cfdb; border-radius: 10px; color: var(--ink-2); background: var(--card); }
.drop.over { border-color: var(--blue); background: var(--blue-soft); }
.drop input[type="file"] { display: none; }
.uploading { font-size: .86rem; color: var(--blue); font-weight: 600; }

.pill { font-size: .76rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.pill.TODO { background: var(--amber-soft); color: #6b4a0c; }
.pill.WIP { background: var(--blue-soft); color: #134a7c; }
.pill.DONE { background: var(--teal-soft); color: #0b5e4e; }

.welcome { padding: 24px 20px; display: grid; gap: 12px; }
.welcome h2 { margin: 0; font-size: 1.25rem; }
.welcome p { margin: 0; color: var(--ink-2); max-width: 64ch; }
.suggest { display: flex; flex-wrap: wrap; gap: 8px; }
.suggest .btn { font-weight: 500; }

@media (max-width: 1100px) {
    .fields-head { display: none; }
    .field-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .field-row .fl { display: block; }
    .field-row .c-label, .field-row .c-notes { grid-column: 1 / -1; }
}
@media (max-width: 860px) {
    .shell { grid-template-columns: minmax(0, 1fr); }
    .rail { position: static; }
    .shell.detail .rail { display: none; }
    .shell:not(.detail) .pane { display: none; }
    .pane .back-btn { display: inline-flex; }
}
@media (max-width: 560px) {
    .ctype .ctype-head { flex-wrap: wrap; padding: 6px; }
    .ctype-toggle { flex-basis: 100%; padding-left: 8px; flex-wrap: wrap; }
    .ctype-toggle .meta { margin-left: 26px; flex-basis: 100%; }
    .ctype .tools { margin-left: auto; }
    .field-row { grid-template-columns: minmax(0, 1fr); }
    .doc { grid-template-columns: minmax(0, 1fr) auto; }
    .doc .ico { display: none; }
    .stats .stat { min-width: 0; flex: 1 1 40%; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Editors see only the catalogue: no bottom bar, so no room kept for it. */
body.no-bottomnav main { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
body.no-bottomnav .toasts { bottom: calc(12px + env(safe-area-inset-bottom)); }
