/* Organization shell follows the light personal workspace in workspace-shell.css. */
@font-face {
    font-family: Chainy;
    src: url("/_assets/fonts/drukwidecyr-medium.5d44df0044cfab83.woff2") format('woff2');
    font-display: swap;
}
:root {
    color-scheme: light;
    --ink: #20292e;
    --muted: #56666e;
    --line: #dce3e6;
    --canvas: #f6f8f8;
    --accent: #b4dc55;
    --accent-ink: #23310f;
    --soft: #ecf4df;
    --surface-soft: #eff3f3;
    --white: #fff;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); font: 14px/1.5 Arial, Helvetica, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button, a, input, select { outline-offset: 3px; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid #547128; }
button { cursor: pointer; min-height: 40px; border: 1px solid #84939b; border-radius: 6px; background: white; color: var(--ink); padding: 9px 14px; font-weight: 600; }
button:hover { background: var(--surface-soft); }
button:disabled { cursor: wait; opacity: .6; }
a { color: #354e21; text-underline-offset: 3px; }
.primary { background: var(--accent); color: var(--accent-ink); border-color: #a4c94b; }
.primary:hover { background: #a8cf4e; }
.danger { color: #993d32; border-color: #c79a92; }
.quiet { border-color: transparent; background: transparent; padding: 7px 10px; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 10; padding: 12px; background: white; color: var(--ink); transform: translateY(-200%); }
.skip-link:focus { transform: none; }
.shell { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100dvh; }
.rail { position: sticky; top: 0; height: 100dvh; background: white; border-right: 1px solid var(--line); padding: 20px 12px 18px; display: flex; flex-direction: column; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; font: 21px/1 Chainy, sans-serif; letter-spacing: -.03em; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand-symbol { display: grid; place-items: center; width: 32px; height: 32px; flex: 0 0 32px; border-radius: 50%; background: var(--accent); color: var(--ink); }
.brand-symbol svg { width: 24px; height: 24px; }
.rail-caption { align-self: flex-start; color: var(--muted); font-size: 12px; margin: 19px 8px 22px; }
nav { display: grid; gap: 6px; }
nav button { display: flex; align-items: center; gap: 12px; min-height: 44px; border: 0; background: transparent; color: var(--muted); text-align: left; padding: 11px 12px; font-weight: 500; }
nav button svg { flex: 0 0 18px; width: 18px; height: 18px; stroke-width: 1.8; }
nav button[aria-current] { background: var(--soft); color: #2a4613; font-weight: 600; }
nav button:hover { background: var(--surface-soft); color: var(--ink); }
.rail-bottom { margin-top: auto; padding: 16px 0 0; border-top: 1px solid var(--line); display: grid; gap: 4px; }
.rail-bottom a { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 8px 12px; color: var(--muted); font-size: 12px; text-decoration: none; border-radius: 6px; }
.rail-bottom a:hover { background: var(--surface-soft); color: var(--ink); }
.rail-bottom svg { width: 16px; height: 16px; flex-shrink: 0; }
.workspace { min-width: 0; display: flex; flex-direction: column; }
header { background: white; border-bottom: 1px solid var(--line); min-height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 10px 32px; gap: 16px; }
.workspace-picker, .environment-picker { display: flex; align-items: center; gap: 10px; min-width: 0; }
.workspace-picker { flex-wrap: wrap; }
header label { font-size: 12px; color: var(--muted); margin-bottom: 0; }
select, input { padding: 10px 12px; min-height: 42px; border: 1px solid #84939b; border-radius: 6px; background: white; color: var(--ink); min-width: 0; }
input::placeholder { color: #65727a; opacity: 1; }
header select { min-height: 36px; padding: 7px 10px; font-size: 13px; font-weight: 600; max-width: 250px; }
#workspace-actions { width: 36px; min-height: 36px; padding: 0; font-size: 20px; font-weight: 400; }
#load-organizations { font-size: 12px; }
.environment-note { display: flex; align-items: center; gap: 8px; padding: 9px 40px; background: #f0f5e7; border-bottom: 1px solid #dce6ce; color: #35491c; font-size: 12px; }
.environment-note::before { content: ''; width: 6px; height: 6px; background: #6a862f; border-radius: 50%; flex-shrink: 0; }
.environment-note.live { background: white; border-bottom-color: var(--line); color: var(--ink); }
.environment-note.live::before { background: #2b7754; }
main { padding: 36px 40px 56px; max-width: 1540px; width: 100%; margin: 0 auto; flex: 1; }
.pagehead { display: flex; justify-content: space-between; gap: 20px; align-items: center; margin-bottom: 28px; }
#context { margin: 0 0 8px; }
h1 { font-size: 32px; letter-spacing: -.035em; line-height: 1.2; margin: 0 0 10px; font-weight: 600; }
h2 { font-size: 18px; letter-spacing: -.02em; margin: 0; font-weight: 600; }
h3 { font-size: 15px; margin: 0 0 14px; }
p { margin: 7px 0; color: var(--muted); max-width: 76ch; }
.subtle { font-size: 12px; color: var(--muted); }
.panel { min-width: 0; border: 1px solid var(--line); background: white; border-radius: 10px; margin-bottom: 24px; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); padding: 20px 24px; }
.panel-body { padding: 24px; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: white; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 28px; }
.metric { padding: 22px 24px; border-right: 1px solid var(--line); }
.metric:last-child { border: 0; }
.metric strong { font-weight: 600; font-size: 32px; letter-spacing: -.035em; display: block; margin: 8px 0 4px; }
.metric span { color: var(--muted); font-size: 13px; }
.split { display: grid; align-items: start; grid-template-columns: minmax(0, 1.8fr) minmax(250px, 1fr); gap: 24px; }
.split > * { min-width: 0; }
.table-wrap { overflow: auto; overscroll-behavior-x: contain; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13px; }
th { font-size: 12px; color: #53616a; font-weight: 600; background: #f3f6f7; }
td, th { padding: 14px 20px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { padding-block: 12px; }
tbody tr:last-child td { border-bottom: 0; }
.row-link { color: #354e21; background: none; border: 0; min-height: 32px; padding: 0; text-align: left; }
.address { font-variant-numeric: tabular-nums; font-size: 12px; }
tr[data-check-row] { cursor: pointer; }
tr[data-check-row]:hover, tr[data-check-row]:focus-within { background: #f0f4f5; }
.badge { display: inline-block; padding: 4px 8px; border-radius: 4px; font-size: 11px; font-weight: 500; white-space: nowrap; background: #eff3f3; color: #45565e; }
.badge.completed { background: #e8f2df; color: #34561e; }
.badge.failed { background: #f9e9e6; color: #913b30; }
.badge.processing, .badge.reconciliation_required { background: #fcf1d9; color: #785313; }
.empty { padding: 40px 24px; text-align: center; color: var(--muted); }
.empty h3 { margin-bottom: 8px; }
.empty p { margin-inline: auto; }
.toolbar { display: flex; gap: 12px; margin-bottom: 18px; }
.toolbar input { flex: 1; }
.toolbar select { max-width: 230px; }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 16px; }
form label input, form label select { font-size: 14px; font-weight: 400; color: var(--ink); width: 100%; }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) 180px; gap: 0 20px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.note { background: #f0f5e7; color: #35491c; padding: 14px 16px; border: 1px solid #d6e2c1; border-radius: 6px; font-size: 13px; margin-bottom: 20px; }
.error, #notice { padding: 14px 16px; border: 1px solid #d6e2c1; background: #f0f5e7; color: #35491c; border-radius: 6px; margin-bottom: 20px; }
.error, #notice.error { background: #f9e9e6; border-color: #e2c4bd; color: #8d352c; }
.definition { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 12px; border-bottom: 1px solid var(--line); padding: 15px 0; }
.definition:last-child { border: 0; }
.definition span { color: var(--muted); }
.definition strong { font-weight: 500; overflow-wrap: anywhere; }
.queue-row { display: flex; justify-content: space-between; gap: 16px; padding: 15px 0; border-bottom: 1px solid var(--line); }
.queue-row:last-child { border: 0; }
.queue-row strong { font-size: 20px; font-weight: 500; }
.inline-actions { display: flex; gap: 8px; align-items: center; }
.inline-actions select { max-width: 150px; }
.daily { display: flex; align-items: flex-end; height: 112px; gap: 5px; border-bottom: 1px solid var(--line); margin: 20px 0 8px; }
.daily div { flex: 1; background: #a5c96a; min-height: 3px; max-width: 50px; }
.usage-total { font-size: 36px; font-weight: 600; line-height: 1.2; letter-spacing: -.035em; margin-bottom: 8px; font-variant-numeric: tabular-nums; }
.usage-empty { margin-top: 20px; font-size: 13px; }
.risk-score { font-size: 60px; line-height: 1.2; letter-spacing: -3px; margin: 12px 0; color: var(--ink); }
.risk-score small { font-size: 20px; color: var(--muted); letter-spacing: 0; }
.risk-list { padding-left: 20px; }
.risk-list li { margin: 12px 0; overflow-wrap: anywhere; }
code, pre { font: 12px/1.8 ui-monospace, SFMono-Regular, monospace; overflow-wrap: anywhere; }
pre { white-space: pre-wrap; background: #f3f6f7; padding: 18px; border-radius: 6px; }
footer { border-top: 1px solid var(--line); padding: 17px 40px; display: flex; justify-content: space-between; gap: 20px; color: var(--muted); font-size: 12px; }
dialog { padding: 0; border: 1px solid var(--line); border-radius: 12px; width: min(550px, calc(100% - 28px)); max-height: 92dvh; overflow: auto; box-shadow: 0 20px 60px #182c3a26; color: var(--ink); background: white; }
dialog::backdrop { background: #14212c66; }
.dialog-head { padding: 20px 24px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.dialog-body { padding: 24px; }
.drawer { margin: 0 0 0 auto; height: 100dvh; max-height: 100dvh; width: min(580px, 100%); border-radius: 12px 0 0 12px; }
.drawer .dialog-head { position: sticky; top: 0; background: white; z-index: 1; }
hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }
.pagination { padding: 15px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.pagination .subtle { margin-right: auto; }
[hidden] { display: none !important; }
@media (max-width: 1199px) {
    header { padding-inline: 20px; }
    main { padding: 28px; }
    .environment-note { padding-inline: 28px; }
    .split { grid-template-columns: minmax(0, 1fr); }
    .metric { padding: 18px; }
    .metric strong { font-size: 29px; }
}
@media (max-width: 900px) and (min-width: 721px) {
    header { align-items: flex-start; flex-direction: column; gap: 8px; }
    .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .metric:nth-child(2) { border-right: 0; }
    .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}
@media (max-width: 720px) {
    .shell { display: block; }
    .rail { position: static; height: auto; padding: 16px; gap: 16px; overflow: visible; border-right: 0; border-bottom: 1px solid var(--line); }
    .brand { padding: 0; }
    .rail-caption { position: absolute; right: 16px; top: 22px; font-size: 11px; margin: 0; }
    nav { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
    nav button { justify-content: center; flex-direction: column; gap: 5px; min-height: 58px; padding: 8px 2px; font-size: 12px; }
    .rail-bottom { margin: 0; padding: 0; border: 0; }
    .rail-bottom a { padding: 0; min-height: 24px; }
    .rail-bottom a + a { display: none; }
    header { padding: 14px 16px; flex-wrap: wrap; gap: 12px; min-height: 0; }
    .workspace-picker { width: 100%; }
    .workspace-picker select { flex: 1; max-width: none; }
    .environment-picker { justify-content: space-between; width: 100%; }
    .environment-note { padding: 9px 16px; }
    main { padding: 24px 16px 40px; }
    .pagehead { align-items: flex-start; gap: 12px; }
    h1 { font-size: 28px; }
    .pagehead .primary { padding: 9px 10px; white-space: nowrap; font-size: 13px; }
    .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .metric:nth-child(2) { border-right: 0; }
    .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
    .form-grid { grid-template-columns: minmax(0, 1fr); }
    .form-grid .wide { grid-column: auto; }
    .toolbar { flex-wrap: wrap; }
    .toolbar input { min-width: 100%; }
    .panel-head, .panel-body { padding: 16px; }
    .panel-head { align-items: flex-start; flex-wrap: wrap; }
    td, th { padding-inline: 14px; }
    .definition { grid-template-columns: 1fr; gap: 3px; }
    footer { padding: 16px; flex-direction: column; gap: 5px; }
    .dialog-body, .dialog-head { padding: 20px; }
    .inline-actions { flex-wrap: wrap; }
}
@media (max-width: 360px) {
    .rail-caption { position: static; align-self: auto; margin: -8px 0 0; }
    .workspace-picker { gap: 6px; }
    .workspace-picker > label { width: 100%; }
    .pagehead { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

.workspace-mode { display:flex; flex:0 0 auto; gap:2px; padding:3px; border:1px solid var(--line); border-radius:7px; }
.workspace-mode a { padding:5px 9px; border-radius:4px; color:var(--muted); text-decoration:none; font-size:13px; }
.workspace-mode a[aria-current] { background:#ecf4df; color:#2a4613; font-weight:600; }
@media(max-width:700px) { header .workspace-mode { align-self:flex-start; } header { flex-wrap:wrap; } }

.recovery-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 12px; margin-top: 18px; }
