:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-subtle: #fafbfe;
  --line: #dde3ed;
  --line-strong: #cad3e1;
  --text: #172033;
  --muted: #6f7b8f;
  --muted-2: #9aa5b5;
  --primary: #3f5ee8;
  --primary-dark: #2f49c7;
  --primary-soft: #edf1ff;
  --green: #138a67;
  --green-soft: #e9f7f2;
  --orange: #c97612;
  --orange-soft: #fff3df;
  --red: #c74747;
  --red-soft: #fff0f0;
  --blue-soft: #edf4ff;
  --shadow: 0 18px 45px rgba(24, 37, 67, 0.14);
  --radius: 12px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { overflow: hidden; }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

.app-shell { height: 100vh; display: flex; flex-direction: column; }
.app-header {
  height: 64px;
  flex: 0 0 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand, .header-context, .title-line, .toolbar-actions, .view-controls, .period-control, .work-metrics, .legend, .agent-identity, .composer-footer { display: flex; align-items: center; }
.brand { gap: 11px; }
.brand-mark { width: 36px; height: 36px; border-radius: 11px; background: #172033; color: #fff; display: grid; place-items: center; font-weight: 800; }
.brand-name { font-size: 15px; font-weight: 750; letter-spacing: .01em; }
.brand-caption { margin-top: 2px; font-size: 11px; color: var(--muted); }
.header-context { gap: 10px; }
.context-chip { height: 38px; display: flex; align-items: center; gap: 8px; padding: 0 13px; background: var(--panel-subtle); border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.context-dot { width: 7px; height: 7px; background: var(--green); border-radius: 50%; }
.chevron { color: var(--muted); margin-left: 3px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: #e8edff; color: var(--primary-dark); font-weight: 700; }
.icon-button { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--line); background: var(--panel); border-radius: 9px; cursor: pointer; }
.icon-button:hover { background: var(--panel-subtle); }
.icon-button.compact { width: 30px; height: 30px; }

.main-shell { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.page-toolbar { min-height: 74px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 13px 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
.title-block { min-width: 260px; }
.title-line { gap: 10px; }
h1 { margin: 0; font-size: 22px; line-height: 1.2; letter-spacing: -.02em; }
.title-block p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.work-badge { padding: 4px 9px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-dark); font-size: 11px; font-weight: 700; }
.agent-badge { gap: 6px; padding: 4px 9px; border-radius: 999px; background: var(--green-soft); color: var(--green); font-size: 11px; font-weight: 700; }
.agent-badge > span { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.agent-badge.processing { background: var(--primary-soft); color: var(--primary); }
.agent-badge.processing > span { animation: pulse 1s infinite; }
.agent-badge.error { background: var(--red-soft); color: var(--red); }
@keyframes pulse { 50% { opacity: .25; } }
.toolbar-actions { gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.button { height: 38px; border-radius: 9px; padding: 0 15px; border: 1px solid transparent; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-weight: 650; font-size: 13px; cursor: pointer; white-space: nowrap; }
.button.primary { background: var(--primary); color: #fff; }
.button.primary:hover { background: var(--primary-dark); }
.button.secondary { background: var(--panel); border-color: var(--line-strong); }
.button.secondary:hover, .button.ghost:hover { background: var(--panel-subtle); }
.button.ghost { background: transparent; color: var(--muted); }
.button.small { height: 34px; padding: 0 12px; font-size: 12px; }
.button.danger { background: var(--red); color: #fff; }
.danger-text { color: var(--red) !important; }

.view-controls { min-height: 52px; padding: 8px 20px; gap: 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.period-control { gap: 5px; }
.period-button { height: 32px; min-width: 126px; border: 0; background: transparent; border-radius: 8px; font-weight: 650; cursor: pointer; }
.period-button:hover { background: var(--panel-subtle); }
.period-button span { color: var(--muted); margin-left: 6px; }
.control-spacer { flex: 1; }
.work-metrics { gap: 7px; }
.metric-chip { height: 34px; border: 1px solid var(--line); background: var(--panel); border-radius: 9px; padding: 0 11px; display: flex; gap: 8px; align-items: center; cursor: pointer; color: var(--muted); }
.metric-chip strong { color: var(--text); }
.metric-chip.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); }
.metric-chip.attention strong { color: var(--orange); }
.search-box { height: 34px; min-width: 250px; display: flex; align-items: center; gap: 7px; padding: 0 10px; background: var(--panel-subtle); border: 1px solid var(--line); border-radius: 9px; color: var(--muted); }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); }
.file-count-button { height: 34px; border: 0; background: transparent; color: var(--muted); display: flex; align-items: center; gap: 6px; cursor: pointer; }
.file-count-button:hover { color: var(--text); }
.file-stack-icon { color: var(--primary); }

.workspace { flex: 1; min-height: 0; display: flex; overflow: hidden; }
.workspace.work-active .journal-workspace { width: calc(100% - 360px); }
.journal-workspace { position: relative; width: 100%; min-width: 0; display: flex; flex-direction: column; background: var(--panel); transition: width .22s ease; }
.journal-summary-row { height: 38px; flex: 0 0 38px; display: flex; align-items: center; justify-content: space-between; padding: 0 18px; border-bottom: 1px solid var(--line); font-size: 11px; color: var(--muted); }
.journal-summary-row > div:first-child { display: flex; align-items: center; gap: 10px; }
.legend { gap: 12px; }
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; }
.legend-dot.evidence { background: #9aa6b8; }
.legend-dot.added { background: var(--green); }
.legend-dot.review { background: var(--orange); }
.journal-content { flex: 1; min-height: 0; position: relative; display: flex; overflow: hidden; }
.journal-list-pane { flex: 1; min-width: 0; overflow: hidden; background: var(--panel); transition: margin-right .22s ease; }
.journal-workspace.detail-open .journal-list-pane { margin-right: min(455px, 43%); }
.table-wrap { height: 100%; overflow: auto; }
.journal-table { width: 100%; min-width: 950px; border-collapse: collapse; table-layout: fixed; }
.journal-table thead { position: sticky; top: 0; z-index: 3; background: #f9fafc; }
.journal-table th { height: 38px; padding: 0 10px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 10px; font-weight: 650; text-align: left; white-space: nowrap; }
.journal-table td { height: 55px; padding: 7px 10px; border-bottom: 1px solid #e8ecf2; font-size: 12px; vertical-align: middle; }
.journal-table tbody tr { cursor: pointer; }
.journal-table tbody tr:hover { background: #f9fbff; }
.journal-table tbody tr.selected { background: #f2f5ff; box-shadow: inset 3px 0 var(--primary); }
.journal-table .state-column { width: 82px; }

.journal-workspace.normal-mode .journal-table .state-column,
.journal-workspace.normal-mode .journal-table th:first-child,
.journal-workspace.normal-mode .journal-table td:first-child { display: none; }

.journal-table th:nth-child(2) { width: 72px; }
.journal-table th:nth-child(3) { width: 260px; }
.journal-table th:nth-child(4), .journal-table th:nth-child(5) { width: 130px; }
.journal-table th:nth-child(6) { width: 110px; }
.journal-table th:nth-child(7) { width: 105px; }
.journal-table th:nth-child(8) { width: 90px; }
.amount-cell { text-align: right !important; }
.party-title { font-weight: 700; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.party-subtitle { margin-top: 3px; color: var(--muted); font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-statuses { display: flex; align-items: flex-start; flex-direction: column; gap: 3px; }
.status-pill { width: fit-content; padding: 3px 6px; border-radius: 6px; font-size: 9px; font-weight: 700; white-space: nowrap; }
.status-pill.added { background: var(--green-soft); color: var(--green); }
.status-pill.modified { background: var(--primary-soft); color: var(--primary-dark); }
.status-pill.removed { background: var(--red-soft); color: var(--red); }
.status-pill.review { background: var(--orange-soft); color: var(--orange); }
.status-placeholder { color: var(--muted-2); }
.evidence-pill { display: inline-flex; align-items: center; padding: 4px 7px; border-radius: 6px; background: #eef2f6; color: #657186; font-size: 9px; white-space: nowrap; }
.tax-label { color: var(--muted); font-size: 10px; }
.empty-state { height: 100%; display: grid; place-items: center; align-content: center; gap: 8px; color: var(--muted); font-size: 12px; }
.empty-icon { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--panel-subtle); border: 1px solid var(--line); }

.journal-detail { position: absolute; z-index: 5; top: 0; bottom: 0; right: 0; width: min(455px, 43%); transform: translateX(101%); background: var(--panel); border-left: 1px solid var(--line); box-shadow: -12px 0 28px rgba(30, 43, 70, .08); transition: transform .22s ease; display: flex; flex-direction: column; }
.journal-workspace.detail-open .journal-detail { transform: translateX(0); }
.detail-header { min-height: 69px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 15px; border-bottom: 1px solid var(--line); }
.detail-header h2 { margin: 4px 0 0; font-size: 16px; }
.section-label { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .04em; }
.detail-content { flex: 1; overflow: auto; padding: 15px; }
.detail-section { padding: 14px 0; border-bottom: 1px solid var(--line); }
.detail-section:first-child { padding-top: 0; }
.detail-section:last-child { border-bottom: 0; }
.detail-section-title { margin-bottom: 10px; font-size: 11px; font-weight: 750; }
.detail-grid { display: grid; grid-template-columns: 115px 1fr; gap: 9px 12px; font-size: 11px; }
.detail-grid dt { color: var(--muted); }
.detail-grid dd { margin: 0; font-weight: 550; }
.journal-lines { border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.journal-line { display: grid; grid-template-columns: 50px 1fr 100px; gap: 9px; align-items: center; min-height: 41px; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 11px; }
.journal-line:last-child { border-bottom: 0; }
.journal-line-side { color: var(--muted); }
.journal-line-amount { text-align: right; font-variant-numeric: tabular-nums; }
.applied-rule { padding: 10px; background: var(--panel-subtle); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 7px; }
.applied-rule:last-child { margin-bottom: 0; }
.applied-rule-name { font-size: 11px; font-weight: 700; }
.applied-rule-scope { margin-top: 4px; color: var(--muted); font-size: 9px; }
.issue-box { padding: 10px; border-radius: 8px; background: var(--orange-soft); color: #92570d; font-size: 11px; line-height: 1.55; }
.evidence-preview { min-height: 122px; display: grid; place-items: center; border: 1px dashed var(--line-strong); border-radius: 9px; background: linear-gradient(145deg, #fbfcfe, #f1f4f8); color: var(--muted); text-align: center; font-size: 10px; }
.diff-row { display: grid; grid-template-columns: 62px 1fr; gap: 9px; margin-bottom: 7px; font-size: 11px; }
.diff-label { color: var(--muted); }
.diff-old { text-decoration: line-through; color: var(--red); }
.diff-new { color: var(--green); font-weight: 650; }

.rules-panel { position: absolute; z-index: 8; left: 0; right: 0; bottom: 0; height: 58px; background: var(--panel); border-top: 1px solid var(--line); box-shadow: 0 -9px 22px rgba(32, 44, 70, .04); transition: height .24s ease; overflow: hidden; }
.rules-panel.open { height: min(390px, 58%); box-shadow: 0 -18px 40px rgba(24, 37, 67, .13); }
.rules-handle { width: 100%; height: 58px; padding: 0 18px; border: 0; background: var(--panel); display: flex; align-items: center; justify-content: space-between; text-align: left; cursor: pointer; }
.rules-summary { margin-top: 4px; color: var(--muted); font-size: 10px; }
.rules-toggle { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; }
.rules-panel.open .rules-toggle { transform: rotate(180deg); }
.rules-panel.open .rules-toggle span { visibility: hidden; }
.rules-content { height: calc(100% - 58px); padding: 0 18px 18px; overflow: auto; }
.rules-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 14px; }
.rules-toolbar h3 { margin: 0; font-size: 14px; }
.rules-toolbar p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.rules-list-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.rule-legend { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; color: var(--muted); font-size: 9px; }
.rule-legend span { display: inline-flex; align-items: center; gap: 5px; }
.rule-legend-swatch { width: 12px; height: 12px; border-radius: 4px; border: 1px solid var(--line); background: var(--panel); }
.rule-legend-swatch.added { background: #eef3ff; border-color: #b8c7ff; }
.rule-legend-swatch.modified { background: #fff8e7; border-color: #f0d38b; }
.rule-legend-swatch.suggested { background: #f4f0ff; border-color: #cfc1ff; }
.rule-search { width: 240px; height: 34px; display: flex; align-items: center; gap: 6px; padding: 0 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.rule-search span { color: var(--muted); }
.rule-search input { width: 100%; border: 0; outline: 0; font-size: 10px; }
.rule-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.rule-card { padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); cursor: pointer; transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease; }
.rule-card:hover { border-color: #b7c0d0; box-shadow: 0 7px 18px rgba(32, 44, 70, .07); transform: translateY(-1px); }
.rule-card.added { background: #f3f6ff; border-color: #b9c7ff; }
.rule-card.modified { background: #fff9eb; border-color: #efd28b; }
.rule-card.suggested { background: #f6f2ff; border-color: #cabdff; }
.rule-card.is-disabled { opacity: .64; }
.rule-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.rule-name { font-size: 11px; font-weight: 750; }
.rule-meta { margin-top: 4px; color: var(--muted); font-size: 8px; }
.rule-status { flex: 0 0 auto; padding: 3px 7px; border-radius: 999px; font-size: 8px; font-weight: 750; background: #eef1f6; color: #556276; }
.rule-status.enabled { background: var(--green-soft); color: var(--green); }
.rule-status.added { background: #dfe7ff; color: #4558ac; }
.rule-status.modified { background: #fff0c7; color: #8b6414; }
.rule-status.suggested { background: #e8e0ff; color: #6548b7; }
.rule-status.disabled { background: #eceef2; color: #6d7582; }
.rule-logic { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: stretch; gap: 8px; margin-top: 10px; }
.rule-logic-block { min-width: 0; padding: 9px; border: 1px solid rgba(137, 150, 172, .22); border-radius: 8px; background: rgba(255, 255, 255, .62); }
.rule-logic-label { margin-bottom: 6px; color: var(--muted); font-size: 8px; font-weight: 750; }
.rule-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.rule-chip { display: inline-flex; max-width: 100%; padding: 4px 6px; border-radius: 6px; font-size: 8px; line-height: 1.35; overflow-wrap: anywhere; }
.rule-chip.condition { background: #eef1f6; color: #4a566a; }
.rule-chip.action { background: #e9f6ef; color: #28754e; }
.rule-arrow { align-self: center; color: var(--muted-2); font-size: 15px; }
.rule-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 9px; }
.rule-impact { color: var(--muted); font-size: 8px; }
.rule-actions { display: flex; gap: 6px; }
.rule-empty { grid-column: 1 / -1; padding: 24px; border: 1px dashed var(--line); border-radius: 9px; color: var(--muted); text-align: center; font-size: 10px; }
.mini-button { height: 29px; padding: 0 9px; border: 1px solid var(--line); background: var(--panel); border-radius: 7px; font-size: 10px; font-weight: 650; cursor: pointer; }
.mini-button.accept { border-color: var(--primary); background: var(--primary); color: #fff; }

.agent-pane { flex: 0 0 360px; width: 360px; min-width: 360px; background: #f8faff; border-left: 1px solid var(--line); display: flex; flex-direction: column; }
.agent-header { height: 63px; flex: 0 0 63px; display: flex; align-items: center; justify-content: space-between; padding: 0 13px; background: var(--panel); border-bottom: 1px solid var(--line); }
.agent-identity { gap: 10px; }
.agent-avatar { width: 34px; height: 34px; border-radius: 10px; background: #172033; color: #fff; display: grid; place-items: center; font-weight: 750; }
.agent-name { font-size: 12px; font-weight: 750; }
.agent-substatus { margin-top: 3px; color: var(--muted); font-size: 9px; }
.tool-button { font-size: 14px; }
.agent-overview { min-height: 57px; display: grid; grid-template-columns: repeat(3, 1fr); background: var(--panel); border-bottom: 1px solid var(--line); }
.overview-item { padding: 10px 9px; border-right: 1px solid var(--line); }
.overview-item:last-child { border-right: 0; }
.overview-item span { display: block; color: var(--muted); font-size: 8px; white-space: nowrap; }
.overview-item strong { display: block; margin-top: 4px; font-size: 15px; }
.overview-item.attention strong { color: var(--orange); }
.agent-timeline { flex: 1; min-height: 0; overflow: auto; padding: 13px; display: flex; flex-direction: column; gap: 10px; }
.timeline-empty { margin: auto; max-width: 230px; text-align: center; color: var(--muted); font-size: 11px; line-height: 1.7; }
.timeline-empty-icon { width: 42px; height: 42px; margin: 0 auto 10px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.timeline-item { display: grid; grid-template-columns: 22px 1fr; gap: 8px; }
.timeline-icon { width: 22px; height: 22px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-size: 9px; font-weight: 800; }
.timeline-item.user .timeline-icon { background: #e9edf4; color: #536176; }
.timeline-item.success .timeline-icon { background: var(--green-soft); color: var(--green); }
.timeline-content { min-width: 0; }
.timeline-title { font-size: 11px; font-weight: 700; line-height: 1.4; }
.timeline-copy { margin-top: 3px; color: var(--muted); font-size: 9px; line-height: 1.55; }
.tool-call-card { margin-top: 7px; padding: 8px 9px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.tool-call-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tool-call-name { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px; }
.tool-call-status { color: var(--green); font-size: 8px; font-weight: 700; }
.tool-call-meta { margin-top: 5px; color: var(--muted); font-size: 8px; line-height: 1.5; }
.agent-composer { flex: 0 0 auto; padding: 10px 11px; background: var(--panel); border-top: 1px solid var(--line); }
.agent-composer textarea { width: 100%; resize: none; border: 0; outline: 0; color: var(--text); min-height: 60px; }
.composer-footer { justify-content: space-between; gap: 10px; }
.composer-footer > span { color: var(--muted-2); font-size: 8px; }
.send-button { height: 32px; padding: 0 13px; border: 0; border-radius: 8px; background: var(--primary); color: #fff; font-size: 11px; font-weight: 700; cursor: pointer; }
.selection-context { display: flex; align-items: center; gap: 4px; margin-bottom: 7px; padding: 7px 8px; background: var(--primary-soft); color: var(--primary-dark); border-radius: 7px; font-size: 9px; }
.selection-context strong { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selection-context button { border: 0; background: transparent; cursor: pointer; }

.modal-layer { position: fixed; z-index: 50; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(20, 28, 44, .42); backdrop-filter: blur(2px); }
.modal-card { width: min(720px, calc(100vw - 40px)); max-height: calc(100vh - 48px); overflow: hidden; background: var(--panel); border-radius: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.file-modal-card { width: min(680px, calc(100vw - 40px)); }
.transaction-modal-card { width: min(900px, calc(100vw - 40px)); }
.medium-modal-card { width: min(600px, calc(100vw - 40px)); }
.small-modal-card { width: min(440px, calc(100vw - 40px)); }
.tool-modal-card { width: min(740px, calc(100vw - 40px)); }
.modal-header { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 17px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 4px 0 0; font-size: 18px; }
.modal-footer { min-height: 64px; display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 17px; border-top: 1px solid var(--line); }
.modal-copy { padding: 18px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.dropzone { margin: 18px; min-height: 210px; border: 1.5px dashed #aab5c8; border-radius: 12px; background: #fafbfe; display: grid; place-items: center; align-content: center; padding: 25px; text-align: center; cursor: pointer; }
.dropzone.dragging { border-color: var(--primary); background: var(--primary-soft); }
.dropzone-icon { width: 45px; height: 45px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-size: 20px; }
.dropzone-title { margin-top: 12px; font-size: 14px; font-weight: 700; }
.dropzone-caption { margin: 6px 0 14px; color: var(--muted); font-size: 10px; }
.pending-files, .work-file-list { padding: 0 18px 18px; display: grid; gap: 7px; overflow: auto; }
.pending-file, .work-file-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 11px; border: 1px solid var(--line); border-radius: 9px; }
.file-main { min-width: 0; }
.file-name { font-size: 11px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { margin-top: 3px; color: var(--muted); font-size: 9px; }
.file-status { padding: 3px 7px; border-radius: 999px; background: var(--green-soft); color: var(--green); font-size: 9px; font-weight: 700; }
.file-status.processing { background: var(--primary-soft); color: var(--primary); }
.file-remove { border: 0; background: transparent; color: var(--muted); cursor: pointer; }

.transaction-modal-body { display: grid; grid-template-columns: 230px 1fr; min-height: 460px; overflow: hidden; }
.transaction-usecases { padding: 13px; background: #f7f9fc; border-right: 1px solid var(--line); overflow: auto; }
.usecase-button { width: 100%; display: flex; align-items: center; gap: 9px; padding: 10px; margin-bottom: 5px; border: 1px solid transparent; background: transparent; border-radius: 9px; text-align: left; cursor: pointer; }
.usecase-button:hover { background: var(--panel); }
.usecase-button.active { background: var(--panel); border-color: #bdc8ff; box-shadow: 0 4px 12px rgba(42, 58, 96, .05); }
.usecase-icon { width: 31px; height: 31px; border-radius: 8px; display: grid; place-items: center; background: #eef1f7; color: #526076; font-size: 13px; }
.usecase-button.active .usecase-icon { background: var(--primary-soft); color: var(--primary); }
.usecase-name { display: block; font-size: 11px; font-weight: 700; }
.usecase-caption { display: block; margin-top: 3px; color: var(--muted); font-size: 8px; }
.transaction-form { padding: 20px; overflow: auto; }
.form-heading { margin-bottom: 16px; }
.form-heading h3 { margin: 0; font-size: 16px; }
.form-heading p { margin: 5px 0 0; color: var(--muted); font-size: 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 10px; font-weight: 650; }
.field input, .field select, .field textarea { width: 100%; min-height: 38px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--panel); outline: 0; color: var(--text); font-size: 11px; }
.field textarea { resize: vertical; min-height: 75px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.form-note { padding: 10px; border-radius: 8px; background: #f5f7fb; color: var(--muted); font-size: 9px; line-height: 1.6; }

.rule-modal-card { width: min(880px, calc(100vw - 40px)); }
.rule-editor-body { padding: 18px; overflow: auto; }
.rule-form-section + .rule-form-section { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.rule-basic-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.rule-enabled-field { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; font-size: 10px; }
.rule-form-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.rule-form-heading h3 { margin: 0; font-size: 13px; }
.rule-form-heading p { margin: 4px 0 0; color: var(--muted); font-size: 9px; line-height: 1.5; }
.rule-builder { display: grid; gap: 7px; }
.rule-builder-row { display: grid; gap: 7px; align-items: center; }
.rule-builder-row.condition-row { grid-template-columns: 1.1fr 1fr 1.5fr 28px; }
.rule-builder-row.action-row { grid-template-columns: 1fr 1.7fr 28px; }
.rule-builder-row select, .rule-builder-row input { width: 100%; min-height: 37px; padding: 7px 9px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--panel); color: var(--text); font-size: 10px; }
.rule-builder-row select:disabled, .rule-builder-row input:disabled, .rule-basic-grid input:disabled, .rule-basic-grid select:disabled { background: #f6f7fa; color: #5d6879; }
.builder-remove { width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); color: var(--muted); cursor: pointer; }
.builder-remove:hover { color: var(--danger); border-color: #efb4b4; }
.rule-conflict-note { margin-top: 15px; padding: 10px 11px; border-radius: 8px; background: #f5f7fb; color: var(--muted); font-size: 9px; line-height: 1.6; }
.rule-modal-footer { justify-content: flex-start; }
.modal-footer-spacer { flex: 1; }

.agent-architecture { padding: 18px; background: #f8faff; border-bottom: 1px solid var(--line); }
.architecture-node { padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); text-align: center; font-size: 10px; font-weight: 650; }
.main-node { width: 180px; margin: 0 auto 20px; border-color: #aebaff; background: var(--primary-soft); color: var(--primary-dark); position: relative; }
.main-node::after { content: ""; position: absolute; left: 50%; top: 100%; width: 1px; height: 20px; background: var(--line-strong); }
.architecture-branches { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; position: relative; }
.tool-list { padding: 15px 18px 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 9px; overflow: auto; }
.tool-item { padding: 11px; border: 1px solid var(--line); border-radius: 9px; }
.tool-name { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; font-weight: 700; color: var(--primary-dark); }
.tool-description { margin-top: 6px; color: var(--muted); font-size: 9px; line-height: 1.55; }
.tool-availability { margin-top: 8px; font-size: 8px; color: var(--green); }

.complete-summary { padding: 18px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.complete-stat { padding: 13px; background: var(--panel-subtle); border: 1px solid var(--line); border-radius: 9px; }
.complete-stat span { color: var(--muted); font-size: 9px; }
.complete-stat strong { display: block; margin-top: 6px; font-size: 20px; }
.completion-note { margin: 0 18px 18px; padding: 11px; border-radius: 8px; background: var(--primary-soft); color: #4052a1; font-size: 10px; line-height: 1.6; }

.toast { position: fixed; z-index: 80; left: 50%; bottom: 24px; transform: translate(-50%, 18px); padding: 10px 14px; border-radius: 9px; background: #182033; color: #fff; font-size: 11px; opacity: 0; pointer-events: none; transition: .2s ease; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1100px) {
  .workspace.work-active .journal-workspace { width: calc(100% - 320px); }
  .agent-pane { width: 320px; min-width: 320px; flex-basis: 320px; }
  .search-box { min-width: 190px; }
  .toolbar-actions .button { padding: 0 10px; }
}

@media (max-width: 820px) {
  body { overflow: auto; }
  .app-shell { min-height: 100vh; height: auto; }
  .header-context .context-chip { display: none; }
  .page-toolbar { align-items: flex-start; flex-direction: column; }
  .toolbar-actions { width: 100%; justify-content: flex-start; }
  .view-controls { flex-wrap: wrap; }
  .control-spacer { display: none; }
  .search-box { flex: 1; min-width: 200px; }
  .workspace { min-height: 760px; }
  .workspace.work-active { display: block; overflow: visible; }
  .workspace.work-active .journal-workspace { width: 100%; min-height: 580px; }
  .agent-pane { width: 100%; min-width: 0; height: 580px; border-left: 0; border-top: 1px solid var(--line); }
  .transaction-modal-body { grid-template-columns: 1fr; }
  .transaction-usecases { display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .usecase-button { min-width: 185px; }
  .rule-list { grid-template-columns: 1fr; }
  .rules-list-toolbar { align-items: stretch; flex-direction: column; }
  .rule-search { width: 100%; }
  .rule-builder-row.condition-row, .rule-builder-row.action-row { grid-template-columns: 1fr; }
  .builder-remove { justify-self: end; }
}
