:root {
  color-scheme: light;
  --navy-950: #071522;
  --navy-900: #0b1e30;
  --navy-800: #12334f;
  --blue-700: #075d88;
  --blue-600: #087daa;
  --cyan-500: #08a6c2;
  --cyan-100: #daf5f8;
  --paper: #f4f7f9;
  --white: #ffffff;
  --ink: #142332;
  --muted: #687886;
  --line: #dbe4ea;
  --warning: #b65f00;
  --warning-bg: #fff2d6;
  --danger: #bd2f2f;
  --danger-bg: #fde7e7;
  --shadow: 0 14px 40px rgba(20, 45, 65, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; color: var(--ink); background: var(--paper); font-size: 16px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.eyebrow { margin: 0 0 0.45rem; color: var(--cyan-500); font-size: 0.75rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; }
.muted { color: var(--muted); }

.auth-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(20rem, 1fr) minmax(24rem, 0.85fr); background: var(--white); }
.auth-brand { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: center; padding: clamp(3rem, 8vw, 8rem); color: var(--white); background: radial-gradient(circle at 85% 15%, rgba(8,166,194,.32), transparent 32%), linear-gradient(145deg, var(--navy-950), var(--navy-800)); }
.auth-brand::after { content: ""; position: absolute; right: -9rem; bottom: -9rem; width: 28rem; height: 28rem; border: 1px solid rgba(255,255,255,.16); border-radius: 50%; box-shadow: 0 0 0 4rem rgba(255,255,255,.025), 0 0 0 8rem rgba(255,255,255,.02); }
.brand-mark { display: grid; place-items: center; width: 3.5rem; height: 3.5rem; margin-bottom: 2.5rem; border: 1px solid rgba(255,255,255,.35); border-radius: 0.85rem; color: var(--white); background: linear-gradient(145deg, var(--cyan-500), var(--blue-700)); font-size: 1.55rem; font-weight: 900; box-shadow: 0 12px 24px rgba(0,0,0,.18); }
.brand-mark.small { width: 2.4rem; height: 2.4rem; margin: 0; border-radius: .65rem; font-size: 1.05rem; }
.auth-brand h1 { max-width: 42rem; margin: 0; font-size: clamp(2.7rem, 5vw, 5.4rem); line-height: .98; letter-spacing: -.055em; }
.auth-copy { max-width: 32rem; margin: 1.5rem 0 3rem; color: #c9d9e4; font-size: 1.05rem; line-height: 1.7; }
.reference-sample { z-index: 1; display: flex; flex-direction: column; gap: .35rem; width: fit-content; padding: 1rem 1.2rem; border: 1px solid rgba(255,255,255,.14); border-radius: .8rem; background: rgba(255,255,255,.07); }
.reference-sample span { color: #91a9b8; font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; }
.reference-sample strong { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92rem; }
.auth-panel { display: grid; place-items: center; padding: 3rem; background: var(--white); }
.auth-form { width: min(100%, 25rem); }
.auth-form h2 { margin: 0; font-size: 2rem; }
.auth-form > .muted { margin: .5rem 0 2rem; line-height: 1.55; }
label { display: grid; gap: .5rem; margin-bottom: 1rem; color: #3d4d5a; font-size: .88rem; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: .65rem; background: var(--white); color: var(--ink); padding: .78rem .9rem; outline: none; transition: border-color .16s, box-shadow .16s; }
input:focus, select:focus, textarea:focus { border-color: var(--cyan-500); box-shadow: 0 0 0 3px rgba(8,166,194,.14); }
input[readonly] { color: var(--muted); background: #f2f5f7; cursor: not-allowed; }
.button { min-height: 2.75rem; border: 0; border-radius: .65rem; padding: .72rem 1rem; font-weight: 800; transition: transform .15s, background .15s; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .55; box-shadow: none; transform: none; }
.button.primary { color: var(--white); background: linear-gradient(135deg, var(--blue-700), var(--cyan-500)); box-shadow: 0 8px 18px rgba(7,93,136,.2); }
.button.secondary { color: var(--blue-700); background: #e5f2f7; }
.button.ghost { color: var(--muted); background: transparent; }
.button.danger { color: var(--white); background: var(--danger); box-shadow: 0 8px 18px rgba(189,47,47,.2); }
.button.full { width: 100%; margin-top: .5rem; }
.link-button { display: inline-grid; place-items: center; text-decoration: none; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 16.5rem minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 1.35rem 1rem; color: #d4e0e8; background: linear-gradient(180deg, var(--navy-950), #0b2438); }
.sidebar-brand { display: flex; align-items: center; gap: .8rem; padding: .2rem .45rem 1.8rem; }
.sidebar-brand div:last-child { display: flex; flex-direction: column; }
.sidebar-brand strong { color: var(--white); font-size: 1rem; }
.sidebar-brand span { color: #8199a9; font-size: .75rem; }
.workspace-switch { display: grid; gap: .35rem; width: calc(100% - .9rem); margin: 0 .45rem 1.3rem; padding: .85rem; border: 1px solid rgba(255,255,255,.14); border-radius: .75rem; color: var(--white); background: #17374f; text-align: left; }
.workspace-switch:hover, .workspace-switch:focus-visible { border-color: #54c5d7; background: #1c405b; }
.workspace-switch-label { color: #9bb6c5; font-size: .68rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.workspace-switch strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .88rem; }
.workspace-switch-action { color: #6cdbeb; font-size: .74rem; font-weight: 800; }
.sidebar nav { display: grid; gap: .35rem; }
.nav-item { display: flex; align-items: center; gap: .75rem; width: 100%; border: 0; border-radius: .65rem; padding: .78rem .85rem; color: #a8bac6; background: transparent; text-align: left; font-weight: 700; }
.nav-item span { display: inline-grid; width: 1.25rem; place-items: center; color: #6e8999; }
.nav-item:hover, .nav-item.active { color: var(--white); background: rgba(255,255,255,.09); }
.nav-item.active span { color: #47c8db; }
.sidebar-foot { margin-top: auto; }
.project-code { display: flex; justify-content: space-between; align-items: center; margin: 0 .45rem 1rem; padding: .8rem; border: 1px solid rgba(255,255,255,.08); border-radius: .6rem; background: rgba(255,255,255,.04); }
.project-code span { color: #8199a9; font-size: .75rem; }
.project-code strong { color: var(--white); font: 700 .82rem ui-monospace, monospace; }
.workspace { min-width: 0; }
.topbar { min-height: 5.5rem; display: flex; align-items: center; gap: 1rem; padding: 1rem clamp(1.2rem, 3vw, 2.5rem); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.92); backdrop-filter: blur(12px); }
.topbar h2 { margin: 0; font-size: 1.45rem; }
.topbar .eyebrow { margin-bottom: .2rem; color: var(--blue-600); font-size: .65rem; }
.active-workspace { display: grid; min-width: 0; max-width: min(24rem, 30vw); gap: .1rem; margin-left: auto; padding: .55rem .85rem; border: 1px solid #cce2e9; border-radius: .65rem; background: #f0f9fb; }
.active-workspace span { color: var(--blue-700); font: 900 .72rem ui-monospace, SFMono-Regular, Menlo, monospace; }
.active-workspace strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .77rem; }
.user-chip { display: flex; align-items: center; gap: .75rem; margin-left: auto; }
.active-workspace + .user-chip { margin-left: 0; }
.user-chip > span { display: grid; width: 2.35rem; height: 2.35rem; place-items: center; border-radius: .7rem; color: var(--blue-700); background: var(--cyan-100); font-size: .78rem; font-weight: 900; }
.user-chip div { display: grid; }
.user-chip strong { font-size: .86rem; }
.user-chip small { color: var(--muted); text-transform: capitalize; }
.menu-button { display: none; }
.content { padding: clamp(1.2rem, 3vw, 2.5rem); }
.page { display: none; }
.page.active { display: block; animation: page-in .2s ease-out; }
@keyframes page-in { from { opacity: 0; transform: translateY(4px); } }
.app-shell.chooser-mode { display: block; min-height: 100vh; }
.chooser-mode .sidebar { display: none; }
.chooser-mode .workspace { min-height: 100vh; }
.chooser-mode .content { max-width: 90rem; margin: 0 auto; padding-top: clamp(1rem, 2.2vw, 1.8rem); }
.chooser-mode .menu-button { display: none; }
.welcome-hero { position: relative; display: flex; justify-content: space-between; align-items: flex-start; gap: 2rem; overflow: hidden; min-height: 12rem; padding: clamp(1.4rem, 2.4vw, 2rem); border-radius: 1.1rem; color: var(--white); background: radial-gradient(circle at 90% 0%, rgba(8,166,194,.35), transparent 35%), linear-gradient(125deg, #0a2034 0%, #123f5c 100%); box-shadow: 0 18px 40px rgba(13,43,62,.16); }
.welcome-hero::after { content: ""; position: absolute; right: -5rem; bottom: -10rem; width: 25rem; height: 25rem; border: 1px solid rgba(255,255,255,.12); border-radius: 50%; box-shadow: 0 0 0 3.5rem rgba(255,255,255,.025), 0 0 0 7rem rgba(255,255,255,.02); pointer-events: none; }
.welcome-hero-copy, .welcome-hero-actions { position: relative; z-index: 1; }
.welcome-hero h1 { max-width: 44rem; margin: .2rem 0 .55rem; font-size: clamp(2rem, 3vw, 2.9rem); line-height: 1.08; letter-spacing: -.035em; }
.welcome-hero-copy > p:not(.eyebrow) { max-width: 43rem; margin: 0; color: #cfdfeb; line-height: 1.6; }
.welcome-hero-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .6rem; }
.welcome-hero-actions .button { min-height: 2.35rem; padding: .55rem .85rem; font-size: .82rem; }
.welcome-admin-button { color: #e6f8fc; background: rgba(255,255,255,.14); }
.welcome-logout-button { color: #c8dce8; background: rgba(255,255,255,.08); }
.welcome-stats { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: 1.2rem; }
.welcome-stats span { display: flex; align-items: baseline; gap: .45rem; padding: .45rem .8rem; border: 1px solid rgba(255,255,255,.17); border-radius: .55rem; color: #d6e9f2; background: rgba(255,255,255,.07); font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.welcome-stats strong { color: var(--white); font-size: 1.1rem; letter-spacing: 0; }
.welcome-section { margin-top: clamp(1.4rem, 2.2vw, 2rem); }
.welcome-section-heading { display: flex; justify-content: space-between; align-items: end; gap: 1.5rem; margin-bottom: 1rem; }
.welcome-section-heading h2, .welcome-overview h2 { margin: 0; font-size: 1.4rem; letter-spacing: -.02em; }
.welcome-section-heading p:not(.eyebrow), .welcome-overview p:not(.eyebrow) { margin: .4rem 0 0; color: var(--muted); font-size: .87rem; }
.welcome-search { width: min(19rem, 100%); margin: 0; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; }
.welcome-search input { margin-top: .35rem; font-size: .86rem; text-transform: none; letter-spacing: 0; }
.workspace-card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.workspace-card { display: grid; align-content: start; gap: .6rem; min-width: 0; min-height: 11rem; padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: .85rem; color: var(--ink); background: var(--white); text-align: left; box-shadow: 0 7px 22px rgba(20,45,65,.045); transition: transform .16s, box-shadow .16s, border-color .16s; }
.workspace-card:hover, .workspace-card:focus-visible { transform: translateY(-3px); border-color: #73c9d8; box-shadow: 0 16px 32px rgba(11,65,90,.12); outline: none; }
.workspace-card-heading { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
.workspace-card-code { display: inline-flex; border-radius: .42rem; padding: .35rem .55rem; color: var(--blue-700); background: #e4f4f8; font: 900 .75rem ui-monospace, SFMono-Regular, Menlo, monospace; }
.workspace-card-inactive { color: #946306; font-size: .7rem; font-weight: 800; }
.workspace-card-name { min-width: 0; font-size: 1.1rem; line-height: 1.3; overflow-wrap: anywhere; }
.workspace-card-details { color: var(--muted); font-size: .8rem; line-height: 1.45; }
.workspace-card-footer { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-top: auto; padding-top: .8rem; border-top: 1px solid #edf1f4; }
.workspace-card-access { color: #6a7c88; font-size: .72rem; font-weight: 700; }
.workspace-card-arrow { color: var(--blue-700); font-size: .78rem; font-weight: 900; white-space: nowrap; }
.department-grid .workspace-card-code { color: #5b4d96; background: #f0ecfa; }
.welcome-empty, .welcome-no-access { padding: 1.25rem 1.4rem; border: 1px dashed #b9cbd5; border-radius: .8rem; color: var(--muted); background: #fff; }
.welcome-no-access { margin-top: 1.5rem; border-style: solid; background: #fff8e9; }
.welcome-no-access h2 { margin: 0 0 .35rem; color: var(--ink); font-size: 1.1rem; }
.welcome-no-access p, .welcome-empty { margin-bottom: 0; font-size: .88rem; line-height: 1.5; }
.welcome-no-access .button { margin-top: 1rem; }
.welcome-overview { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; margin-top: 2rem; padding: 1.4rem 1.6rem; border: 1px solid #c9e5ed; border-radius: .85rem; background: #eaf7fa; }
.welcome-overview .eyebrow { color: var(--blue-700); }
.page-actions, .panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; }
.page-actions { margin-bottom: 1.5rem; }
.page-actions h3, .panel-heading h3 { margin: 0; font-size: 1.15rem; }
.page-actions p, .panel-heading p { margin: .35rem 0 0; font-size: .88rem; }
.button-row { display: flex; gap: .7rem; }
.metric-grid { display: grid; grid-template-columns: repeat(6, minmax(8.5rem, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.metric-card { position: relative; overflow: hidden; min-height: 9rem; padding: 1.2rem; border: 1px solid var(--line); border-radius: .85rem; background: var(--white); box-shadow: 0 5px 18px rgba(20,45,65,.04); }
.metric-card::after { content: ""; position: absolute; inset: auto 0 0; height: 3px; background: var(--cyan-500); }
.metric-card.warning::after { background: #e89b25; }
.metric-card.danger::after, .metric-card.urgent::after { background: var(--danger); }
.metric-card.referral::after { background: #6d5bd0; }
.metric-card span { color: var(--muted); font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.metric-card strong { display: block; margin: .65rem 0 .3rem; font-size: 2.4rem; line-height: 1; }
.metric-card small { color: var(--muted); }
.panel { overflow: hidden; border: 1px solid var(--line); border-radius: .9rem; background: var(--white); box-shadow: var(--shadow); }
.filter-panel { overflow: visible; }
.panel-heading { padding: 1.2rem 1.3rem; border-bottom: 1px solid var(--line); }
.dashboard-panel + .dashboard-panel { margin-top: 1.25rem; }
.text-button { border: 0; color: var(--blue-700); background: transparent; font-weight: 800; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .85rem 1.05rem; border-bottom: 1px solid #edf1f4; text-align: left; white-space: nowrap; }
th { color: var(--muted); background: #f9fbfc; font-size: .72rem; letter-spacing: .05em; text-transform: uppercase; }
td { font-size: .87rem; }
.subject-cell { min-width: 18rem; max-width: 28rem; white-space: normal; line-height: 1.4; }
.reference-cell { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; font-weight: 700; }
.filing-id { display: block; color: #647585; font: 700 .69rem/1.35 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .02em; }
.correspondence-table { table-layout: fixed; }
.correspondence-table th, .correspondence-table td { padding: .72rem .75rem; }
.correspondence-table td { white-space: normal; overflow-wrap: anywhere; vertical-align: middle; }
.correspondence-table tbody tr { transition: background .14s; }
.correspondence-table tbody tr:hover { background: #f8fbfc; }
.correspondence-table .subject-cell { min-width: 0; max-width: none; }
.incoming-table th:nth-child(1) { width: 12%; }
.incoming-table th:nth-child(2) { width: 5%; }
.incoming-table th:nth-child(3) { width: 8%; }
.incoming-table th:nth-child(4) { width: 20%; }
.incoming-table th:nth-child(5) { width: 7%; }
.incoming-table th:nth-child(6) { width: 12%; }
.incoming-table th:nth-child(7) { width: 20%; }
.incoming-table th:nth-child(8) { width: 9%; }
.incoming-table th:nth-child(9) { width: 7%; }
.outgoing-table th:nth-child(1) { width: 14%; }
.outgoing-table th:nth-child(2) { width: 5%; }
.outgoing-table th:nth-child(3) { width: 7%; }
.outgoing-table th:nth-child(4) { width: 20%; }
.outgoing-table th:nth-child(5) { width: 7%; }
.outgoing-table th:nth-child(6) { width: 11%; }
.outgoing-table th:nth-child(7) { width: 20%; }
.outgoing-table th:nth-child(8) { width: 9%; }
.outgoing-table th:nth-child(9) { width: 7%; }
.party-code-badge { display: inline-flex; min-width: 2.8rem; justify-content: center; border: 1px solid transparent; border-radius: .4rem; padding: .28rem .42rem; font-size: .72rem; font-weight: 900; text-decoration: none; }
.party-code-badge.party-color-client { color: #066789; border-color: #b9dfe8; background: #ddf3f7; }
.party-code-badge.party-color-contractor { color: #8a5800; border-color: #efd59e; background: #fff0cc; }
.party-code-badge.party-color-0 { color: #5d3a9b; border-color: #d8c8ef; background: #f0e9fa; }
.party-code-badge.party-color-1 { color: #246b45; border-color: #b9dec9; background: #e3f4ea; }
.party-code-badge.party-color-2 { color: #9a3f62; border-color: #edc3d2; background: #fbe8ef; }
.party-code-badge.party-color-3 { color: #3c568f; border-color: #c6d2eb; background: #eaf0fb; }
.party-code-badge.party-color-4 { color: #7b4b22; border-color: #e6ccb2; background: #faeee2; }
.party-code-badge.party-color-5 { color: #4b626b; border-color: #c9d9de; background: #eaf2f4; }
tr.party-row.party-color-client td:first-child { box-shadow: inset 3px 0 #08a6c2; }
tr.party-row.party-color-contractor td:first-child { box-shadow: inset 3px 0 #d99a28; }
tr.party-row.party-color-0 td:first-child { box-shadow: inset 3px 0 #7c5bb5; }
tr.party-row.party-color-1 td:first-child { box-shadow: inset 3px 0 #3b9663; }
tr.party-row.party-color-2 td:first-child { box-shadow: inset 3px 0 #c15c82; }
tr.party-row.party-color-3 td:first-child { box-shadow: inset 3px 0 #5e79b4; }
tr.party-row.party-color-4 td:first-child { box-shadow: inset 3px 0 #aa7140; }
tr.party-row.party-color-5 td:first-child { box-shadow: inset 3px 0 #708891; }
.cell-stack, .link-stack { display: grid; justify-items: start; align-content: center; gap: .38rem; min-width: 0; }
.link-line { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: .4rem; min-width: 0; }
.link-label { color: var(--muted); font-size: .67rem; font-weight: 800; letter-spacing: .025em; text-transform: uppercase; }
.link-value { min-width: 0; font: 700 .72rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
.cell-stack .badge, .link-stack .badge { width: fit-content; max-width: 100%; justify-self: start; white-space: nowrap; }
.short-name { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-action { min-width: 2.8rem; border: 0; border-radius: .45rem; padding: .45rem .58rem; color: var(--blue-700); background: #eaf4f7; font-size: .76rem; font-weight: 800; white-space: nowrap; }
.table-action.danger-action { color: var(--danger); background: var(--danger-bg); }
.table-action:disabled { cursor: not-allowed; opacity: .45; }
.table-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem .7rem; }
.staff-table { table-layout: fixed; }
.staff-table th, .staff-table td { padding: .7rem .7rem; white-space: normal; overflow-wrap: anywhere; vertical-align: middle; }
.staff-table th:nth-child(1) { width: 12%; }
.staff-table th:nth-child(2) { width: 11%; }
.staff-table th:nth-child(3) { width: 9%; }
.staff-table th:nth-child(4) { width: 18%; }
.staff-table th:nth-child(5) { width: 11%; }
.staff-table th:nth-child(6) { width: 7%; }
.staff-table th:nth-child(7) { width: 13%; }
.staff-table th:nth-child(8) { width: 19%; }
.empty-cell { height: 8rem; color: var(--muted); text-align: center; }
.filters { display: grid; grid-template-columns: minmax(15rem, 2fr) repeat(4, minmax(7rem, 1fr)); gap: .8rem; padding: 1rem 1.1rem; border-bottom: 1px solid var(--line); background: #fbfcfd; }
.outgoing-filters { grid-template-columns: minmax(15rem, 2fr) repeat(4, minmax(7rem, 1fr)); }
.filters label { margin: 0; font-size: .72rem; text-transform: uppercase; letter-spacing: .045em; }
.filters input, .filters select { min-height: 2.6rem; padding: .55rem .7rem; font-size: .86rem; text-transform: none; letter-spacing: 0; }
.badge { display: inline-flex; align-items: center; justify-content: center; min-height: 1.55rem; border-radius: 999px; padding: .22rem .55rem; color: #4f606d; background: #eef2f4; font-size: .7rem; font-weight: 900; text-transform: uppercase; letter-spacing: .04em; }
.badge.normal, .badge.open { color: #35596c; background: #e7f1f5; }
.badge.important, .badge.pending { color: #915209; background: var(--warning-bg); }
.badge.urgent, .badge.overdue { color: var(--danger); background: var(--danger-bg); }
.badge.replied { color: #18724f; background: #e1f5ec; }
.badge.closed { color: #5a6070; background: #ebecef; }
.badge.cancelled { color: #9d3030; background: #fde7e7; }
.badge.superseded { color: #6c5b2d; background: #f6eed4; }
.badge.reply { color: #18724f; background: #e1f5ec; }
.badge.referral { color: #35596c; background: #e7f1f5; }
.category-subject { display: grid; justify-items: start; gap: .38rem; }
.category-badge { display: inline-flex; border-radius: 999px; padding: .16rem .48rem; color: #53616b; background: #edf1f3; font-size: .63rem; font-weight: 900; letter-spacing: .035em; text-transform: uppercase; }
.category-technical, .category-design { color: #075d88; background: #e0f2f7; }
.category-contractual { color: #65409a; background: #eee7f8; }
.category-commercial { color: #276b47; background: #e2f3e9; }
.category-programme { color: #8a5800; background: #fff0cc; }
.category-hse { color: #9d3030; background: #fde7e7; }
.category-quality { color: #176a5e; background: #ddf3ef; }
.category-authority { color: #334f78; background: #e6edf7; }
.category-memos { color: #74436e; background: #f4e6f2; }
.attachment-link { border: 0; padding: 0; color: var(--blue-700); background: transparent; font-size: .74rem; font-weight: 800; text-align: left; text-decoration: underline; text-underline-offset: 2px; }
.status-select { width: auto; max-width: 100%; min-height: 1.75rem; border: 0; border-radius: 999px; padding: .28rem 1.6rem .28rem .62rem; font-size: .7rem; font-weight: 900; letter-spacing: .035em; text-transform: uppercase; box-shadow: none; }
.status-select.draft { color: #59636b; background: #eceff1; }
.status-select.open { color: #35596c; background: #e7f1f5; }
.status-select.pending { color: #915209; background: var(--warning-bg); }
.status-select.overdue { color: var(--danger); background: var(--danger-bg); }
.status-select.replied { color: #18724f; background: #e1f5ec; }
.status-select.issued { color: #35596c; background: #e7f1f5; }
.status-select.awaiting_reply { color: #915209; background: var(--warning-bg); }
.status-select.reply_received { color: #18724f; background: #e1f5ec; }
.status-select.closed { color: #5a6070; background: #ebecef; }
.status-select.cancelled { color: #9d3030; background: #fde7e7; }
.status-select.superseded { color: #6c5b2d; background: #f6eed4; }
.status-select:disabled { cursor: default; opacity: .8; }
.due-overdue { color: var(--danger); font-weight: 800; }
.due-soon { color: var(--warning); font-weight: 800; }
.secondary-text { color: var(--muted); font-size: .76rem; }
.placeholder { display: grid; min-height: 55vh; place-items: center; align-content: center; padding: 3rem; border: 1px dashed #bdccd5; border-radius: 1rem; color: var(--muted); text-align: center; background: rgba(255,255,255,.55); }
.placeholder h3 { margin: 0 0 .5rem; color: var(--ink); }
.placeholder p { margin: 0; }
.toast-region { position: fixed; z-index: 100; top: 1rem; right: 1rem; display: grid; gap: .6rem; }
.toast { max-width: 23rem; padding: .85rem 1rem; border-radius: .65rem; color: var(--white); background: var(--navy-900); box-shadow: var(--shadow); }
.toast.error { background: #8e2727; }
.icon-button { border: 0; background: transparent; }
.backup-panel { margin-top: 1.25rem; }
.backup-summary { padding: 1rem 1.3rem; color: var(--muted); font-size: .88rem; }
.admin-tabs { display: flex; flex-wrap: wrap; gap: .45rem; margin: -0.45rem 0 1.35rem; padding: .45rem; border: 1px solid var(--line); border-radius: .8rem; background: var(--white); box-shadow: 0 6px 20px rgba(20,45,65,.05); }
.admin-tab { border: 0; border-radius: .58rem; padding: .7rem .9rem; color: var(--muted); background: transparent; font-size: .84rem; font-weight: 800; }
.admin-tab:hover { color: var(--blue-700); background: #edf6f8; }
.admin-tab.active { color: var(--white); background: var(--blue-700); }
.admin-section { display: none; }
.admin-section.active { display: block; }
.section-actions { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.section-actions h3 { margin: 0; font-size: 1.05rem; }
.section-actions p { margin: .3rem 0 0; font-size: .86rem; }
.catalogue-heading { margin-top: 1.6rem; }
.admin-workspace-guide { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .75rem; margin: -.3rem 0 1.3rem; padding: .85rem 1rem; border: 1px solid #c9e5ed; border-radius: .7rem; color: #275771; background: #eaf7fa; font-size: .85rem; font-weight: 700; }
.admin-workspace-guide .button { min-height: 2.3rem; padding: .5rem .75rem; font-size: .78rem; }
.team-access-note { max-width: 45rem; font-size: .78rem !important; line-height: 1.45; }
.team-dialog-note { margin: -.35rem 0 1.2rem; font-size: .85rem; line-height: 1.5; }
.activity-more { display: flex; justify-content: center; padding: 1rem; }
#admin-section-voided table { table-layout: fixed; }
#admin-section-voided th, #admin-section-voided td { padding: .7rem .75rem; white-space: normal; overflow-wrap: anywhere; vertical-align: top; }
#admin-section-voided th:nth-child(1) { width: 9%; }
#admin-section-voided th:nth-child(2) { width: 23%; }
#admin-section-voided th:nth-child(3) { width: 17%; }
#admin-section-voided th:nth-child(4) { width: 12%; }
#admin-section-voided th:nth-child(5) { width: 12%; }
#admin-section-voided th:nth-child(6) { width: 20%; }
#admin-section-voided th:nth-child(7) { width: 7%; }

.modal { width: min(48rem, calc(100% - 2rem)); max-height: calc(100vh - 2rem); border: 0; border-radius: 1rem; padding: 0; color: var(--ink); background: var(--white); box-shadow: 0 30px 80px rgba(3, 18, 30, .3); }
.modal::backdrop { background: rgba(4, 18, 29, .68); backdrop-filter: blur(3px); }
.compact-modal { width: min(30rem, calc(100% - 2rem)); }
.staff-modal { width: min(54rem, calc(100% - 2rem)); overflow-y: auto; }
.modal-form { padding: 1.35rem; }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.modal-header h2 { margin: 0; font-size: 1.35rem; }
.modal-header .close-dialog { display: grid; width: 2.25rem; height: 2.25rem; place-items: center; border-radius: .5rem; color: var(--muted); background: #eff3f5; font-size: 1.4rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-workspace-lock { display: grid; gap: .28rem; margin-bottom: 1rem; padding: .8rem .95rem; border: 1px solid #cce2e9; border-radius: .65rem; background: #f0f9fb; }
.form-workspace-lock span { color: var(--blue-700); font-size: .7rem; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }
.form-workspace-lock strong { color: var(--ink); font-size: .93rem; overflow-wrap: anywhere; }
.form-workspace-lock small { color: var(--muted); font-size: .75rem; }
.form-readonly-detail { display: grid; align-content: start; gap: .3rem; margin-bottom: 1rem; padding: .75rem .9rem; border: 1px solid var(--line); border-radius: .65rem; background: #f9fbfc; }
.form-readonly-detail span { color: #3d4d5a; font-size: .88rem; font-weight: 700; }
.form-readonly-detail strong { overflow-wrap: anywhere; font-size: .88rem; }
.form-readonly-detail small { color: var(--muted); font-size: .74rem; line-height: 1.4; }
.checkbox-label { display: flex; align-items: flex-start; gap: .75rem; padding: .85rem; border: 1px solid var(--line); border-radius: .7rem; background: #f9fbfc; }
.checkbox-label input { width: 1.05rem; height: 1.05rem; margin-top: .12rem; accent-color: var(--blue-700); }
.checkbox-label span { display: grid; gap: .2rem; }
.checkbox-label small { color: var(--muted); font-weight: 500; }
.field-help { color: var(--muted); font-size: .74rem; font-weight: 500; line-height: 1.4; }
.staff-dialog-note { margin: -.25rem 0 1.1rem; font-size: .86rem; line-height: 1.5; }
.staff-assignment-heading { margin: 1rem 0 .8rem; }
.staff-assignment-heading h3 { margin: 0; font-size: 1rem; }
.staff-assignment-heading p { margin: .35rem 0 0; font-size: .8rem; line-height: 1.45; }
.staff-password-field { display: grid; gap: .1rem; margin-bottom: 1rem; }
.staff-password-field label { margin: 0; }
.staff-password-field .field-help { margin-top: .2rem; }
.staff-password-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .4rem; }
.staff-password-actions .button { min-height: 2.25rem; padding: .45rem .7rem; font-size: .76rem; }
.staff-workspace-search { margin-bottom: .65rem; }
.staff-workspace-search input { padding: .58rem .75rem; }
.staff-workspace-assignments { display: grid; gap: 1rem; }
.staff-assignment-section { display: grid; gap: .45rem; min-width: 0; }
.staff-assignment-section-heading { margin: 0; color: var(--ink); font-size: .85rem; }
.staff-assignment-list { display: grid; gap: .45rem; max-height: 14rem; overflow-y: auto; padding: .12rem; }
.staff-assignment-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(12rem, .9fr); align-items: start; gap: .4rem 1rem; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: .65rem; background: #f9fbfc; }
.staff-assignment-row.selected { border-color: #9bcddd; background: #f0f9fb; }
.staff-assignment-main { display: flex; align-items: flex-start; gap: .6rem; min-width: 0; margin: 0; cursor: pointer; }
.staff-assignment-main input { flex: 0 0 auto; width: 1.05rem; height: 1.05rem; margin: .08rem 0 0; padding: 0; accent-color: var(--blue-700); }
.staff-assignment-main input:disabled { cursor: not-allowed; }
.staff-assignment-name { display: grid; gap: .2rem; min-width: 0; }
.staff-assignment-name strong { font-size: .82rem; overflow-wrap: anywhere; }
.staff-assignment-name small { color: var(--muted); font-size: .7rem; }
.staff-check { display: flex; align-items: center; gap: .45rem; margin: 0; font-size: .76rem; }
.staff-check input { flex: 0 0 auto; width: 1rem; height: 1rem; accent-color: var(--blue-700); }
.staff-role-options { display: flex; flex-wrap: wrap; grid-column: 1; gap: .5rem 1rem; padding-left: 1.65rem; }
.staff-preparer-control { display: grid; grid-column: 2; grid-row: 1 / span 2; gap: .4rem; min-width: 0; }
.staff-preparer-control input[type="text"] { padding: .42rem .55rem; font-size: .76rem; }
.staff-preparer-control input[type="text"]:disabled { opacity: .6; }
.staff-preparer-control .staff-check { align-items: flex-start; }
.staff-no-match { margin: 0; padding: .25rem .15rem; font-size: .78rem; }
.staff-access-summary { margin: .85rem 0; padding: .8rem .9rem; border: 1px solid #c9e5ed; border-radius: .65rem; color: #275771; background: #f0f9fb; font-size: .78rem; line-height: 1.45; overflow-wrap: anywhere; }
.staff-access-summary p { margin: 0; }
.staff-access-summary p + p { margin-top: .35rem; }
.staff-advanced-options, .admin-advanced-access { border: 1px solid var(--line); border-radius: .7rem; background: #f9fbfc; }
.staff-advanced-options { margin: 1rem 0; padding: .8rem .95rem; }
.staff-advanced-options summary, .admin-advanced-access summary { color: var(--blue-700); cursor: pointer; font-size: .83rem; font-weight: 800; }
.staff-advanced-options .form-grid { margin-top: 1rem; }
.staff-manager-toggle { margin: .1rem 0 .7rem; }
.staff-advanced-options .field-help { display: block; margin: 0; }
.admin-advanced-access { padding: 1rem; }
.admin-advanced-access > .section-actions { margin-top: 1rem; }
.admin-advanced-access > .panel { margin-bottom: 0; }
.staff-profile-warning { color: #965a00; font-weight: 800; }
.employee-scope-hint { margin: -.4rem 0 1rem; padding: .75rem .85rem; border: 1px solid #e5d69e; border-radius: .6rem; color: #704e10; background: #fff8e5; font-size: .79rem; line-height: 1.5; }
.file-field input { padding: .55rem; background: #f9fbfc; }
.attachment-box { margin-bottom: 1rem; padding: .75rem; border: 1px solid var(--line); border-radius: .7rem; background: #f9fbfc; }
.attachment-list { display: grid; gap: .65rem; }
.attachment-item { display: flex; align-items: center; justify-content: space-between; gap: .8rem; min-width: 0; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: .6rem; background: var(--white); }
.attachment-details { display: grid; min-width: 0; gap: .2rem; }
.attachment-details strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .84rem; }
.attachment-download { flex: 0 0 auto; min-height: 2.15rem; padding: .48rem .7rem; font-size: .76rem; }
.deadline-box { display: grid; grid-template-columns: minmax(12rem, .8fr) 1.2fr; align-items: end; gap: 1rem; margin-bottom: 1rem; padding: 1rem; border-radius: .7rem; background: #f0f7f9; }
.deadline-box label { margin: 0; }
.quick-dates { display: flex; flex-wrap: wrap; gap: .45rem; }
.quick-dates span { width: 100%; color: var(--muted); font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.quick-dates button { border: 1px solid #c9dde5; border-radius: 999px; padding: .48rem .7rem; color: var(--blue-700); background: var(--white); font-size: .78rem; font-weight: 800; }
.reference-preview { margin: -.2rem 0 1.2rem; padding: .8rem 1rem; border-left: 3px solid var(--cyan-500); color: #356077; background: #eef8fa; font: 700 .82rem ui-monospace, SFMono-Regular, Menlo, monospace; }
.action-reference, .form-current-value { display: block; margin: 0 0 1rem; padding: .7rem .85rem; border: 1px solid var(--line); border-radius: .55rem; color: var(--ink); background: #f7fafb; font: 700 .78rem/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
.form-current-value { margin: .35rem 0 0; }
.letter-action-list { display: grid; gap: .55rem; }
.letter-action { width: 100%; border: 1px solid #d3e2e8; border-radius: .6rem; padding: .72rem .85rem; color: var(--blue-700); background: #f3f9fb; text-align: left; font-size: .86rem; font-weight: 800; }
.letter-action:hover { background: #e5f4f8; }
.letter-action.danger-text { border-color: #efd1d1; color: var(--danger); background: var(--danger-bg); }
.letter-action.danger-text:hover { background: #fce5e5; }
.generated-reference-card { margin-bottom: .4rem; padding: 1.25rem; border: 1px solid #b9dce6; border-radius: .85rem; background: #effafd; text-align: center; }
.generated-reference-card span { display: block; color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.generated-reference-card strong { display: block; margin: .65rem 0; color: var(--blue-700); font: 800 1.05rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; user-select: all; }
.generated-reference-card p { margin: 0; color: var(--muted); font-size: .88rem; }
.confirmation-copy { margin: 0 0 .6rem; line-height: 1.55; }
.modal-actions { display: flex; justify-content: flex-end; gap: .7rem; margin-top: .5rem; padding-top: 1rem; border-top: 1px solid var(--line); }

.status-toggle { display: inline-flex; align-items: center; gap: .45rem; border: 0; color: var(--muted); background: transparent; font-size: .78rem; font-weight: 800; }
.status-toggle::before { content: ""; width: .6rem; height: .6rem; border-radius: 50%; background: #86949d; }
.status-toggle.active::before { background: #1e9d6c; }

@media (max-width: 1250px) {
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .workspace-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1300px) {
  .page-actions { align-items: flex-start; flex-direction: column; }
  .page-actions .button-row { flex-wrap: wrap; }
  .filters, .outgoing-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters .search-field { grid-column: 1 / -1; }
  .filter-panel { overflow: hidden; }
  .filter-panel .table-wrap { overflow-x: hidden; }
  .correspondence-table { display: block; width: 100%; min-width: 0; table-layout: auto; }
  .correspondence-table thead { display: none; }
  .correspondence-table tbody { display: grid; gap: .75rem; padding: .8rem; }
  .correspondence-table tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: hidden; min-width: 0; border: 1px solid var(--line); border-radius: .65rem; }
  .correspondence-table td { display: flex; flex-direction: column; align-items: flex-start; gap: .25rem; min-width: 0; padding: .65rem .75rem; }
  .correspondence-table td::before { content: attr(data-label); color: var(--muted); font-size: .65rem; font-weight: 800; letter-spacing: .045em; text-transform: uppercase; }
  .correspondence-table td:first-child, .correspondence-table td:nth-child(4), .correspondence-table td:nth-child(7), .correspondence-table .empty-cell { grid-column: 1 / -1; }
  .correspondence-table td:last-child { align-items: flex-end; }
  .correspondence-table .empty-cell { justify-content: center; align-items: center; }
  .correspondence-table .empty-cell::before { display: none; }
  .staff-table-wrap { overflow-x: hidden; }
  .staff-table { display: block; width: 100%; min-width: 0; table-layout: auto; }
  .staff-table thead { display: none; }
  .staff-table tbody { display: grid; gap: .75rem; padding: .8rem; }
  .staff-table tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: hidden; min-width: 0; border: 1px solid var(--line); border-radius: .65rem; }
  .staff-table td { display: flex; flex-direction: column; align-items: flex-start; gap: .35rem; min-width: 0; padding: .6rem .75rem; }
  .staff-table td::before { content: attr(data-label); color: var(--muted); font-size: .65rem; font-weight: 800; letter-spacing: .045em; text-transform: uppercase; }
  .staff-table td:first-child, .staff-table td:nth-child(4), .staff-table td:nth-child(7), .staff-table td:last-child, .staff-table .empty-cell { grid-column: 1 / -1; }
  .staff-table .empty-cell { justify-content: center; align-items: center; }
  .staff-table .empty-cell::before { display: none; }
}

@media (max-width: 780px) {
  .auth-layout { grid-template-columns: 1fr; }
  .auth-brand { min-height: 15rem; padding: 2rem; justify-content: flex-end; }
  .auth-brand h1 { font-size: 2.6rem; }
  .auth-brand .brand-mark, .auth-copy, .reference-sample { display: none; }
  .auth-panel { padding: 2rem 1.3rem; }
  .app-shell { display: block; }
  .chooser-mode .topbar { padding: 1rem; }
  .welcome-hero { flex-direction: column; min-height: 0; }
  .welcome-hero-actions { justify-content: flex-start; }
  .welcome-section-heading { align-items: stretch; flex-direction: column; gap: .8rem; }
  .welcome-search { width: 100%; }
  .active-workspace { max-width: 35vw; }
  .sidebar { position: fixed; z-index: 50; left: 0; transform: translateX(-105%); width: 17rem; transition: transform .2s; box-shadow: 10px 0 30px rgba(0,0,0,.2); }
  .sidebar.open { transform: translateX(0); }
  .menu-button { display: inline-grid; width: 2.5rem; height: 2.5rem; place-items: center; border-radius: .55rem; background: #e8f0f4; }
  .user-chip div { display: none; }
  .content { padding: 1rem; }
  .page-actions { align-items: flex-start; flex-direction: column; }
  .section-actions { align-items: flex-start; flex-direction: column; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .filters { grid-template-columns: 1fr 1fr; }
  .outgoing-filters { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  .correspondence-table { min-width: 0; }
  .staff-assignment-row { grid-template-columns: minmax(0, 1fr) minmax(10rem, .8fr); }
}

@media (max-width: 480px) {
  .workspace-card-grid { grid-template-columns: 1fr; }
  .welcome-hero h1 { font-size: 2rem; }
  .welcome-stats { margin-top: 1.2rem; }
  .welcome-overview { align-items: stretch; flex-direction: column; }
  .welcome-overview .button { width: 100%; }
  .active-workspace { display: none; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 7.4rem; }
  .button-row { width: 100%; }
  .button-row .button { flex: 1; }
  .filters, .form-grid, .deadline-box { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .staff-assignment-row { grid-template-columns: 1fr; }
  .staff-preparer-control { grid-column: 1; grid-row: auto; }
  .deadline-box.span-2 { grid-column: auto; }
  .modal-form { padding: 1rem; }
  .correspondence-table tbody tr { grid-template-columns: 1fr; }
  .correspondence-table td { grid-column: 1 / -1; }
  .correspondence-table td:last-child { align-items: flex-start; }
  .staff-table tbody tr { grid-template-columns: 1fr; }
  .staff-table td { grid-column: 1 / -1; }
}
