/* ==========================================
   Expenses (UI-04), approved Graphite. Loaded after graphite.css and transactions.css.
   Page pieces only, every rule under .ex or an ex-* class; colours come from the --g-* tokens so Dark and Light
   follow the released palette on <html data-theme>. Shared sd-* pieces that graphite.css colours for Dark only
   get a Light rule here, scoped to this page.
   ========================================== */


:root, [data-theme="dark"] {
    --ex-info: #a9c7d8; --ex-skin: #18191c; --ex-fig-line: #383639;
    --c-ServerVps: #eeb39d; --c-Proxy: #a9c7d8; --c-Software: #9bc8b7; --c-AccountEmail: #e2ba91; --c-Labor: #c3b4dc; --c-Other: #8f8d95;
}
[data-theme="light"] {
    --ex-info: #2c5f7c; --ex-skin: #ffffff; --ex-fig-line: var(--g-line);
    --c-ServerVps: #a8553a; --c-Proxy: #2c5f7c; --c-Software: #2f7a5c; --c-AccountEmail: #8a5410; --c-Labor: #6b559a; --c-Other: #6f6e75;
}

.ex { max-width: 1480px; margin: 0 auto; font-size: 14px; line-height: 1.5; color: var(--g-text); }
.ex .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.ex :is(.ex-fig-value, td.n, .ex-panel-amount, .sd-facts dd, .sd-pager, .ex-cats-legend b, .ex-imp-summary strong) { font-variant-numeric: tabular-nums; }
.ex-missing { color: var(--g-muted); font-style: normal; }
.ex-dim, .ex .dim { color: var(--g-muted); }
.ex-ge { color: var(--g-muted); font-weight: 400; }
.ex-warn-text { color: var(--g-warn); }
.ex .ok { color: var(--g-ok); } .ex .bad { color: var(--g-bad); } .ex .warn { color: var(--g-warn); }


/* ---- Head ---- */
.ex-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.ex-head-main { min-width: 0; }
.ex-head h1 { margin: 6px 0 0; font-size: 33px; font-weight: 550; line-height: 1.2; letter-spacing: -1.2px; outline: none; }
.ex-sub { margin-top: 7px; font-size: 12.5px; color: var(--g-muted); }
.ex-ro { display: inline-flex; align-items: center; gap: 5px; color: var(--g-text-2); }
.ex-ro svg:not([width]) { width: 13px; height: 13px; }
.ex-head-actions { display: flex; align-items: center; gap: 8px; flex: none; flex-wrap: wrap; justify-content: flex-end; }
.ex-head-actions .g-btn { height: 38px; }
.ex-head-actions .g-icon-btn { width: 38px; height: 38px; }
.ex-head-actions .g-btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.ex-head-actions .g-btn > svg:last-child:not(:first-child) { width: 13px; height: 13px; margin-left: -2px; opacity: .7; }
.ex-btn-primary { border: 1px solid var(--g-coral-line); background: var(--g-coral-bg); color: var(--g-coral-ink); font-weight: 500; }
.ex-btn-primary:hover:not(:disabled) { border-color: var(--g-coral); }
.ex-btn-primary:disabled { opacity: .55; cursor: default; }
.ex-btn-danger { border: 1px solid var(--g-bad); background: var(--g-bad-bg); color: var(--g-bad); }
.ex-link { display: inline-flex; align-items: center; gap: 5px; padding: 4px 2px; border: 0; background: none; color: var(--g-coral-ink); font-size: 12.5px; cursor: pointer; }
.ex-link:hover { text-decoration: underline; }
.ex-link svg:not([width]) { width: 14px; height: 14px; }

/* Import menu (contextual: template + file live together) */
.ex-pop-wrap { position: relative; }
.ex-menu { position: absolute; top: calc(100% + 6px); right: 0; z-index: 40; display: grid; gap: 2px; min-width: 250px; padding: 6px; border: 1px solid var(--g-line); border-radius: 11px; background: var(--g-raised); box-shadow: 0 18px 50px #0006; }
[data-theme="light"] .ex-menu { box-shadow: 0 18px 50px #0002; }
.ex-menu button { display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 8px; background: none; text-align: left; cursor: pointer; font-size: 13px; color: var(--g-text); }
.ex-menu button:hover, .ex-menu button:focus-visible { background: var(--g-hover); outline: none; }
.ex-menu button svg:not([width]) { width: 16px; height: 16px; margin-top: 2px; color: var(--g-muted); flex: none; }
.ex-menu small { display: block; font-size: 11.5px; color: var(--g-muted); }

/* ---- Period + filters ---- */
.ex-filters { display: grid; gap: 8px; margin-bottom: 16px; }
.ex-filter-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 12px; }
.ex-input { height: 36px; padding: 0 9px; border: 1px solid var(--g-line); border-radius: 8px; background: var(--ex-skin); color: var(--g-text); font-size: 13px; color-scheme: dark; }
[data-theme="light"] .ex-input { color-scheme: light; }
textarea.ex-input { height: auto; padding: 8px 9px; resize: vertical; }
.ex-input:focus { outline: 2px solid var(--g-coral); outline-offset: 0; border-color: transparent; }
.ex-input[aria-invalid="true"] { border-color: var(--g-bad); }
.ex-periods button { height: 30px; }
.ex-range { display: flex; align-items: center; gap: 8px; }
.ex-range label { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--g-muted); }
.ex-range .g-btn { height: 36px; }
.ex-field-inline { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--g-muted); white-space: nowrap; }
.ex-field-inline select { max-width: 190px; }
.ex-scope { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin: 0; font-size: 12.5px; color: var(--g-muted); }
.ex-scope b { color: var(--g-text); font-weight: 550; }
.ex-scope-note { display: inline-flex; align-items: center; gap: 5px; color: var(--g-warn); }
.ex-scope-note svg:not([width]) { width: 13px; height: 13px; }

/* ---- Balance (period figures) ---- */
.ex-bal { border: 1px solid var(--g-line); border-radius: 13px; background: linear-gradient(113deg, #272527 0%, #1e1f22 57%, #1b1c1f 100%); box-shadow: var(--g-shadow); overflow: hidden; }
[data-theme="light"] .ex-bal { background: var(--g-panel); }
.ex-bal-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 14px 22px 0; }
.ex-bal-head h2 { margin: 0; font-size: 13px; font-weight: 550; color: var(--g-text-2); letter-spacing: 0; }
.ex-bal-head .ov-source-btn { margin-left: auto; padding: 6px 10px; }
.ex-bal-sub { margin: 4px 22px 0; font-size: 11.5px; color: var(--g-muted); }
.ex-bal-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 14px 22px 18px; }
.ex-fig { min-width: 0; padding: 0 20px; border-left: 1px solid var(--ex-fig-line); display: flex; flex-direction: column; gap: 4px; }
.ex-fig:first-child { padding-left: 0; border-left: 0; }
.ex-fig-label { font-size: 12.5px; color: var(--g-text-2); }
.ex-fig-value { font-size: 27px; font-weight: 500; letter-spacing: -.8px; line-height: 1.2; white-space: nowrap; }
.ex-fig-value .ex-ge { font-size: 20px; letter-spacing: 0; }
.ex-fig.ok .ex-fig-value { color: var(--g-ok); }
.ex-fig.bad .ex-fig-value { color: var(--g-bad); }
.ex-fig.warn .ex-fig-value { color: var(--g-warn); }
.ex-fig-lines { margin: 4px 0 0; font-size: 12px; }
.ex-fig-lines > div { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; }
.ex-fig-lines dt { color: var(--g-muted); min-width: 0; }
.ex-fig-lines dd { margin: 0; color: var(--g-text-2); text-align: right; white-space: nowrap; }
.ex-fig-lines dd small { color: var(--g-muted); font-size: 11.5px; }
.ex-cats { display: grid; grid-template-columns: minmax(160px, 260px) minmax(0, 1fr); align-items: center; gap: 10px 22px; padding: 12px 22px; border-top: 1px solid var(--ex-fig-line); background: #1415184f; }
[data-theme="light"] .ex-cats { background: #f5f2ee; }
.ex-cats-bar { display: flex; gap: 2px; height: 8px; border-radius: 4px; overflow: hidden; }
.ex-cats-bar i { display: block; min-width: 3px; background: var(--c); }
.ex-cats-legend { display: flex; flex-wrap: wrap; gap: 4px 6px; margin: 0; padding: 0; list-style: none; }
.ex-cats-legend button { display: inline-flex; align-items: baseline; gap: 6px; padding: 4px 8px; border: 1px solid transparent; border-radius: 7px; background: none; font-size: 12px; color: var(--g-text-2); cursor: pointer; }
.ex-cats-legend button:hover { border-color: var(--g-line); background: var(--g-hover); }
.ex-cats-legend i { width: 8px; height: 8px; border-radius: 2px; background: var(--c); align-self: center; }
.ex-cats-legend b { font-weight: 550; color: var(--g-text); }
.ex-cats-legend small { color: var(--g-muted); font-size: 11px; }
.ex .c-ServerVps { --c: var(--c-ServerVps); } .ex .c-Proxy { --c: var(--c-Proxy); } .ex .c-Software { --c: var(--c-Software); }
.ex .c-AccountEmail { --c: var(--c-AccountEmail); } .ex .c-Labor { --c: var(--c-Labor); } .ex .c-Other { --c: var(--c-Other); }
.ex-bal-note { display: flex; align-items: flex-start; gap: 8px; margin: 0; padding: 9px 22px; border-top: 1px solid var(--ex-fig-line); font-size: 12px; line-height: 1.5; color: var(--g-text-2); }
.ex-bal-note svg:not([width]) { width: 15px; height: 15px; flex: none; margin-top: 1px; }
.ex-bal-note.warn svg:not([width]) { color: var(--g-warn); }
.ex-bal-note.bad { color: var(--g-bad); }
.ex-bal-note.info svg:not([width]) { color: var(--ex-info); }
.ex-imp-result + .ex-bal-note, .ex-modal .ex-bal-note { padding: 8px 0; border-top: 0; }
.ex-bal-state { display: flex; align-items: flex-start; gap: 12px; margin: 14px 22px 18px; padding: 14px 16px; border: 1px solid var(--g-line); border-radius: 10px; font-size: 12.5px; color: var(--g-text-2); }
.ex-bal-state svg:not([width]) { width: 18px; height: 18px; flex: none; color: var(--ex-info); margin-top: 1px; }
.ex-bal-state > div { flex: 1; }
.ex-bal-state strong { display: block; color: var(--g-text); font-weight: 550; }
.ex-bal-state p { margin: 3px 0 0; color: var(--g-muted); }
.ex-bal-state.warn { border-color: var(--g-warn); background: var(--g-warn-bg); } .ex-bal-state.warn svg:not([width]) { color: var(--g-warn); }
.ex-bal-state.bad { border-color: var(--g-bad); background: var(--g-bad-bg); } .ex-bal-state.bad svg:not([width]) { color: var(--g-bad); }

/* ---- Work area (tabs + table + panel) ---- */
.ex .sd-work { margin-top: 18px; }
.ex-work-col { min-width: 0; }
.ex-tabs { margin: 0 0 12px; }
.ex-tab-n { margin-left: 2px; padding: 0 6px; border-radius: 9px; background: #ffffff10; font-size: 11.5px; color: var(--g-muted); }
[data-theme="light"] .ex-tab-n { background: #0000000c; }
.ex-view-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px; margin-bottom: 10px; }
.ex-view-text { margin: 0; flex: 1 1 260px; font-size: 12.5px; color: var(--g-muted); }
.ex-view-text b { color: var(--g-text); font-weight: 600; }
.ex-list-bar .sd-search { flex: 1 1 280px; max-width: 420px; height: 36px; }
.ex-list-bar .sd-search button { display: grid; padding: 2px; border: 0; border-radius: 5px; background: none; color: var(--g-muted); cursor: pointer; }
.ex-view-hint { font-size: 11.5px; color: var(--g-muted); }
.ex-list-bar + .ex-view-text { margin: 0 0 10px; }
.ex-check { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--g-text-2); cursor: pointer; white-space: nowrap; }
.ex-check input { width: 15px; height: 15px; accent-color: var(--g-coral); }
.ex .sd-table-wrap .sd-scroll { position: relative; }
.ex-table { min-width: 760px; }
.ex .sd-work.has-panel .ex-table { min-width: 680px; }
.ex-table td .sub { display: block; font-size: 11.5px; color: var(--g-muted); }
.ex-table td.n .sub { text-align: right; }
.ex-table td.m-cell { display: none; }
.ex-table .sub.m-only { display: none; }
.ex-day { display: inline-flex; align-items: baseline; gap: 6px; font-weight: 500; }
.ex-day small { font-size: 11.5px; color: var(--g-muted); font-weight: 400; }
.ex-q { display: inline-block; margin-left: 8px; padding: 0 6px; border-radius: 5px; border: 1px solid currentColor; font-size: 10.5px; line-height: 16px; letter-spacing: .2px; vertical-align: 1px; }
.ex-q.partial { color: var(--g-warn); border-color: #554331; background: var(--g-warn-bg); }
.ex-q.good { color: var(--g-ok); border-color: #34463e; background: #23302b; }
[data-theme="light"] .ex-q.partial { border-color: #e2c89e; }
[data-theme="light"] .ex-q.good { border-color: #a8d3c0; background: #e2f1ea; }
.ex-cost { color: var(--g-warn); }
.ex-fee { color: var(--g-text-2); }
.ex-amt { font-weight: 550; color: var(--g-text); }
.ex-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--g-text-2); white-space: nowrap; }
.ex-chip i { width: 8px; height: 8px; border-radius: 2px; background: var(--c); }
.ex-voided td { color: var(--g-muted) !important; }
.ex-voided .ex-amt { text-decoration: line-through; color: var(--g-muted); }
.ex-actions-cell { width: 76px; white-space: nowrap; }
.ex-row-btn { display: inline-grid; place-items: center; width: 28px; height: 28px; border: 1px solid transparent; border-radius: 7px; background: none; color: var(--g-muted); cursor: pointer; }
.ex-row-btn:hover { border-color: var(--g-line); color: var(--g-text); }
.ex-row-btn.danger:hover { border-color: var(--g-bad); color: var(--g-bad); }
.ex-row-btn svg:not([width]) { width: 15px; height: 15px; }
.ex-table tfoot td { height: 40px; padding: 6px 12px; border-top: 1px solid var(--g-line); font-size: 12.5px; color: var(--g-muted); white-space: nowrap; background: var(--g-panel); }
.ex-table tfoot td.n { color: var(--g-text-2); }
.ex-reconcile { display: flex; gap: 8px; align-items: flex-start; margin: 10px 2px 0; font-size: 12px; line-height: 1.5; color: var(--g-muted); }
.ex-reconcile svg:not([width]) { width: 15px; height: 15px; flex: none; margin-top: 1px; color: var(--ex-info); }
.ex-gap { padding: 0 4px; color: var(--g-muted); }
.ex-ps select { height: 30px; margin-left: 6px; border: 1px solid var(--g-line); border-radius: 7px; background: var(--ex-skin); color: var(--g-text); padding: 0 6px; }
.ex .sd-pager button svg:not([width]) { width: 14px; height: 14px; }
.ex .sd-pager button { display: inline-grid; place-items: center; }
.ex-inline-empty { margin-top: 4px; border: 1px solid var(--g-line); border-radius: 11px; }
.ex-empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 12px; }
.ex-empty-actions .g-btn svg:not([width]) { width: 15px; height: 15px; }
.ex-skel-table { margin-top: 18px; padding: 6px 0; }
.ex-skel-row { display: flex; gap: 24px; align-items: center; height: 46px; padding: 0 16px; border-bottom: 1px solid var(--g-line-soft); }

/* ---- Side panel ---- */
.ex .sd-work.has-panel { grid-template-columns: minmax(0, 1fr) 360px; }
.ex-panel-top { display: flex; align-items: center; gap: 8px; padding-top: 12px; }
.ex-panel-top .ex-q { margin-left: 0; }
.ex-panel-top .sd-tag { margin-left: 0; }
.ex-panel-amount { margin: 10px 0 2px; font-size: 28px; font-weight: 500; letter-spacing: -.8px; }
.ex-panel-amount small { font-size: 12px; color: var(--g-muted); letter-spacing: 0; }
.ex-panel .sd-facts dd a { color: var(--g-coral-ink); text-decoration: none; }
.ex-panel .sd-facts dd small { color: var(--g-muted); font-size: 11.5px; margin-left: 4px; }
.ex-panel h4 small { margin-left: 4px; color: var(--g-muted); font-weight: 400; }
.ex-notes { margin: 0; font-size: 13px; color: var(--g-text-2); }
.ex-back { margin-top: 10px; padding-left: 0; }
.ex-day-list { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.ex-day-list button { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 1px solid var(--g-line-soft); border-radius: 9px; background: none; text-align: left; cursor: pointer; font-size: 12.5px; }
.ex-day-list button:hover { background: var(--g-hover); border-color: var(--g-line); }
.ex-day-list .ex-chip { font-size: 11.5px; }
.ex-day-what { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--g-text); }
.ex-day-what small { display: block; color: var(--g-muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
.ex-day-list button { color: var(--g-text); }
.ex-day-list b { font-weight: 550; color: var(--g-text); }
.ex-empty-note { margin: 0; font-size: 12.5px; color: var(--g-muted); }
.ex-panel .sd-panel-foot .g-btn { height: 34px; }
.ex-panel .sd-panel-foot .g-btn svg:not([width]) { width: 15px; height: 15px; }

/* ---- Modals ---- */
.ex-modal.wide { width: min(780px, calc(100vw - 32px)); }
.ex-modal .g-modal-body h3:first-of-type { margin-top: 18px; }
.ex-modal .sd-recon td small { line-height: 1.5; }
.ex-scope-table th { padding: 6px 8px; font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .5px; color: var(--g-muted); text-align: left; }
.ex-scope-table td small { display: block; font-size: 11px; color: var(--g-muted); }
.ex-list-notes { margin: 0; padding-left: 18px; font-size: 12.5px; line-height: 1.6; color: var(--g-text-2); }
.ex-modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.ex-modal-foot > span { margin-right: auto; font-size: 11.5px; line-height: 1.5; }
.ex-modal-foot .g-btn { height: 36px; }
.ex-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.ex-form.one { grid-template-columns: 1fr; margin: 10px 0; }
.ex-form .full, .ex-form .ex-form-error { grid-column: 1 / -1; }
.ex-form label { display: grid; gap: 5px; font-size: 12.5px; color: var(--g-text-2); }
.ex-form .ex-input { width: 100%; }
.ex-err { font-size: 12px; color: var(--g-bad); }
.ex-form-error { display: flex; gap: 8px; align-items: center; margin: 0; color: var(--g-bad); font-size: 12.5px; }
.ex-form-error svg:not([width]) { width: 15px; height: 15px; }
.ex-sim, .ex-sim-note { color: var(--g-warn); font-size: 11.5px; }
.ex-sim { padding: 1px 6px; border: 1px dashed currentColor; border-radius: 5px; }
.ex-sim-note { display: flex; gap: 8px; align-items: flex-start; margin: 0; padding: 8px 10px; border: 1px dashed var(--g-warn); border-radius: 8px; line-height: 1.5; }
.ex-sim-note svg:not([width]) { width: 15px; height: 15px; margin-top: 1px; flex: none; }
.ex-modal p { line-height: 1.55; }
/* Import */
.ex-drop { position: relative; display: flex; align-items: center; gap: 14px; padding: 16px 18px; border: 1px dashed var(--g-coral-line); border-radius: 11px; background: var(--g-coral-bg); cursor: pointer; }
.ex-drop:hover, .ex-drop:focus-within { border-color: var(--g-coral); }
.ex-drop > svg:not([width]) { width: 22px; height: 22px; color: var(--g-coral-ink); flex: none; }
.ex-drop b { display: block; color: var(--g-coral-ink); font-weight: 550; }
.ex-drop small { display: block; color: var(--g-muted); font-size: 12px; }
.ex-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.ex-drop:focus-within { outline: 2px solid var(--g-coral); outline-offset: 2px; }
.ex-imp-help { margin-top: 14px; font-size: 12.5px; color: var(--g-text-2); }
.ex-imp-help p { margin: 0 0 6px; }
.ex-imp-result { display: flex; gap: 12px; align-items: flex-start; margin-top: 14px; padding: 12px 14px; border: 1px solid var(--g-line); border-radius: 10px; font-size: 12.5px; }
.ex-imp-result > svg:not([width]) { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.ex-imp-result strong { display: block; font-weight: 550; }
.ex-imp-result p { margin: 6px 0 0; color: var(--g-text-2); }
.ex-imp-result.bad { border-color: var(--g-bad); background: var(--g-bad-bg); } .ex-imp-result.bad > svg:not([width]), .ex-imp-result.bad strong { color: var(--g-bad); }
.ex-imp-result.ok { border-color: #34463e; background: #23302b; } .ex-imp-result.ok > svg:not([width]), .ex-imp-result.ok strong { color: var(--g-ok); }
[data-theme="light"] .ex-imp-result.ok { border-color: #a8d3c0; background: #e2f1ea; }
.ex-imp-errors { margin: 8px 0 0; padding-left: 18px; color: var(--g-text); line-height: 1.6; }
.ex-imp-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 14px; border: 1px solid var(--g-line); border-radius: 10px; }
.ex-imp-summary > div { display: grid; gap: 2px; padding: 10px 14px; border-left: 1px solid var(--g-line-soft); }
.ex-imp-summary > div:first-child { border-left: 0; }
.ex-imp-summary span { font-size: 11.5px; color: var(--g-muted); }
.ex-imp-summary strong { font-size: 17px; font-weight: 500; }
.ex-imp-preview { margin-top: 10px; overflow-x: auto; border: 1px solid var(--g-line-soft); border-radius: 9px; }
.ex-mini { width: 100%; min-width: 520px; font-size: 12.5px; }
.ex-mini th { padding: 7px 10px; text-align: left; font-size: 11px; font-weight: 500; letter-spacing: .6px; text-transform: uppercase; color: var(--g-muted); border-bottom: 1px solid var(--g-line); white-space: nowrap; }
.ex-mini td { padding: 7px 10px; border-bottom: 1px solid var(--g-line-soft); white-space: nowrap; }
.ex-mini tr:last-child td { border-bottom: 0; }
.ex-mini :is(th, td).n { text-align: right; }

.ex-toast { position: fixed; left: 50%; bottom: 24px; z-index: 95; transform: translateX(-50%); max-width: min(600px, calc(100vw - 32px)); padding: 10px 14px; border: 1px solid var(--g-line); border-radius: 10px; background: var(--g-raised); color: var(--g-text); font-size: 13px; box-shadow: 0 12px 40px #0005; }

/* ---- Light: shared sd-* pieces that graphite.css only colours for Dark ---- */
[data-theme="light"] .ex .sd-panel-head, [data-theme="light"] .ex .sd-panel-foot { border-color: var(--g-line); }
[data-theme="light"] .ex .sd-panel-foot { background: var(--g-panel); }
[data-theme="light"] .ex .sd-facts > div { border-bottom-color: var(--g-line-soft); }
[data-theme="light"] .ex .sd-facts dt { color: var(--g-muted); }
[data-theme="light"] .ex .sd-alert { border-color: var(--g-bad); }
[data-theme="light"] .ex .sd-pager button { color: var(--g-text-2); }
[data-theme="light"] .ex .sd-table td.primary { color: var(--g-text); }
[data-theme="light"] .ex .sd-table tbody tr[aria-selected="true"] td { background: var(--g-select); }
[data-theme="light"] .ex .sd-table tbody tr { border-bottom-color: var(--g-line-soft); }

/* ---- Responsive ---- */
@media (max-width: 1360px) {
    .ex .sd-work.has-panel { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1150px) {
    .ex-bal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 18px; }
    .ex-fig:nth-child(3) { padding-left: 0; border-left: 0; }
    .ex-cats { grid-template-columns: 1fr; }
    .ex-head { align-items: flex-start; flex-direction: column; gap: 14px; }
    .ex-head-actions { justify-content: flex-start; }
    .ex-table .opt-panel { display: none; }
    .ex-table, .ex .sd-work.has-panel .ex-table { min-width: 640px; }
}
@media (max-width: 720px) {
    .ex-head h1 { font-size: 28px; letter-spacing: -1px; }
    .ex-head-actions { width: 100%; }
    .ex-head-actions > .g-btn, .ex-pop-wrap { flex: 1 1 auto; }
    .ex-head-actions .g-btn { justify-content: center; }
    .ex-pop-wrap .g-btn { width: 100%; }
    .ex-menu { left: 0; right: auto; }
    .ex-periods { width: 100%; }
    .ex-range { flex-wrap: wrap; width: 100%; }
    .ex-range label { flex: 1 1 140px; }
    .ex-range .ex-input { flex: 1; min-width: 0; }
    .ex-filter-row > * { min-width: 0; max-width: 100%; }
    .ex-field-inline { flex: 1 1 100%; min-width: 0; }
    .ex-field-inline select { flex: 1 1 0; width: 0; max-width: none; min-width: 0; }
    .ex-field-inline > span, .ex-field-inline { white-space: nowrap; }
    .ex-bal-head { padding: 14px 16px 0; }
    .ex-bal-head .ov-source-btn { margin-left: 0; }
    .ex-bal-sub { margin: 4px 16px 0; }
    .ex-bal-grid { grid-template-columns: 1fr; padding: 10px 16px 12px; row-gap: 0; }
    .ex-fig, .ex-fig:nth-child(3) { padding: 12px 0; border-left: 0; border-top: 1px solid var(--ex-fig-line); }
    .ex-fig:first-child { border-top: 0; padding-top: 4px; }
    .ex-fig-value { font-size: 24px; }
    .ex-cats, .ex-bal-note { padding-left: 16px; padding-right: 16px; }
    .ex-cats-legend { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ex-cats-legend button { width: 100%; flex-wrap: wrap; padding: 4px 2px; }
    .ex-table td.m-right .sub.m-only { display: block; }
    .ex-bal-state { margin: 12px 16px 14px; }
    .ex-tabs { width: 100%; }
    .ex-list-bar .sd-search { flex: 1 1 100%; max-width: none; }
    .ex-view-hint { display: none; }
    /* Table → list rows (graphite.css sd-table phone rules); every field stays in the panel and the CSV. */
    .ex-table, .ex .sd-work.has-panel .ex-table { min-width: 0; }
    .ex-table td.m-cell.m-show { display: block; }
    .ex-table tfoot { display: none; }
    .ex-table td.m-title .ex-q { margin-left: 6px; }
    .ex-imp-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ex-imp-summary > div:nth-child(3) { border-left: 0; }
    .ex-imp-summary > div:nth-child(n+3) { border-top: 1px solid var(--g-line-soft); }
    .ex-imp-preview .ex-table { min-width: 0; }
    .ex .sd-pager { flex-direction: column; align-items: stretch; }
    .ex .sd-pager-btns { flex-wrap: wrap; }
    .ex-form { grid-template-columns: 1fr; }
}
