:root {
  --ink: #182322;
  --muted: #66716f;
  --paper: #f4f1ea;
  --surface: #fffdf8;
  --line: #dcd8ce;
  --teal: #145b56;
  --teal-dark: #0f403d;
  --teal-soft: #dce9e5;
  --rust: #934126;
  --rust-soft: #f7e2d8;
  --amber: #80520c;
  --amber-soft: #f6ead2;
  --green: #2d7658;
  --green-soft: #deeee5;
  --blue: #3d617a;
  --blue-soft: #e1ebf1;
  --shadow: 0 18px 45px rgba(30, 42, 40, .08);
  --radius: 16px;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font: 14px/1.5 Inter, "Segoe UI", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 3px solid #1b736d; outline-offset: 2px; }
#page-title:focus, #portal-name:focus { outline: 0; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(25px, 2vw, 34px); letter-spacing: -.035em; line-height: 1.1; }
h2 { font-size: 20px; letter-spacing: -.025em; line-height: 1.2; }
h3 { font-size: 15px; letter-spacing: -.01em; }
small { color: var(--muted); font-weight: 450; }

.shell { min-height: 100dvh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 24px 16px 18px;
  color: #eaf1ee;
  background:
    radial-gradient(circle at 20% 0%, rgba(79, 151, 136, .22), transparent 30%),
    #123c3a;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 3px 8px 28px; }
.brand-mark {
  width: 37px; height: 37px; display: grid; place-items: center;
  color: var(--teal-dark); background: #e8d8bd; border-radius: 11px;
  font: 800 19px Georgia, serif;
}
.brand strong { display: block; font-size: 15px; letter-spacing: -.01em; }
.brand small { display: block; color: #aabfba; font-size: 11px; margin-top: 2px; }
.main-nav { display: grid; gap: 4px; }
.nav-item {
  border: 0; background: transparent; color: #b9cbc6; cursor: pointer;
  display: flex; align-items: center; gap: 11px; width: 100%;
  min-height: 44px; padding: 11px 12px; border-radius: 10px; text-align: left; font-weight: 600;
  transition: background .16s ease, color .16s ease, transform .16s ease;
}
.nav-item span { width: 20px; color: #8fb0a8; font-size: 18px; line-height: 1; text-align: center; }
.nav-item:hover { color: white; background: rgba(255,255,255,.07); transform: translateX(2px); }
.nav-item.active { color: white; background: rgba(255,255,255,.11); box-shadow: inset 3px 0 #e8d8bd; }
.nav-item.active span { color: #e8d8bd; }
.nav-count { margin-left: auto; min-width: 22px; padding: 2px 7px; border-radius: 999px; background: #e8d8bd; color: var(--teal-dark); font-size: 11px; font-weight: 800; text-align: center; }
.sidebar-foot { margin-top: auto; padding: 14px 9px 0; border-top: 1px solid rgba(255,255,255,.12); }
.system-dot { display: flex; align-items: center; gap: 10px; }
.system-dot i, .connection-pill i { width: 8px; height: 8px; border-radius: 50%; background: #e1b34b; box-shadow: 0 0 0 4px rgba(225,179,75,.12); }
.system-dot i.ok, .connection-pill.ok i { background: #70c493; box-shadow: 0 0 0 4px rgba(112,196,147,.12); }
.system-dot i.bad, .connection-pill.bad i { background: #e57a65; box-shadow: 0 0 0 4px rgba(229,122,101,.12); }
.system-dot strong, .system-dot small { display: block; }
.system-dot small { color: #9fb6b0; font-size: 11px; }
.sidebar-foot > p { color: #8fa9a3; font-size: 11px; line-height: 1.45; margin-top: 14px; }

.workspace { width: 100%; max-width: 1600px; min-width: 0; margin: 0 auto; padding: 0 34px 48px; }
.topbar {
  min-height: 108px; display: flex; align-items: center; justify-content: space-between; gap: 24px;
  border-bottom: 1px solid var(--line); margin-bottom: 28px;
}
.eyebrow { color: var(--teal); font-size: 10px; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; margin-bottom: 5px; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.connection-pill {
  display: flex; align-items: center; gap: 9px; min-height: 38px;
  padding: 0 13px; border: 1px solid var(--line); border-radius: 999px;
  background: rgba(255,253,248,.55); color: var(--muted); font-size: 12px; font-weight: 600;
}
.button {
  min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; border: 1px solid transparent; border-radius: 9px;
  cursor: pointer; font-weight: 700; font-size: 13px; white-space: nowrap;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .5; cursor: wait; transform: none; }
.button[hidden] { display:none; }
[hidden] { display:none !important; }
.button.primary { background: var(--teal); color: white; box-shadow: 0 6px 18px rgba(20,91,86,.16); }
.button.primary:hover { background: var(--teal-dark); }
.button.secondary { background: var(--surface); border-color: var(--line); }
.button.secondary:hover { border-color: #bcb7aa; box-shadow: 0 5px 16px rgba(30,42,40,.07); }
.button.ghost { background: transparent; color: var(--ink); }
.button.danger { background: var(--rust-soft); color: #8f3f29; }
.text-button { min-height: 44px; border: 0; background: transparent; color: var(--teal); font-weight: 750; font-size: 12px; cursor: pointer; padding: 8px; }
.icon-button { flex: 0 0 auto; width: 44px; height: 44px; border: 0; border-radius: 50%; background: #eeebe4; cursor: pointer; font-size: 23px; line-height: 1; }
.mobile-menu { display: none; }
.menu-backdrop { display: none; }

.view { display: none; animation: appear .18s ease both; }
.view.active { display: block; }
@keyframes appear { from { opacity: 0; transform: translateY(4px); } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 1px 0 rgba(255,255,255,.8); }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 21px 22px 17px; }
.metrics { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 12px; margin-bottom: 18px; }
.metric {
  position: relative; min-height: 124px; padding: 19px 18px; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
}
.metric::after { content:""; position:absolute; right:-22px; bottom:-37px; width:88px; height:88px; border: 12px solid var(--metric-soft, var(--teal-soft)); border-radius:50%; opacity:.7; }
.metric span { color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.metric strong { display: block; margin-top: 12px; font: 700 34px/1 Georgia, serif; letter-spacing: -.04em; }
.metric small { display: block; margin-top: 7px; }
.metric.urgent { --metric-soft: var(--rust-soft); }
.metric.review { --metric-soft: var(--amber-soft); }
a.metric:hover { border-color: var(--teal); }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, .7fr); gap: 18px; }
.case-list { padding: 0 10px 12px; }
.case-row {
  width: 100%; display: grid; grid-template-columns: minmax(150px,1.2fr) minmax(105px,.75fr) minmax(115px,.8fr) auto 20px;
  align-items: center; gap: 10px; padding: 13px 12px; border: 0; border-top: 1px solid #ebe7de; cursor: pointer; border-radius: 9px;
  color: inherit; background: transparent; text-align: left; font: inherit;
}
.case-row:hover { background: #f6f3ed; }
.case-row > * { min-width: 0; }
.identity { display: flex; align-items: center; gap: 11px; min-width: 0; }
.avatar { flex: 0 0 auto; width: 34px; height: 34px; display:grid; place-items:center; border-radius:10px; background:var(--teal-soft); color:var(--teal); font-weight:800; font-size:12px; }
.identity strong, .identity small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.identity small { font-size: 11px; }
.cell-label { display:block; color:var(--muted); font-size:10px; text-transform:uppercase; letter-spacing:.08em; margin-bottom:2px; }
.case-row > span:last-child { color: var(--teal); font-size: 20px; }
.status-badge, .flow-badge, .document-status {
  display:inline-flex; align-items:center; width:max-content; max-width:100%; padding:5px 8px; border-radius:999px;
  background:var(--blue-soft); color:var(--blue); font-size:10px; font-weight:800; letter-spacing:.04em; text-transform:uppercase;
}
.flow-badge.waiting { background:#ebe8e0; color:#5c584f; }
.flow-badge.standard, .document-status.ONAYLANDI { background:var(--green-soft); color:var(--green); }
.flow-badge.fast, .document-status.OPERASYON_KONTROLU { background:var(--amber-soft); color:var(--amber); }
.flow-badge.urgent, .document-status.DUZELTME, .document-status.RED { background:var(--rust-soft); color:var(--rust); }
.document-status.INCELEMEDE { background:var(--blue-soft); color:var(--blue); }
.timeline { padding: 0 22px 20px; }
.timeline-item { position:relative; padding: 2px 0 17px 22px; }
.timeline-item::before { content:""; position:absolute; left:2px; top:7px; width:7px; height:7px; background:var(--teal); border-radius:50%; }
.timeline-item:not(:last-child)::after { content:""; position:absolute; left:5px; top:17px; bottom:2px; width:1px; background:var(--line); }
.timeline-item strong { display:block; font-size:12px; }
.timeline-item span { display:block; color:var(--muted); font-size:11px; margin-top:2px; }
.principle-strip {
  margin-top: 18px; padding: 22px 24px; display:grid; grid-template-columns:auto minmax(0,1fr) 1px minmax(0,1fr); gap:20px;
  color:#e9f0ed; background:var(--teal-dark); border-radius:var(--radius);
}
.principle-strip > span:first-child { color:#c9b58e; font:700 27px Georgia,serif; }
.principle-strip .line { display:block; width:1px; height:100%; background:rgba(255,255,255,.16); }
.principle-strip strong { font-size:14px; }
.principle-strip p { color:#acc3bd; font-size:12px; margin-top:4px; }

.toolbar { display:flex; align-items:center; gap:9px; padding:11px; margin-bottom:14px; }
.spacer { flex:1; }
.search-field { min-height:44px; min-width:260px; display:flex; align-items:center; gap:7px; padding:0 11px; border:1px solid var(--line); border-radius:9px; background:#fff; }
.search-field:focus-within { border-color:var(--teal); box-shadow:0 0 0 3px rgba(20,91,86,.09); }
.search-field span { color:var(--muted); font-size:18px; }
.search-field input { width:100%; border:0; outline:0; background:transparent; }
select, input, textarea {
  width:100%; border:1px solid #cfcbc0; border-radius:8px; background:#fff; color:var(--ink);
  min-height:44px; padding:9px 10px; outline:0;
}
select:focus, input:focus, textarea:focus { border-color:var(--teal); box-shadow:0 0 0 3px rgba(20,91,86,.09); }
textarea { resize:vertical; }
.toolbar > select { width:auto; min-width:180px; height:44px; }
.table-panel { overflow:hidden; }
.table-wrap { max-height:calc(100dvh - 260px); overflow:auto; }
table { width:100%; border-collapse:collapse; }
th { position:sticky; top:0; z-index:1; color:var(--muted); background:#f5f2eb; font-size:10px; letter-spacing:.08em; text-transform:uppercase; text-align:left; padding:11px 14px; white-space:nowrap; }
td { padding:13px 14px; border-top:1px solid #ebe7de; vertical-align:middle; }
tbody tr:hover { background:#faf8f3; }
td .sub { display:block; color:var(--muted); font-size:11px; margin-top:2px; }
.sub { display:block; color:var(--muted); font-size:11px; margin-top:2px; }
.case-row strong { display:block; }
.open-case { min-height:44px; display:inline-flex; align-items:center; border:0; background:transparent; color:var(--teal); cursor:pointer; font-weight:800; }
.muted { color:var(--muted); }
.empty-state { text-align:center; padding:46px 20px; color:var(--muted); }
.empty-state strong { display:block; color:var(--ink); margin-bottom:5px; }
.loading-block { color:var(--muted); min-height:100px; display:grid; place-items:center; }
.page-intro { display:flex; align-items:end; justify-content:space-between; gap:30px; margin:4px 0 20px; }
.page-intro > div > p:last-child { max-width:680px; color:var(--muted); margin-top:7px; }
.page-intro-actions { display:flex; flex-wrap:wrap; gap:8px; }

.contact-list, .message-list { padding:5px 18px; }
.contact-row, .message-row {
  display:grid; grid-template-columns:minmax(220px,1fr) minmax(160px,.8fr) minmax(170px,1.2fr) auto;
  align-items:center; gap:18px; padding:14px 5px; border-bottom:1px solid #ebe7de;
}
.contact-row > *, .message-row > * { min-width:0; }
.contact-actions { display:flex; align-items:center; gap:10px; }
.contact-row:last-child, .message-row:last-child { border-bottom:0; }
.intake-invite { margin-bottom:20px; }
.intake-list-panel { overflow:hidden; }
.intake-card { padding:18px 22px; border-top:1px solid var(--line); }
.intake-card-head { display:flex; align-items:start; justify-content:space-between; gap:12px; }
.intake-card-head strong, .intake-card-head small { display:block; }
.intake-card-head small { color:var(--muted); margin-top:4px; }
.intake-details { display:flex; flex-wrap:wrap; gap:8px 18px; margin:12px 0; font-size:13px; }
.intake-details p { flex-basis:100%; margin:0; }
.intake-preview { margin-top:12px; }
.intake-preview summary { display:inline-flex; align-items:center; list-style:none; }
.intake-note { display:block; max-width:650px; margin:12px 0; font-size:12px; font-weight:700; }
.intake-note textarea { display:block; width:100%; margin-top:5px; }
.intake-decision { font-size:13px; color:var(--muted); }
.intake-actions { display:flex; flex-wrap:wrap; gap:8px; margin-top:14px; }
.city-rule-list { max-height:440px; overflow:auto; margin-top:12px; }
.intake-section { min-width:0; margin:20px 0 0; padding:0; border:0; border-top:1px solid var(--line); }
.intake-section > legend { padding:0 10px; margin-left:12px; font-weight:700; color:var(--teal); }
.intake-conditional { min-width:0; margin:0; padding:0; border:1px solid var(--line); border-radius:10px; }
.intake-conditional legend { margin-left:10px; padding:0 6px; color:var(--muted); font-size:12px; }
.intake-form label small { display:block; margin-top:4px; font-weight:400; }
.intake-form .form-grid { overflow:visible; }
.intake-details dl, .intake-record { display:grid; grid-template-columns:minmax(120px,1fr) 2fr; gap:8px 16px; width:100%; margin:0; }
.intake-details dt, .intake-record dt { color:var(--muted); }
.intake-details dd, .intake-record dd { margin:0; white-space:pre-wrap; overflow-wrap:anywhere; }
.research-panel { margin:16px 0; padding:14px 16px; border:1px solid var(--line); border-radius:12px; background:#faf8f3; }
.research-head { display:flex; flex-wrap:wrap; align-items:start; justify-content:space-between; gap:10px; }
.research-head strong, .research-head small { display:block; }
.research-head small { color:var(--muted); margin-top:4px; }
.research-actions, .research-sources { display:flex; flex-wrap:wrap; align-items:center; gap:8px; }
.research-sources { font-size:12px; color:var(--muted); }
.research-draft.form-grid { padding:14px 0; border-top:1px solid var(--line); }
.research-add { margin-top:10px; }
.research-add summary { display:inline-flex; list-style:none; }
.toggle {
  position:relative; width:48px; height:44px; padding:0; border:0; border-radius:99px;
  background:linear-gradient(#c8c5bc 0 0) center / 44px 26px no-repeat; cursor:pointer; transition:background .18s;
}
.toggle::after { content:""; position:absolute; top:11px; left:4px; width:22px; height:22px; border-radius:50%; background:white; box-shadow:0 1px 4px rgba(0,0,0,.2); transition:transform .18s; }
.toggle.on { background:linear-gradient(var(--teal) 0 0) center / 44px 26px no-repeat; }
.toggle.on::after { transform:translateX(18px); }
.toggle:disabled { opacity:.55; cursor:wait; }
.message-row { grid-template-columns:minmax(180px,.7fr) minmax(260px,1.7fr) 115px 180px; align-items:start; }
.message-text { white-space:pre-wrap; overflow-wrap:anywhere; }
.message-actions { display:flex; flex-wrap:wrap; gap:5px; }
.todo-group { margin-bottom:16px; overflow:hidden; }
.mini-button { min-height:36px; border:1px solid var(--line); background:#fff; border-radius:7px; padding:7px 9px; font-size:11px; font-weight:700; cursor:pointer; }
.mini-button:hover { border-color:var(--teal); color:var(--teal); }
.mini-button.danger { border-color:#d9a99a; color:#8f3f29; }

.settings-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:18px; }
.settings-card { padding-bottom:21px; }
.connection-account { margin:0 22px 14px; padding:13px 14px; border-radius:10px; background:var(--teal-soft); }
.connection-account span, .connection-account strong, .connection-account small { display:block; }
.connection-account span { color:var(--muted); font-size:10px; font-weight:800; letter-spacing:.08em; text-transform:uppercase; }
.connection-account strong { margin-top:3px; }
.settings-card > label, .field-row { display:block; margin:0 22px 14px; color:var(--muted); font-size:11px; font-weight:700; }
.settings-card label input, .settings-card label select { margin-top:5px; color:var(--ink); font-size:13px; }
.field-row { display:grid; grid-template-columns:1fr 1fr; gap:12px; margin-bottom:0; }
.field-row label { display:block; }
.toggle-row { display:flex!important; align-items:center; justify-content:space-between; gap:15px; padding:12px; background:#f5f2eb; border-radius:9px; }
.toggle-row strong, .toggle-row small { display:block; }
.toggle-row input[role="switch"] {
  appearance:none; flex:0 0 auto; width:46px; height:26px; min-height:26px; padding:2px; border:0; border-radius:99px;
  background:#c8c5bc; cursor:pointer; transition:background .18s;
}
.toggle-row input[role="switch"]::before { content:""; display:block; width:22px; height:22px; border-radius:50%; background:white; box-shadow:0 1px 4px rgba(0,0,0,.2); transition:transform .18s; }
.toggle-row input[role="switch"]:checked { background:var(--teal); }
.toggle-row input[role="switch"]:checked::before { transform:translateX(20px); }
.button-row { display:flex; flex-wrap:wrap; gap:8px; margin:18px 22px 0; }
.webhook-box { margin:0 22px; padding:10px 12px; background:#f1eee7; border-radius:9px; overflow:hidden; }
.webhook-box span { display:block; color:var(--muted); font-size:10px; text-transform:uppercase; letter-spacing:.08em; }
.webhook-box code { display:block; margin-top:4px; font-size:11px; white-space:nowrap; overflow:auto; }
.qr-card { grid-column:1/-1; display:grid; grid-template-columns:1fr 230px; align-items:center; padding:24px; }
.qr-card[hidden] { display:none; }
.qr-card ol { color:var(--muted); padding-left:20px; }
.qr-output { min-height:230px; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:8px; padding:10px; border:1px dashed #c8c3b7; border-radius:12px; background:white; text-align:center; }
.qr-output img { width:205px; max-width:100%; height:auto; aspect-ratio:1; image-rendering:pixelated; }
.qr-output small, .qr-message small { display:block; }
.qr-message { display:grid; justify-items:center; gap:10px; }
.qr-message.success { color:var(--green); }
.qr-output code { max-width:100%; padding:10px; overflow-wrap:anywhere; font-size:10px; }

.group-management-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:18px; }
.group-panel { min-width:0; }
.access-group-list { display:grid; gap:12px; padding:0 18px 18px; }
.access-group-card { overflow:hidden; border:1px solid var(--line); border-radius:12px; background:#fff; }
.access-group-card > header { padding:13px 15px; border-bottom:1px solid var(--line); background:#f5f2eb; }
.access-group-card > header small { display:block; margin-top:2px; }
.group-actions { display:flex; flex-wrap:wrap; justify-content:flex-end; gap:8px; }
.group-members { display:grid; }
.group-member-row { display:grid; grid-template-columns:38px minmax(0,1fr) auto auto; align-items:center; gap:10px; min-height:72px; padding:10px 13px; border-top:1px solid #ebe7de; }
.group-member-row:first-child { border-top:0; }
.group-member-row:hover { background:#faf8f3; }
.group-member-row > span:nth-child(2) { min-width:0; }
.group-member-row strong, .group-member-row small, .group-member-row em { display:block; }
.group-member-row strong, .group-member-row small { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.group-member-row em { margin-top:3px; color:var(--teal); font-size:11px; font-style:normal; font-weight:700; }
.group-member-row b { color:var(--muted); font-size:20px; }
.group-member-row > .icon-button { display:grid; place-items:center; }
.group-responsibility { display:flex; align-items:center; gap:6px; min-height:44px; white-space:nowrap; font-size:12px; font-weight:700; }
.group-responsibility input { width:18px; height:18px; accent-color:var(--teal); }

dialog { padding:0; border:0; color:var(--ink); background:transparent; }
dialog::backdrop { background:rgba(12,26,24,.44); backdrop-filter:blur(3px); }
.modal { width:min(690px,calc(100vw - 28px)); max-height:calc(100dvh - 28px); }
.modal.compact { width:min(560px,calc(100vw - 28px)); }
.modal-card { display:grid; grid-template-rows:auto minmax(0,1fr) auto; background:var(--surface); border:1px solid rgba(255,255,255,.65); border-radius:18px; box-shadow:var(--shadow); overflow:hidden; max-height:calc(100dvh - 28px); }
.modal-card > header, .modal-card > footer { display:flex; align-items:center; justify-content:space-between; gap:16px; padding:20px 22px; }
.modal-card > header { position:sticky; top:0; z-index:1; border-bottom:1px solid var(--line); background:var(--surface); }
.modal-card > footer { position:sticky; bottom:0; z-index:1; border-top:1px solid var(--line); justify-content:flex-end; background:var(--surface); }
.form-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px; padding:20px 22px; overflow:auto; }
.form-grid label { display:block; color:var(--muted); font-size:11px; font-weight:700; }
.form-grid label input, .form-grid label select, .form-grid label textarea { margin-top:5px; color:var(--ink); font-size:13px; }
.form-grid input[readonly] { color:var(--muted); background:#f1eee7; cursor:not-allowed; }
.form-grid .span-2 { grid-column:1/-1; }
.check-line { display:flex!important; align-items:center; gap:8px; min-height:44px; color:var(--ink)!important; }
.check-line input { width:17px; height:17px; min-height:17px; margin:0!important; accent-color:var(--teal); }
.form-stack { display:grid; gap:14px; padding:20px 22px; overflow:auto; }
.form-stack label { color:var(--muted); font-size:11px; font-weight:700; }
.form-stack textarea { margin-top:5px; color:var(--ink); font-size:13px; }
.case-page { min-height:100dvh; }
.case-header { width:min(1280px,calc(100% - 32px)); }
.case-shell { width:min(1280px,calc(100% - 32px)); margin:0 auto; padding:34px 0 calc(60px + env(safe-area-inset-bottom)); }
.case-titlebar { display:flex; align-items:flex-end; justify-content:space-between; gap:20px; margin-bottom:22px; }
.case-titlebar h1 { margin-top:2px; }
.case-titlebar small { display:block; margin-top:6px; }
.case-body[aria-busy="true"] { min-height:260px; display:grid; place-items:center; color:var(--muted); }
.case-summary-grid { display:grid; grid-template-columns:1.4fr repeat(3,1fr); gap:10px; margin-bottom:15px; }
.summary-cell { padding:13px 14px; background:var(--surface); border:1px solid var(--line); border-radius:11px; }
.summary-cell span { display:block; color:var(--muted); font-size:10px; text-transform:uppercase; letter-spacing:.08em; }
.summary-cell strong { display:block; margin-top:4px; }
.detail-actions { display:flex; flex-wrap:wrap; gap:8px; margin:15px 0; }
.case-edit { padding:18px; margin-bottom:16px; }
.case-edit .form-grid { padding:0; grid-template-columns:repeat(4,minmax(0,1fr)); }
.requirements-head { display:flex; align-items:end; justify-content:space-between; gap:16px; margin:26px 0 11px; }
.requirements-head p { color:var(--muted); font-size:12px; margin-top:3px; }
.case-history { margin-top:26px; }
.case-history .message-text { margin:4px 0 2px; font-size:13px; }
.timing-group { margin-bottom:19px; }
.timing-title { display:flex; align-items:center; gap:9px; color:var(--muted); font-size:11px; font-weight:800; letter-spacing:.08em; text-transform:uppercase; margin:0 0 8px 3px; }
.timing-title::after { content:""; height:1px; flex:1; background:var(--line); }
.requirement-card { background:var(--surface); border:1px solid var(--line); border-radius:12px; margin-bottom:8px; overflow:hidden; }
.requirement-main { display:grid; grid-template-columns:minmax(210px,1fr) minmax(150px,.7fr) auto; align-items:center; gap:16px; padding:14px 16px; }
.requirement-copy p { color:var(--muted); font-size:11px; margin-top:3px; }
.requirement-meta { display:flex; flex-wrap:wrap; gap:6px; }
.meta-chip { padding:4px 7px; border-radius:6px; background:#efede6; color:#6a665e; font-size:10px; font-weight:700; }
.upload-label { position:relative; overflow:hidden; }
.upload-label input { position:absolute; inset:0; opacity:0; cursor:pointer; }
.upload-label:focus-within { outline:3px solid #1b736d; outline-offset:2px; }
.upload-label[aria-busy="true"] { opacity:.65; cursor:wait; }
.document-list { border-top:1px solid #ebe7de; }
.document-item { display:grid; grid-template-columns:minmax(180px,1fr) 115px minmax(180px,1.2fr) auto; align-items:center; gap:12px; padding:12px 16px; background:#fcfaf5; border-bottom:1px solid #efebe2; }
.document-item:last-child { border-bottom:0; }
.document-item a { color:var(--teal); font-weight:750; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.ai-note { color:var(--muted); font-size:11px; }
.ai-note strong { color:var(--ink); }
.review-actions { display:flex; flex-wrap:wrap; gap:5px; }
.crop-modal { width:min(980px,calc(100vw - 28px)); }
.crop-body { padding:18px 22px; overflow:auto; }
.crop-body > p:first-child { margin-bottom:13px; }
.crop-canvas { padding:12px; overflow:auto; border-radius:11px; background:#262b2a; text-align:center; }
.crop-stage { position:relative; display:inline-block; max-width:100%; line-height:0; touch-action:none; user-select:none; }
.crop-stage[aria-busy="true"] { min-width:260px; min-height:180px; }
.crop-stage img { display:block; width:auto; max-width:100%; max-height:calc(100dvh - 300px); }
.crop-box { position:absolute; border:3px solid #f2c65d; box-shadow:0 0 0 9999px rgba(7,16,15,.58),0 0 0 1px rgba(0,0,0,.35); cursor:move; touch-action:none; }
.crop-box:focus-visible { outline:3px solid white; outline-offset:3px; }
.crop-box[hidden] { display:none; }
.crop-handle { position:absolute; width:22px; height:22px; border:3px solid #f2c65d; border-radius:50%; background:white; box-shadow:0 1px 4px rgba(0,0,0,.35); }
.crop-handle.nw { left:-12px; top:-12px; cursor:nwse-resize; }
.crop-handle.ne { right:-12px; top:-12px; cursor:nesw-resize; }
.crop-handle.sw { left:-12px; bottom:-12px; cursor:nesw-resize; }
.crop-handle.se { right:-12px; bottom:-12px; cursor:nwse-resize; }
.crop-selection { min-height:20px; margin-top:10px; color:var(--muted); font-size:11px; text-align:center; }
.result-body { padding:22px; overflow:auto; }
.result-box { padding:13px; border-radius:10px; background:#f2efe8; margin-bottom:11px; }
.result-box code { display:block; margin-top:4px; overflow-wrap:anywhere; }
.result-links { display:grid; gap:7px; margin-top:14px; }
.result-links a { display:flex; justify-content:space-between; padding:10px 12px; border:1px solid var(--line); border-radius:8px; color:var(--teal); font-weight:700; }
.toast {
  position:fixed; right:max(16px,env(safe-area-inset-right)); bottom:max(16px,env(safe-area-inset-bottom)); z-index:100; max-width:min(390px,calc(100vw - 32px));
  padding:12px 15px; color:white; background:#243936; border-radius:10px; box-shadow:var(--shadow);
  opacity:0; transform:translateY(12px); pointer-events:none; transition:.2s ease;
}
.toast.show { opacity:1; transform:none; }
.toast.error { background:#8d3f2c; }
.toast.error.show { pointer-events:auto; user-select:text; }

@media (max-width: 1180px) {
  .metrics { grid-template-columns:repeat(3,1fr); }
  .dashboard-grid { grid-template-columns:1fr; }
  .case-summary-grid { grid-template-columns:repeat(2,1fr); }
}
@media (max-width: 980px) {
  .settings-grid, .group-management-grid { grid-template-columns:minmax(0,1fr); }
}
@media (max-width: 860px) {
  .shell { display:block; }
  .sidebar { position:fixed; left:-260px; width:248px; visibility:hidden; pointer-events:none; transition:left .2s ease, visibility .2s; }
  body.menu-open { overflow:hidden; }
  body.menu-open .sidebar { left:0; visibility:visible; pointer-events:auto; box-shadow:25px 0 50px rgba(0,0,0,.2); }
  .menu-backdrop { position:fixed; inset:0; z-index:19; border:0; background:rgba(12,26,24,.42); }
  body.menu-open .menu-backdrop { display:block; }
  .workspace { padding:0 16px 35px; }
  .topbar { min-height:90px; margin-bottom:20px; }
  .mobile-menu { display:inline-grid; place-items:center; float:left; width:44px; height:44px; margin-right:10px; border:1px solid var(--line); border-radius:8px; background:var(--surface); cursor:pointer; }
  .connection-pill { display:none; }
  .toolbar { flex-wrap:wrap; }
  .toolbar .search-field { flex:1 1 100%; }
  .spacer { display:none; }
  .page-intro { align-items:flex-start; flex-direction:column; }
  .page-intro .search-field { width:100%; }
  .principle-strip { grid-template-columns:auto 1fr; }
  .principle-strip .line { display:none; }
  .contact-row, .message-row { grid-template-columns:1fr auto; gap:8px; }
  .contact-row > :nth-child(2), .message-row > :nth-child(2) { grid-column:1/-1; }
  .document-item { grid-template-columns:1fr auto; }
  .document-item .ai-note { grid-column:1/-1; }
  .case-edit .form-grid { grid-template-columns:repeat(2,1fr); }
  .mini-button { min-height:44px; padding:9px 11px; }
}
@media (max-width: 800px) {
  select, input, textarea,
  .settings-card label input, .settings-card label select,
  .form-grid label input, .form-grid label select, .form-grid label textarea,
  .form-stack textarea { font-size:16px; }
  .table-wrap { max-height:none; overflow:visible; }
  .data-table, .data-table tbody { display:block; width:100%; }
  .data-table thead { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; }
  .data-table tr { display:block; padding:9px 12px; border-top:1px solid #ebe7de; }
  .data-table td { display:grid; grid-template-columns:105px minmax(0,1fr); gap:10px; align-items:center; padding:7px 0; border:0; }
  .data-table td::before { content:attr(data-label); color:var(--muted); font-size:10px; font-weight:800; letter-spacing:.08em; text-transform:uppercase; }
  .data-table .empty-table-row td { display:block; }
  .data-table .empty-table-row td::before { content:none; }
  .data-table .empty-state { padding:34px 12px; }
}
@media (max-width: 580px) {
  .workspace { padding:0 11px calc(28px + env(safe-area-inset-bottom)); }
  .topbar { gap:10px; }
  .top-actions .button { padding:8px 10px; }
  .metrics { grid-template-columns:repeat(2,1fr); }
  .metric { min-height:108px; padding:15px; }
  .metric strong { font-size:29px; }
  .case-row { grid-template-columns:minmax(0,1fr) auto; gap:8px 12px; }
  .case-row > :nth-child(2) { grid-column:1; grid-row:2; padding-left:45px; }
  .case-row > :nth-child(3) { grid-column:2; grid-row:2; text-align:right; }
  .case-row > :nth-child(4) { grid-column:2; grid-row:1; }
  .case-row > :nth-child(5) { display:none; }
  .principle-strip { padding:18px; grid-template-columns:1fr; }
  .principle-strip > span:first-child { display:none; }
  .toolbar > * { flex:1 1 auto; }
  .toolbar .button { font-size:12px; padding:8px; }
  .form-grid, .case-edit .form-grid { grid-template-columns:1fr; }
  .form-grid .span-2 { grid-column:auto; }
  .case-shell { width:min(100% - 22px,1280px); padding-top:20px; }
  .case-titlebar { align-items:flex-start; flex-direction:column; }
  .case-summary-grid { grid-template-columns:1fr 1fr; }
  .requirement-main { grid-template-columns:1fr; }
  .requirement-main .button { width:100%; }
  .detail-actions .button, .case-edit .span-2 .button { width:100%; flex:1 1 100%; }
  .modal-card > header, .modal-card > footer { padding:15px; }
  .modal-card > footer { padding-bottom:calc(15px + env(safe-area-inset-bottom)); }
  .crop-body { padding:14px; }
  .crop-canvas { padding:7px; }
  .crop-modal .modal-card > footer { flex-wrap:wrap; }
  .crop-modal .modal-card > footer .button.primary { flex:1 1 100%; order:-1; }
  .qr-card { grid-template-columns:1fr; gap:20px; }
  .group-member-row { grid-template-columns:38px minmax(0,1fr) auto; }
  .group-member-row > .avatar { grid-column:1; grid-row:1 / span 2; }
  .group-member-row > span:nth-child(2) { grid-column:2; grid-row:1; }
  .group-responsibility { grid-column:2; grid-row:2; justify-self:start; }
  .group-member-row > .icon-button { grid-column:3; grid-row:1 / span 2; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior:auto!important; transition:none!important; animation:none!important; }
}

.portal-page {
  min-height:100dvh;
  background:
    radial-gradient(circle at 85% 0%, rgba(20,91,86,.12), transparent 30%),
    var(--paper);
}
.portal-header {
  width:min(1120px,calc(100% - 32px)); min-height:84px; margin:auto;
  display:flex; align-items:center; justify-content:space-between; gap:20px;
  border-bottom:1px solid var(--line);
}
.portal-brand { display:flex; align-items:center; gap:10px; }
.portal-brand strong, .portal-brand small { display:block; }
.portal-brand small { font-size:10px; }
.portal-trust { color:var(--muted); font-size:11px; }
.portal-trust::before { content:"●"; color:var(--green); margin-right:7px; }
.portal-shell { width:min(1120px,calc(100% - 32px)); margin:0 auto; padding:48px 0 calc(70px + env(safe-area-inset-bottom)); }
.portal-auth { min-height:calc(100dvh - 190px); display:grid; grid-template-columns:minmax(0,1.25fr) minmax(310px,.65fr); align-items:center; gap:9vw; }
.portal-auth-copy h1 { max-width:740px; font:700 clamp(38px,5vw,67px)/1.03 Georgia,serif; letter-spacing:-.045em; }
.portal-auth-copy > p:not(.eyebrow) { max-width:640px; margin-top:21px; color:var(--muted); font-size:16px; }
.portal-steps { display:flex; flex-wrap:wrap; gap:20px; margin-top:34px; color:var(--muted); font-size:12px; font-weight:700; }
.portal-steps span { display:flex; align-items:center; gap:8px; }
.portal-steps b { width:27px; height:27px; display:grid; place-items:center; color:var(--teal); background:var(--teal-soft); border-radius:50%; }
.portal-login { padding:28px; box-shadow:var(--shadow); }
.portal-login h2 { font-size:25px; }
.portal-login > p:not(.eyebrow) { color:var(--muted); margin:8px 0 23px; }
.portal-login label { display:block; color:var(--muted); font-size:11px; font-weight:750; }
.portal-login input { height:54px; margin:6px 0 13px; text-align:center; font-size:25px; letter-spacing:.28em; font-weight:800; }
.portal-login .button { width:100%; min-height:48px; }
.portal-login .button + .button { margin-top:8px; }
.form-error { margin:10px 0 0; padding:10px 12px; color:#7f3b26; background:var(--rust-soft); border-radius:8px; font-size:12px; font-weight:700; }
.form-error[hidden] { display:none; }
.portal-login > small { display:block; text-align:center; margin-top:15px; }
.portal-loading { max-width:520px; margin:18vh auto 0; padding:28px; text-align:center; }
.portal-welcome { display:flex; justify-content:space-between; align-items:end; gap:30px; margin-bottom:25px; }
.portal-welcome h1 { font:700 clamp(31px,4vw,49px)/1.05 Georgia,serif; }
.portal-welcome p:last-child { color:var(--muted); margin-top:7px; }
.portal-case-switcher { display:grid; grid-template-columns:minmax(190px,.7fr) minmax(220px,1fr); align-items:center; gap:7px 20px; padding:17px 20px; margin-bottom:14px; }
.portal-case-switcher[hidden] { display:none; }
.portal-case-switcher label { display:block; font-weight:800; }
.portal-case-switcher .eyebrow { margin-bottom:3px; }
.portal-case-switcher p:last-child { grid-column:2; color:var(--muted); font-size:11px; }
#portal-flow { min-width:170px; text-align:right; }
#portal-flow > * { display:block; margin-left:auto; }
#portal-flow strong { margin-top:7px; font-size:17px; }
#portal-flow small { margin-top:2px; }
.portal-notice {
  display:flex; gap:16px; align-items:flex-start; padding:18px 20px; margin-bottom:14px;
  color:var(--teal-dark); background:var(--teal-soft); border:1px solid #bfd7d0; border-radius:13px;
}
.portal-notice.waiting { color:#5e5b55; background:#ece9e2; border-color:#d9d5ca; }
.portal-notice.waiting p { color:#504d48; opacity:1; }
.portal-notice.urgent { color:#823d2a; background:var(--rust-soft); border-color:#ebc5b7; }
.portal-notice > span { width:30px; height:30px; flex:0 0 auto; display:grid; place-items:center; border:1px solid currentColor; border-radius:50%; font-weight:800; }
.portal-notice p { opacity:.82; font-size:12px; margin-top:3px; }
.portal-progress { display:grid; grid-template-columns:auto minmax(160px,1fr) auto; align-items:center; gap:20px; padding:17px 20px; margin-bottom:28px; }
.portal-progress span, .portal-progress strong { display:block; }
.portal-progress .eyebrow { margin:0 0 2px; font-size:9px; }
.portal-progress .text-button { min-height:44px; justify-content:flex-start; padding:4px 0 0; }
.progress-track { height:8px; background:#e4e0d7; border-radius:99px; overflow:hidden; }
.progress-track i { display:block; height:100%; background:var(--teal); border-radius:inherit; transition:width .35s ease; }
.portal-progress > b { color:var(--teal); font:700 19px Georgia,serif; }
.portal-group { margin-bottom:28px; }
.portal-group > header { display:flex; align-items:end; justify-content:space-between; padding:0 3px 10px; border-bottom:1px solid var(--line); }
.portal-group > header > span { color:var(--muted); font-size:11px; }
.portal-group.locked > header h2 { color:var(--muted); }
.locked-note { padding:12px; margin-top:8px; color:#4f5957; background:#eae7df; border-radius:9px; font-size:12px; text-align:center; }
.portal-requirement {
  display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:center; gap:18px;
  padding:19px 18px; margin-top:9px; background:var(--surface); border:1px solid var(--line); border-radius:13px;
}
.portal-requirement-copy { display:flex; gap:14px; align-items:flex-start; }
.portal-number { width:32px; height:32px; flex:0 0 auto; display:grid; place-items:center; color:var(--teal); background:var(--teal-soft); border-radius:9px; font:700 12px Georgia,serif; }
.portal-requirement-copy p { max-width:690px; color:var(--muted); font-size:12px; margin-top:4px; }
.portal-requirement .requirement-meta { margin-top:9px; }
.portal-documents { grid-column:1/-1; display:grid; gap:6px; padding-top:11px; border-top:1px solid #ebe7de; }
.portal-document { display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:center; gap:10px; padding:10px 12px; background:#f5f2eb; border-radius:9px; }
.portal-document strong, .portal-document small { display:block; }
.portal-document strong { overflow-wrap:anywhere; }
.portal-document-actions { grid-column:1/-1; display:flex; gap:14px; }
.portal-document-actions .text-button { min-height:32px; padding:0; }
.portal-document-actions .danger { color:#9a432d; }
.portal-document p { grid-column:1/-1; color:var(--muted); font-size:11px; padding-top:7px; border-top:1px solid #dfdbd2; }
p.needs-fix { color:#8a412c; font-weight:650; }
.portal-footer { max-width:760px; margin:48px auto 0; padding-top:25px; border-top:1px solid var(--line); text-align:center; }
.portal-footer p { color:var(--muted); font-size:12px; margin-top:5px; }

@media (max-width:800px) {
  .portal-header { min-height:72px; }
  .portal-trust { display:none; }
  .portal-shell { padding-top:20px; }
  .portal-auth { min-height:auto; grid-template-columns:1fr; align-items:start; gap:28px; }
  .portal-login { order:-1; padding:22px; }
  .portal-auth-copy h1 { font-size:31px; }
  .portal-auth-copy > p:not(.eyebrow) { font-size:14px; }
  .portal-steps { gap:11px; }
  .portal-steps span { flex:1 1 100%; }
  .portal-welcome { align-items:flex-start; flex-direction:column; }
  .portal-case-switcher { grid-template-columns:1fr; }
  .portal-case-switcher p:last-child { grid-column:1; }
  #portal-flow { text-align:left; }
  #portal-flow > * { margin-left:0; }
  .portal-progress { grid-template-columns:1fr auto; }
  .progress-track { grid-column:1/-1; grid-row:2; }
  .portal-requirement { grid-template-columns:1fr; padding:15px; }
  .portal-requirement > .button { width:100%; }
}

.login-page { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(100%, 420px); padding: 32px; }
.login-card .brand-mark { margin-bottom: 24px; }
.login-card h1 { margin: 8px 0; }
.login-card .form-stack { margin-top: 28px; }
#login-error { color: #9b2525; margin: 0; }

.intake-type { display: block; margin-bottom: 20px; padding: 20px; }
.intake-type select { margin-top: 10px; }
#group-progress { padding: 24px; }
.group-intake-member { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; border-bottom: 1px solid var(--line); padding: 16px 0; }
.group-intake-member > div { flex: 1 1 220px; min-width: 0; overflow-wrap: anywhere; }
#group-progress > button { margin-top: 20px; }
#group-member-info { padding: 20px; }
