/* =========================================================================
 * pages.css — list windows, functional tabs, filter bar, record cards,
 * category tree, dashboard, reports.
 * ========================================================================= */

/* ------------------------------------------------ list window */
.list-ws { height: 100%; }
.list-head { flex: 0 0 auto; display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; border-bottom: 1px solid var(--line-strong); padding: 0 2px; margin-top: 2px; }
.lh-title { display: flex; align-items: center; gap: 8px; padding-bottom: 5px; }
.lh-title .bi { font-size: 17px; color: var(--primary); }
.lh-title h2 { font-size: 15px; font-weight: 700; margin: 0; }
.lh-count { font-size: 11px; color: var(--text-3); background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 0 7px; }
.fn-tabs { display: flex; gap: 2px; margin-inline-start: auto; overflow-x: auto; scrollbar-width: thin; }
.fn-tab {
  border: 1px solid var(--line); border-bottom: 0; background: var(--surface-3); color: var(--text-2); font-size: 12px; font-weight: 500; padding: 4px 10px;
  border-radius: 3px 3px 0 0; display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; position: relative; top: 1px;
}
.fn-tab .bi { font-size: 12px; }
.fn-tab .cnt { font-size: 10.5px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 0 5px; color: var(--text-2); min-width: 20px; text-align: center; }
.fn-tab:hover { background: var(--surface-2); color: var(--text); }
.fn-tab.active { background: var(--surface); color: var(--primary-700); font-weight: 700; border-color: var(--line-strong); box-shadow: inset 0 2px 0 var(--primary); }
.fn-tab.active .cnt { background: var(--primary); color: #fff; border-color: var(--primary); }
.filter-bar { flex: 0 0 auto; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 6px 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 5px 8px; box-shadow: var(--shadow-1); }
.fb-item { display: flex; flex-direction: column; gap: 1px; margin: 0; flex: 0 1 150px; min-width: 110px; }
.fb-item > span { font-size: 10.5px; color: var(--text-2); font-weight: 600; }
.list-main { flex: 1 1 auto; min-height: 260px; display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); }
.list-main.has-preview { grid-template-columns: minmax(0, 1fr) 330px; }
.list-grid { min-height: 0; display: flex; flex-direction: column; }
.list-grid .dg { flex: 1; }
.list-preview { overflow: auto; padding: 8px; min-height: 0; font-size: 12px; }
.lp-empty { display: grid; place-items: center; height: 100%; font-size: 30px; opacity: .3; }
.pv-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding-bottom: 6px; border-bottom: 1px solid var(--line-soft); margin-bottom: 6px; }
.pv-head b { font-size: 13px; }
.pv-sub { margin-bottom: 6px; font-weight: 600; }
.pv-sub small { color: var(--text-3); font-weight: 400; }
.pv-totals { width: 100%; margin-top: 6px; font-size: 12px; }
.pv-totals th { font-weight: 500; color: var(--text-2); padding: 1px 0; }
.pv-totals td { text-align: end; font-weight: 600; }
.pv-totals tr.g th, .pv-totals tr.g td { font-size: 13.5px; color: var(--primary-700); border-top: 1px solid var(--line); padding-top: 3px; }
.pv-kv { width: 100%; font-size: 12px; }
.pv-kv th { color: var(--text-3); font-weight: 500; padding: 2px 0; width: 42%; vertical-align: top; }
.pv-kv td { padding: 2px 0; font-weight: 500; }
.pv-section { font-size: 10.5px; font-weight: 700; color: var(--primary-700); text-transform: uppercase; letter-spacing: .03em; margin: 10px 0 3px; }
.list-summary { flex: 0 0 auto; display: flex; gap: 18px; flex-wrap: wrap; padding: 4px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); font-size: 12px; color: var(--text-2); }
.list-summary b { color: var(--text); }

/* ------------------------------------------------ record card */
.card-ws { height: 100%; }
.card-head { flex: 0 0 auto; display: flex; align-items: stretch; gap: 0; overflow: hidden; }
.ch-main { display: flex; align-items: center; gap: 10px; padding: 8px 12px; min-width: 0; flex: 1 1 auto; }
.ch-main > .monogram, .ch-icon { flex: none; }
.ch-icon { width: 44px; height: 44px; border-radius: 3px; background: var(--primary-50); border: 1px solid var(--primary-200); color: var(--primary); display: grid; place-items: center; font-size: 22px; }
.ch-text { min-width: 0; }
.ch-text h2 { font-size: 15.5px; font-weight: 700; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-sub { display: flex; align-items: center; gap: 8px; color: var(--text-3); font-size: 11.5px; flex-wrap: wrap; margin-top: 2px; }
.mode-badge { font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 2px; text-transform: uppercase; letter-spacing: .03em; }
.mode-view { background: var(--muted-bg); color: var(--text-2); border: 1px solid var(--muted-line); }
.mode-edit { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-line); }
.mode-new { background: var(--info-bg); color: var(--primary-700); border: 1px solid var(--primary-200); }
.ch-stats { display: flex; align-items: stretch; border-inline-start: 1px solid var(--line); flex: 0 1 auto; overflow-x: auto; }
.stat { display: flex; flex-direction: column; justify-content: center; padding: 6px 14px; border-inline-end: 1px solid var(--line-soft); min-width: 104px; background: var(--surface-2); white-space: nowrap; }
.stat:last-child { border-inline-end: 0; }
.stat span { font-size: 10.5px; color: var(--text-3); font-weight: 500; }
.stat b { font-size: 14px; font-variant-numeric: tabular-nums; }
.stat.good b { color: var(--ok); } .stat.bad b { color: var(--bad); } .stat.warn b { color: var(--warn); }
.card-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.card-tabs { display: flex; gap: 2px; padding: 0 8px; border-bottom: 1px solid var(--line-strong); background: var(--surface-2); overflow-x: auto; flex: 0 0 auto; border-radius: var(--radius) var(--radius) 0 0; padding-top: 5px; }
.ct-tab { border: 1px solid transparent; border-bottom: 0; background: transparent; padding: 4px 12px; font-size: 12.3px; color: var(--text-2); border-radius: 3px 3px 0 0; white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; position: relative; top: 1px; }
.ct-tab .bi { color: var(--primary); font-size: 12.5px; }
.ct-tab .cnt { font-size: 10px; background: var(--surface-3); border-radius: 8px; padding: 0 5px; color: var(--text-2); }
.ct-tab:hover { background: var(--surface); color: var(--text); }
.ct-tab.active { background: var(--surface); border-color: var(--line-strong); color: var(--text); font-weight: 700; box-shadow: inset 0 2px 0 var(--primary); }
.card-pane { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 12px; display: none; }
.card-pane.active { display: block; }
.card-pane.pane-grid { padding: 6px; }
.card-pane.pane-grid.active { display: flex; flex-direction: column; }
.card-pane.pane-grid .dg { flex: 1; min-height: 240px; }
.card-sections { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 16px; }
.card-sections .fieldset.wide { grid-column: 1 / -1; }
.card-ws.mode-view .card-sections .form-control, .card-ws.mode-view .card-sections .form-select { background: var(--surface-2); border-color: var(--line-soft); pointer-events: none; }
.card-ws.mode-view .card-sections .form-select { background-image: none; }
.card-ws.is-dirty .card-head { box-shadow: inset 0 -2px 0 #e0892b; }
.rel-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; margin-bottom: 12px; }
.rel-box { border: 1px solid var(--line); border-radius: 3px; background: var(--surface); padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; text-decoration: none !important; color: var(--text); position: relative; }
.rel-box:hover { border-color: var(--primary); background: var(--primary-50); color: var(--text); }
.rel-box .rb-l { font-size: 10.5px; color: var(--text-3); display: flex; align-items: center; gap: 5px; font-weight: 600; text-transform: uppercase; letter-spacing: .02em; }
.rel-box .rb-l .bi { color: var(--primary); font-size: 12px; }
.rel-box b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rel-box small { color: var(--text-2); font-size: 11px; }
.rel-diagram { display: flex; align-items: center; gap: 0; flex-wrap: wrap; margin-bottom: 12px; padding: 10px; background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: 3px; }
.rel-diagram .rd-node { background: var(--surface); border: 1px solid var(--line); border-radius: 3px; padding: 5px 10px; display: flex; flex-direction: column; min-width: 120px; text-decoration: none !important; color: var(--text); }
.rel-diagram .rd-node.center { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-100); }
.rel-diagram .rd-node span { font-size: 10px; color: var(--text-3); text-transform: uppercase; font-weight: 600; }
.rel-diagram .rd-node b { font-size: 12.5px; }
.rel-diagram .rd-link { width: 26px; height: 2px; background: var(--line-strong); position: relative; }
.rel-diagram .rd-link::after { content: ''; position: absolute; inset-inline-end: -1px; top: -3px; border: 4px solid transparent; border-inline-start-color: var(--line-strong); }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { display: grid; grid-template-columns: 130px 22px 1fr; align-items: center; gap: 6px; padding: 5px 0; }
.timeline .tl-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--primary); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--primary); justify-self: center; position: relative; }
.timeline li:not(:last-child) .tl-dot::after { content: ''; position: absolute; top: 12px; left: 3px; width: 2px; height: 22px; background: var(--primary-200); }
.timeline .tl-time { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-2); }
.timeline li.pending .tl-dot { background: var(--surface-3); box-shadow: 0 0 0 1px var(--line-strong); }
.timeline li.pending { color: var(--text-3); }
.logo-box { width: 64px; height: 64px; border: 1px dashed var(--line-strong); border-radius: 3px; display: grid; place-items: center; background: var(--surface-2); }
.perm-table td, .perm-table th { text-align: center !important; }
.perm-table td:first-child, .perm-table th:first-child { text-align: start !important; }

/* ------------------------------------------------ category tree */
.tree-layout { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: var(--gap); }
.tree-panel { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.tree-tools { display: flex; gap: 4px; padding: 5px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.tree-scroll { flex: 1; overflow: auto; padding: 4px 0; }
.tree { list-style: none; margin: 0; padding: 0; }
.tree .tree { padding-inline-start: 18px; }
.tn { display: flex; align-items: center; gap: 6px; padding: 3px 8px; cursor: pointer; border: 1px solid transparent; margin: 0 4px; border-radius: 2px; user-select: none; }
.tn:hover { background: var(--row-hover); }
.tn.on { background: var(--row-active); border-color: var(--primary-200); font-weight: 600; }
.tn .tw { width: 14px; color: var(--text-3); font-size: 10px; text-align: center; }
.tn .bi-folder2, .tn .bi-folder2-open, .tn .bi-tag { color: #c98a0c; }
.tn .tn-code { font-family: var(--font-mono); color: var(--text-3); font-size: 11px; }
.tn .tn-cnt { margin-inline-start: auto; font-size: 10.5px; color: var(--text-2); background: var(--surface-3); border-radius: 8px; padding: 0 6px; }
.tn.inactive { color: var(--text-3); text-decoration: line-through; }
li.collapsed > .tree { display: none; }
.tree-detail { display: flex; flex-direction: column; min-height: 0; gap: var(--gap); }

/* ------------------------------------------------ dashboard */
.dash-ws { gap: var(--gap); }
.dash-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 10px; box-shadow: var(--shadow-1); }
.dash-hello h2 { font-size: 15px; font-weight: 700; margin: 0; }
.dash-hello span { font-size: 11.5px; color: var(--text-3); }
.shortcuts { display: flex; flex-wrap: wrap; gap: 3px; margin-inline-start: auto; }
.sc { display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 76px; padding: 4px 6px; border: 1px solid transparent; border-radius: 3px; color: var(--text); text-decoration: none !important; font-size: 11.3px; text-align: center; position: relative; }
.sc .bi { font-size: 19px; color: var(--primary); }
.sc:hover { background: var(--primary-50); border-color: var(--primary-200); color: var(--text); }
.sc kbd { position: absolute; top: 1px; inset-inline-end: 1px; font-size: 9px; padding: 0 2px; }
.kpi-strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1); overflow: hidden; }
.kpi { display: grid; grid-template-columns: 26px 1fr auto; grid-template-rows: auto auto; column-gap: 8px; align-items: center; padding: 7px 12px; border-inline-end: 1px solid var(--line-soft); color: var(--text); text-decoration: none !important; }
.kpi:last-child { border-inline-end: 0; }
.kpi:hover { background: var(--row-hover); color: var(--text); }
.kpi .bi { grid-row: span 2; font-size: 20px; color: var(--primary); }
.kpi-l { font-size: 11.5px; color: var(--text-2); font-weight: 500; }
.kpi b { grid-row: span 2; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi small { font-size: 11px; color: var(--text-3); }
.kpi.warn .bi, .kpi.warn b { color: var(--warn); }
.kpi.bad .bi, .kpi.bad b { color: var(--bad); }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: var(--gap); flex: 1 1 auto; min-height: 0; }
.dp { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.dp header { display: flex; align-items: center; gap: 6px; padding: 5px 10px; background: linear-gradient(#f7f9fb, #edf1f5); border-bottom: 1px solid var(--line); font-weight: 700; font-size: 12.5px; }
.dp header .bi { color: var(--primary); }
.dp header a { margin-inline-start: auto; font-weight: 500; font-size: 11.5px; }
.dp-body { overflow: auto; max-height: 360px; }

/* ------------------------------------------------ reports */
.rpt-ws { height: 100%; }
.rpt-picker .dropdown-menu { max-height: 70vh; overflow: auto; }
.rpt-paper { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1); overflow: hidden; }
.rpt-head { flex: 0 0 auto; display: flex; align-items: center; gap: 14px; padding: 8px 12px; border-bottom: 2px solid var(--titlebar-2); flex-wrap: wrap; }
.rpt-head h2 { font-size: 16px; font-weight: 700; margin: 0; color: var(--titlebar); }
.rpt-head .rh-co { color: var(--text-2); font-size: 11.5px; }
.rpt-head .rh-meta { margin-inline-start: auto; text-align: end; font-size: 11.5px; color: var(--text-2); }
.rpt-kpis { flex: 0 0 auto; display: flex; border-bottom: 1px solid var(--line); overflow-x: auto; }
.rpt-kpis .stat { background: var(--surface); }
.rpt-grid { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.rpt-grid .dg { flex: 1; border: 0; border-radius: 0; box-shadow: none; }

/* ------------------------------------------------ settings */
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
