:root {
  color-scheme: light;
  --ink: #17231f;
  --muted: #61706a;
  --line: #dce4df;
  --surface: #ffffff;
  --canvas: #f4f7f5;
  --nav: #152c24;
  --nav-soft: #24473b;
  --brand: #16785d;
  --brand-dark: #0f6049;
  --brand-pale: #e7f4ef;
  --amber: #9a650d;
  --amber-pale: #fff4d9;
  --red: #a23838;
  --red-pale: #fdeaea;
  --shadow: 0 12px 36px rgba(18, 43, 34, .07);
  font-family: Tahoma, Arial, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { background: var(--canvas); }
body { margin: 0; color: var(--ink); background: var(--canvas); line-height: 1.6; }
a { color: var(--brand-dark); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #6fbca5; outline-offset: 2px; }
.ltr, .mono { direction: ltr; unicode-bidi: isolate; }
.mono { font-family: Consolas, "Courier New", monospace; font-size: .92em; }
.muted { color: var(--muted); }
.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; }
.skip-link { position: fixed; z-index: 100; top: -60px; right: 16px; padding: 10px 16px; background: white; border-radius: 8px; }
.skip-link:focus { top: 12px; }
.sidebar { position: fixed; inset: 0 0 0 auto; width: 260px; padding: 24px 18px; background: var(--nav); color: white; display: flex; flex-direction: column; z-index: 20; }
.brand { display: flex; gap: 12px; align-items: center; padding: 0 8px 24px; border-bottom: 1px solid rgba(255,255,255,.12); }
.brand strong, .brand small { display: block; }
.brand small { color: #a9c4ba; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: #e5ba69; color: #27372f; font-weight: 800; font-size: 20px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.3); }
.brand-mark.large { width: 54px; height: 54px; border-radius: 15px; font-size: 28px; }
.sidebar nav { display: grid; gap: 5px; margin-top: 24px; }
.sidebar nav a { color: #d9e7e2; text-decoration: none; padding: 10px 13px; border-radius: 9px; font-weight: 600; }
.sidebar nav a:hover, .sidebar nav a.active { background: var(--nav-soft); color: white; }
.sidebar-footer { margin-top: auto; border-top: 1px solid rgba(255,255,255,.12); padding: 18px 8px 0; }
.user-summary { margin-bottom: 8px; }
.user-summary strong, .user-summary small { display: block; }
.user-summary small { color: #a9c4ba; }
.sidebar .link-button { color: #cae0d8; }
.app-shell { margin-right: 260px; min-height: 100vh; }
.topbar { min-height: 58px; padding: 0 32px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.9); display: flex; justify-content: flex-end; align-items: center; color: var(--muted); font-size: 13px; }
.nav-toggle { display: none; }
main { max-width: 1460px; margin: 0 auto; padding: 34px 38px 56px; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 26px; }
.page-heading h1 { margin: 2px 0 5px; font-size: clamp(25px, 3vw, 36px); letter-spacing: -.02em; }
.page-heading p { margin: 0; color: var(--muted); }
.eyebrow { color: var(--brand) !important; font-size: 13px; font-weight: 800; }
.heading-badges { display: flex; gap: 8px; align-items: center; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 22px; box-shadow: var(--shadow); margin-bottom: 22px; }
.panel.flush { padding: 0; overflow: hidden; }
.panel.flush .table-heading { padding: 17px 17px 0; }
.panel h2 { margin: 0 0 12px; font-size: 19px; }
.panel h3 { margin: 0 0 6px; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 18px; }
.section-heading h2, .section-heading p { margin: 0; }
.section-heading p { color: var(--muted); font-size: 14px; }
.metric-grid { display: grid; grid-template-columns: repeat(6, minmax(130px, 1fr)); gap: 12px; margin-bottom: 22px; }
.metric-grid article, .status-grid article { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 17px; }
.metric-grid span, .status-grid span { display: block; color: var(--muted); font-size: 13px; }
.metric-grid strong { display: block; font-size: 30px; margin-top: 7px; overflow-wrap: anywhere; }
.private-image-wrap { display: flex; justify-content: center; padding: 16px; background: #f5f7f8; border-radius: 12px; }
.private-image { display: block; max-width: 100%; max-height: 32rem; object-fit: contain; border-radius: 8px; }
.status-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.status-grid strong { display: block; font-size: 20px; margin: 7px 0; }
.status-grid small { color: var(--muted); }
.status-pill, .badge { display: inline-flex; align-items: center; width: fit-content; padding: 4px 9px; border-radius: 999px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.status-pill { background: #edf1ef; color: #41514a; }
.status-pill.ok, .badge.ready, .badge.verified, .success-text { background: var(--brand-pale); color: var(--brand-dark); }
.status-pill.danger, .badge.cannot_process, .badge.conflicted, .badge.revoked, .danger-text { background: var(--red-pale); color: var(--red); }
.badge.needs_review, .badge.candidate, .badge.superseded { background: var(--amber-pale); color: var(--amber); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 14px 15px; border-bottom: 1px solid #e7ece9; text-align: right; vertical-align: top; }
th { background: #f8faf9; color: #53635c; font-size: 12px; white-space: nowrap; }
tbody tr:hover { background: #fbfdfc; }
td small { display: block; color: var(--muted); margin-top: 3px; }
.message-cell { max-width: 320px; min-width: 210px; }
.line-chip { display: block; width: fit-content; margin: 2px 0; padding: 2px 7px; border: 1px solid var(--line); border-radius: 6px; }
.filter-bar, .form-grid { display: grid; grid-template-columns: 2fr repeat(3, 1fr) auto; gap: 12px; align-items: end; margin-bottom: 18px; }
label { display: grid; gap: 5px; color: #3e4d47; font-size: 13px; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid #bccac4; background: white; color: var(--ink); border-radius: 8px; padding: 9px 11px; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(22,120,93,.12); outline: 0; }
button, .button-link { border: 0; border-radius: 8px; padding: 9px 14px; cursor: pointer; font-weight: 800; text-decoration: none; display: inline-flex; justify-content: center; align-items: center; }
button:disabled { cursor: not-allowed; opacity: .48; }
.primary { background: var(--brand); color: white; }
.primary:hover { background: var(--brand-dark); }
.secondary { background: #edf3f0; color: #21483a; border: 1px solid #d4e1dc; }
.danger-button { background: var(--red-pale); color: var(--red); border: 1px solid #efcccc; }
.link-button { padding: 3px 0; background: transparent; color: var(--brand-dark); }
.full { width: 100%; }
.text-link, .back-link { font-weight: 700; text-decoration: none; }
.back-link { display: inline-block; margin-bottom: 7px; font-size: 13px; }
.notice, .form-error { padding: 12px 15px; border-radius: 9px; margin-bottom: 18px; }
.notice { background: var(--brand-pale); color: var(--brand-dark); border: 1px solid #cde5dc; }
.form-error { background: var(--red-pale); color: #7e2929; border: 1px solid #efcccc; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 18px; color: var(--muted); margin: 22px 0; }
.pagination a { font-weight: 800; text-decoration: none; }
.empty-state { padding: 55px 25px; text-align: center; color: var(--muted); }
.empty-state h3 { color: var(--ink); }
.empty-state.compact { padding: 22px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.detail-grid .span-2 { grid-column: 1 / -1; }
.source-message { margin: 0 0 18px; padding: 18px; background: #f7faf8; border: 1px solid var(--line); border-right: 4px solid var(--brand); border-radius: 8px; white-space: pre-wrap; overflow-wrap: anywhere; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0; }
.facts.compact { grid-template-columns: repeat(3, minmax(100px, 1fr)); }
.facts.vertical { grid-template-columns: 1fr; }
.facts div { padding: 9px 11px; background: #f7f9f8; border-radius: 8px; }
.facts dt { color: var(--muted); font-size: 12px; }
.facts dd { margin: 2px 0 0; font-weight: 700; overflow-wrap: anywhere; }
.candidate-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.candidate-grid article, .order-line { border: 1px solid var(--line); border-radius: 11px; padding: 16px; }
.candidate-grid small { display: block; color: var(--muted); }
.line-stack { display: grid; gap: 14px; }
.order-line header { display: flex; justify-content: space-between; margin-bottom: 10px; }
.evidence { display: block; padding: 7px 9px; border-right: 3px solid #a8c9bd; background: #f5f9f7; font-size: 13px; }
.issue-list { margin: 10px 0; padding-right: 22px; }
.issue-list li { margin: 6px 0; }
.warning-panel { border-right: 4px solid #d79b32; }
.alternatives { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.alternatives > div, .record-row { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid #edf0ee; }
.inline-form { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; margin-top: 12px; }
.inline-form label { min-width: 180px; flex: 1; }
.stack-form { display: grid; gap: 11px; }
.compact-form { max-width: 680px; }
.action-row { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 17px; }
.safety-note { margin-top: 15px; padding: 10px; background: #f7f9f8; color: var(--muted); border-radius: 7px; font-size: 13px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 19px 17px 0; border-right: 2px solid #dfe7e3; }
.timeline li::before { content: ""; position: absolute; right: -5px; top: 5px; width: 8px; height: 8px; background: var(--brand); border-radius: 50%; }
.timeline span { display: block; color: var(--muted); font-size: 12px; }
details summary { cursor: pointer; font-weight: 800; }
.creation-panel summary { font-size: 17px; }
.creation-panel .form-grid { margin: 18px 0 0; grid-template-columns: repeat(4, 1fr) auto; }
.quiet-panel { background: #f8faf9; box-shadow: none; }
.build-line { color: var(--muted); text-align: center; font-size: 12px; }
.inbox-filter { display: grid; grid-template-columns: minmax(220px, 2fr) repeat(4, minmax(130px, 1fr)) auto auto; gap: 10px; align-items: end; }
.inbox-layout { display: grid; grid-template-columns: minmax(230px, .72fr) minmax(360px, 1.25fr) minmax(300px, .9fr); gap: 16px; align-items: start; direction: rtl; }
.inbox-layout > * { min-width: 0; }
.inbox-conversations, .inbox-timeline { max-height: calc(100vh - 105px); overflow: auto; position: sticky; top: 16px; }
.conversation-list, .message-timeline, .generation-list { list-style: none; padding: 0; margin: 0; }
.conversation-list li + li { border-top: 1px solid var(--line); }
.conversation-card { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; padding: 12px 9px; color: var(--ink); text-decoration: none; border-radius: 9px; }
.conversation-card:hover, .conversation-card.selected { background: var(--brand-pale); }
.conversation-title { font-weight: 800; overflow-wrap: anywhere; }
.conversation-card time { color: var(--muted); font-size: 11px; }
.conversation-preview { color: var(--muted); font-size: 13px; grid-column: 1 / -1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conversation-card .badge { grid-column: 1 / -1; }
.conversation-header { display: flex; justify-content: space-between; gap: 12px; align-items: start; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.conversation-header h2, .conversation-header p { margin: 0; }
.message-timeline { display: grid; gap: 12px; padding-top: 18px; }
.message-row { display: flex; }
.message-row.inbound { justify-content: flex-start; }
.message-row.outbound, .message-row.echo { justify-content: flex-end; }
.message-row.system, .message-row.status { justify-content: center; }
.message-bubble { width: min(88%, 620px); padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: #f7faf8; overflow-wrap: anywhere; }
.message-bubble.outbound, .message-bubble.echo { background: #e8f4ef; border-bottom-left-radius: 4px; }
.message-bubble.inbound { background: white; border-bottom-right-radius: 4px; }
.message-bubble.system, .message-bubble.status { width: fit-content; background: #f1f2f2; color: var(--muted); }
.message-bubble header { display: flex; justify-content: space-between; gap: 14px; color: var(--muted); font-size: 11px; }
.message-original { white-space: pre-wrap; unicode-bidi: plaintext; font-size: 15px; margin: 9px 0; }
.message-thumbnail { display: block; max-width: 100%; max-height: 260px; object-fit: contain; border-radius: 9px; background: #eef2f0; }
.message-image-link { display: block; margin: 9px 0; }
.media-placeholder, .attachment-card { padding: 16px; border: 1px dashed #b8c6c0; border-radius: 9px; background: #f8faf9; color: var(--muted); }
.attachment-card { display: grid; gap: 3px; }
.message-bubble details { margin-top: 10px; font-size: 12px; }
.analysis-section { margin-bottom: 16px; }
.analysis-section .line-stack { margin-top: 12px; }
.danger-panel { border: 2px solid #d88484; }
.danger-callout { background: var(--red-pale); color: var(--red); padding: 12px; border-radius: 9px; }
.comparison-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.comparison-grid div { padding: 9px; border-radius: 8px; text-align: center; background: #f6f8f7; }
.comparison-grid dt { font-size: 11px; color: var(--muted); }
.comparison-grid dd { margin: 2px 0 0; font-size: 18px; font-weight: 800; }
.vision-summary + .vision-summary { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }
.generation-list { display: grid; gap: 8px; }
.generation-list li { display: grid; grid-template-columns: auto auto 1fr; gap: 8px; align-items: center; }
.generation-list small { color: var(--muted); text-align: left; }
.technical-details .facts { margin-top: 14px; }
.inbox-table td { overflow-wrap: anywhere; }
.inbox-pagination input { display: none; }
.user-actions { display: grid; gap: 8px; min-width: 190px; }
.error-card { max-width: 560px; margin: 9vh auto; padding: 40px; text-align: center; background: white; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.error-code { font: 800 46px/1 Consolas, monospace; color: #b4c0bb; }
.guest-shell { min-height: 100vh; background: radial-gradient(circle at top right, #e8f3ef 0, var(--canvas) 42%); }
.guest-main { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(430px, 100%); background: white; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 22px 60px rgba(20,50,40,.11); padding: 34px; }
.login-brand { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.login-card h1 { margin: 24px 0 2px; }
.login-note { color: var(--muted); font-size: 12px; text-align: center; margin: 19px 0 0; }
@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .status-grid { grid-template-columns: repeat(2, 1fr); }
  .filter-bar { grid-template-columns: repeat(2, 1fr); }
  .creation-panel .form-grid { grid-template-columns: repeat(2, 1fr); }
  .inbox-filter { grid-template-columns: repeat(3, 1fr); }
  .inbox-layout { grid-template-columns: minmax(220px, .7fr) minmax(380px, 1.3fr); }
  .inbox-analysis { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .inbox-analysis .panel { margin: 0; }
}
@media (max-width: 820px) {
  .sidebar { transform: translateX(110%); transition: transform .18s ease; box-shadow: -10px 0 30px rgba(0,0,0,.18); }
  body.nav-open .sidebar { transform: translateX(0); }
  .app-shell { margin-right: 0; }
  .topbar { justify-content: space-between; padding: 0 18px; }
  .nav-toggle { display: inline-flex; background: #edf3f0; color: var(--ink); padding: 6px 10px; }
  main { padding: 25px 18px 45px; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-grid .span-2 { grid-column: auto; }
  .page-heading { display: grid; }
  .facts { grid-template-columns: 1fr; }
  .inbox-layout { display: block; }
  .inbox-conversations, .inbox-timeline { position: static; max-height: none; }
  .inbox-conversations { margin-bottom: 16px; max-height: 320px; overflow: auto; }
  .inbox-analysis { display: block; }
  .inbox-analysis .panel { margin-bottom: 16px; }
  .inbox-filter { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .metric-grid, .status-grid, .filter-bar, .creation-panel .form-grid { grid-template-columns: 1fr; }
  .metric-grid article { display: flex; justify-content: space-between; align-items: center; }
  .metric-grid strong { font-size: 24px; margin: 0; }
  .panel { padding: 17px; border-radius: 11px; }
  .login-card { padding: 25px 20px; }
  .heading-badges { flex-wrap: wrap; }
  .inbox-filter { grid-template-columns: 1fr; }
  .message-bubble { width: 94%; }
  .message-bubble header { display: grid; gap: 2px; }
  .comparison-grid { grid-template-columns: repeat(2, 1fr); }
  .conversation-header { display: grid; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
