:root {
  --portal-navy: #081c2b;
  --portal-navy-2: #102f43;
  --portal-blue: #0875ad;
  --portal-blue-dark: #075b8d;
  --portal-cyan: #43b8d6;
  --portal-ink: #142a36;
  --portal-text: #4b606b;
  --portal-muted: #70828b;
  --portal-line: #d8e2e7;
  --portal-soft: #f2f6f8;
  --portal-blue-soft: #e9f4f9;
  --portal-success: #16754a;
  --portal-danger: #b42318;
}
html.dark-mode, .portal-body.dark-mode {
  --portal-navy: #061721; --portal-navy-2: #0d2735; --portal-blue: #1a9bd0; --portal-blue-dark: #73c8ec;
  --portal-cyan: #4ac2df; --portal-ink: #e8f1f5; --portal-text: #bfd0d8; --portal-muted: #91a7b1;
  --portal-line: #2a4552; --portal-soft: #081820; --portal-blue-soft: #102d3a; --portal-success: #5bc997; --portal-danger: #ff7d72;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body.portal-body { margin: 0; min-height: 100vh; color: var(--portal-ink); background: var(--portal-soft); font-family: 'IBM Plex Sans', Arial, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--portal-blue-dark); text-underline-offset: 3px; }
button, input, textarea, select { font: inherit; }
.portal-body.dark-mode input, .portal-body.dark-mode textarea, .portal-body.dark-mode select { color: var(--portal-ink); background: #0d222c; border-color: var(--portal-line); }
.theme-toggle { border: 1px solid #496573; border-radius: 5px; padding: 7px 10px; color: #fff; background: transparent; cursor: pointer; }
:focus-visible { outline: 3px solid var(--portal-cyan); outline-offset: 2px; }

.portal-header { position: sticky; top: 0; z-index: 30; color: #fff; background: var(--portal-navy); border-bottom: 3px solid var(--portal-blue); }
.portal-header__inner { width: min(1360px, calc(100% - 40px)); min-height: 68px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 28px; }
.portal-brand { display: inline-flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; }
.portal-brand img { width: 40px; height: 40px; object-fit: contain; }
.portal-brand__copy { display: grid; gap: 1px; }
.portal-brand__copy strong { font-size: 16px; letter-spacing: .09em; }
.portal-brand__copy small { color: #9eb5c0; font-size: 10px; letter-spacing: .05em; }
.portal-context { display: inline-flex; align-items: center; gap: 10px; }
.portal-context__badge { padding: 6px 9px; color: #8eddf0; border: 1px solid rgba(142,221,240,.35); font-family: 'IBM Plex Mono', monospace; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.portal-header nav { display: flex; align-items: center; gap: 8px; }
.portal-header nav a { min-height: 40px; padding: 0 13px; display: inline-flex; align-items: center; color: #d8e5ea; text-decoration: none; font-size: 13px; font-weight: 500; }
.portal-header nav a:hover { color: #fff; background: rgba(255,255,255,.08); }

.wrap { width: min(1360px, calc(100% - 40px)); min-height: calc(100vh - 150px); margin: 0 auto; padding: 38px 0 70px; }
.topline { margin-bottom: 24px; padding-bottom: 24px; display: flex; gap: 28px; justify-content: space-between; align-items: flex-end; border-bottom: 1px solid var(--portal-line); }
.topline h1, .panel h1 { margin: 0 0 8px; font-size: clamp(30px, 4vw, 44px); line-height: 1.06; font-weight: 400; letter-spacing: -.035em; }
.topline p { max-width: 820px; margin: 4px 0; color: var(--portal-text); line-height: 1.55; }
h2 { margin: 0 0 18px; font-size: 23px; line-height: 1.25; font-weight: 500; letter-spacing: -.02em; }
h3 { margin: 26px 0 13px; font-size: 17px; font-weight: 600; }
p { color: var(--portal-text); line-height: 1.6; }
.portal-kicker { margin: 0 0 12px; color: var(--portal-blue-dark); font-family: 'IBM Plex Mono', monospace; font-size: 11px; font-weight: 500; letter-spacing: .09em; text-transform: uppercase; }

.panel { margin: 18px 0; padding: 25px; overflow-x: auto; background: #fff; border: 1px solid var(--portal-line); border-top: 3px solid var(--portal-navy-2); border-radius: 2px; box-shadow: 0 8px 28px rgba(8,28,43,.045); }
.panel > .panel { margin: 16px 0; border-top-color: var(--portal-line); box-shadow: none; }
.panel > :first-child { margin-top: 0; }
.panel > :last-child { margin-bottom: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 16px; }
.metric { min-height: 112px; padding: 18px; background: var(--portal-blue-soft); border-top: 3px solid var(--portal-blue); color: var(--portal-ink); line-height: 1.65; }
.metric strong { color: var(--portal-blue-dark); font-family: 'IBM Plex Mono', monospace; font-size: 11px; font-weight: 500; letter-spacing: .055em; text-transform: uppercase; }

label { display: block; margin: 13px 0; color: #334b57; font-size: 13px; font-weight: 600; }
input, textarea, select { width: 100%; min-height: 46px; margin-top: 7px; padding: 11px 12px; color: var(--portal-ink); background: #fff; border: 1px solid #b9c8d0; border-radius: 2px; outline: none; transition: border-color .15s ease, box-shadow .15s ease; }
textarea { min-height: 104px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--portal-blue); box-shadow: 0 0 0 3px rgba(8,117,173,.12); }
input[type="checkbox"] { width: 18px; min-height: 18px; margin: 0 8px 0 0; vertical-align: middle; accent-color: var(--portal-blue); }
input[type="file"] { padding: 9px; }

.btn, button { min-height: 42px; padding: 10px 15px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--portal-blue); border-radius: 2px; color: #fff; background: var(--portal-blue); text-decoration: none; font-size: 13px; font-weight: 600; cursor: pointer; transition: background .15s ease, border-color .15s ease; }
.btn:hover, button:hover { background: var(--portal-blue-dark); border-color: var(--portal-blue-dark); }
.btn.light, .light { color: var(--portal-blue-dark); background: #fff; border-color: #a9bdc8; }
.btn.light:hover, .light:hover { background: var(--portal-blue-soft); border-color: var(--portal-blue); }
.danger { color: #fff; background: var(--portal-danger); border-color: var(--portal-danger); }
.danger:hover { background: #8f1c13; border-color: #8f1c13; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pagination { justify-content: space-between; margin: 12px 0; }
.inline { display: inline-flex; margin: 0; }
.inline button { width: auto; }

.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--portal-line); }
table { width: 100%; min-width: 680px; border-collapse: collapse; background: #fff; font-size: 13px; }
th { padding: 12px 13px; color: #dce8ed; background: var(--portal-navy-2); border-right: 1px solid rgba(255,255,255,.1); text-align: left; font-family: 'IBM Plex Mono', monospace; font-size: 10px; font-weight: 500; letter-spacing: .055em; text-transform: uppercase; white-space: nowrap; }
td { padding: 13px; color: #334c58; border-bottom: 1px solid var(--portal-line); vertical-align: top; line-height: 1.45; }
tbody tr:hover td { background: #f7fafb; }
td .actions { min-width: 150px; }

.success, .error { margin: 16px 0; padding: 13px 15px; border-radius: 2px; font-size: 14px; }
.success { color: #0c5a36; background: #eaf8f0; border: 1px solid #a8ddbe; }
.error { color: #8b1b13; background: #fff0ef; border: 1px solid #efb5b1; }
.note { color: var(--portal-muted); font-size: 13px; line-height: 1.55; }
.presence-online, .presence-offline { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.presence-online { color: var(--portal-success); }
.presence-offline { color: var(--portal-danger); }
.presence-online::before, .presence-offline::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 15%, transparent); }

.auth-panel { width: min(490px, 100%); margin: clamp(34px, 8vh, 90px) auto; padding: clamp(26px, 5vw, 42px); border-top: 5px solid var(--portal-blue); box-shadow: 0 18px 55px rgba(8,28,43,.10); }
.auth-panel h1 { margin-bottom: 12px; }
.auth-panel form { margin-top: 24px; }
.auth-panel button { width: 100%; min-height: 48px; margin-top: 8px; }
.auth-links { display: flex; justify-content: space-between; gap: 16px; margin-top: 22px; font-size: 13px; }

.portal-footer { color: #8da5b1; background: #04131d; }
.portal-footer__inner { width: min(1360px, calc(100% - 40px)); min-height: 66px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 24px; font-size: 12px; }
.portal-footer a { color: #b9d0da; text-decoration: none; }

/* Coordinated operational shells */
.admin-shell { background: var(--portal-soft); }
.admin-sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; width: 232px; padding: 22px 15px; display: flex; flex-direction: column; color: #fff; background: var(--portal-navy); }
.admin-brand { display: flex; align-items: center; gap: 11px; color: #fff; text-decoration: none; }
.admin-brand img { width: 36px; height: 36px; object-fit: contain; }
.admin-brand span { display: grid; }
.admin-brand strong { font-size: 14px; letter-spacing: .1em; }
.admin-brand small { color: #90acb9; font-family: 'IBM Plex Mono', monospace; font-size: 9px; letter-spacing: .08em; }
.admin-sidebar__nav { display: grid; gap: 3px; margin-top: 30px; }
.admin-sidebar__nav a { min-height: 42px; padding: 0 12px; display: flex; align-items: center; color: #bfd3dc; text-decoration: none; border-left: 3px solid transparent; font-size: 13px; font-weight: 500; }
.admin-sidebar__nav a:hover, .admin-sidebar__nav a.is-active { color: #fff; background: #12394d; border-left-color: var(--portal-cyan); }
.admin-sidebar__section { margin: 22px 12px 6px; color: #718f9d; font-family: 'IBM Plex Mono', monospace; font-size: 9px; letter-spacing: .09em; text-transform: uppercase; }
.admin-sidebar__account { margin-top: auto; padding: 16px 10px 0; display: grid; gap: 4px; border-top: 1px solid #254657; }
.admin-sidebar__account strong { font-size: 13px; }
.admin-sidebar__account small { color: #90acb9; font-size: 11px; }
.admin-sidebar__account a { margin-top: 8px; color: #8eddf0; font-size: 12px; }
.admin-sidebar__account form { margin: 4px 0 0; }
.admin-logout { min-height: 34px; padding: 4px 0; justify-content: flex-start; color: #d7e5ea; background: transparent; border: 0; }
.admin-logout:hover { color: #fff; background: transparent; border: 0; }
.admin-main { min-height: 100vh; margin-left: 232px; padding: 32px 30px 68px; }
.admin-main > * { max-width: 1450px; margin-inline: auto; }
.admin-mobile-bar { display: none; }
.admin-main .topline { padding-bottom: 18px; }
.admin-main .topline h1 { font-size: clamp(28px, 3vw, 38px); font-weight: 500; }
.admin-main .panel { border-top-width: 1px; border-radius: 5px; }
.admin-main .workspace-grid .panel { margin: 0; }
.command-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 0 0 15px; }
.command-metric { min-width: 0; padding: 17px; background: #fff; border: 1px solid var(--portal-line); border-top: 3px solid var(--portal-blue); box-shadow: 0 6px 20px rgba(8,28,43,.04); }
.command-metric.is-alert { border-top-color: var(--portal-danger); }
.command-metric span { display: block; color: var(--portal-muted); font-family: 'IBM Plex Mono', monospace; font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }
.command-metric strong { display: block; margin: 5px 0 2px; color: var(--portal-ink); font-size: 25px; }
.command-metric small { color: var(--portal-success); }
.command-metric.is-alert small { color: var(--portal-danger); }
.command-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr); gap: 14px; }
.command-grid > * { min-width: 0; }
.command-panel { margin: 0 !important; }
.command-panel__head, .client-card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.command-panel__head h2, .client-card__head h2 { margin: 0; font-size: 17px; }
.command-list { display: grid; }
.command-row { padding: 12px 0; display: grid; grid-template-columns: 9px minmax(0, 1fr) auto; align-items: center; gap: 11px; border-top: 1px solid #e4ecef; color: inherit; text-decoration: none; }
.command-row:first-child { border-top: 0; }
.command-row__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--portal-blue); }
.command-row__dot.is-urgent { background: var(--portal-danger); }
.command-row__dot.is-warning { background: #c47b15; }
.command-row b, .command-row small { display: block; min-width: 0; overflow-wrap: anywhere; }
.command-row small { color: var(--portal-muted); }
.status-pill { padding: 4px 8px; color: var(--portal-blue-dark); background: var(--portal-blue-soft); border-radius: 12px; font-size: 10px; font-weight: 600; white-space: nowrap; }
.status-pill.is-urgent { color: #982017; background: #fff0ef; }
.sla-pill { display: inline-block; padding: 4px 8px; border-radius: 12px; color: #155f3a; background: #eaf8f0; font-size: 10px; font-weight: 700; white-space: nowrap; }
.sla-pill.is-due { color: #7a4b08; background: #fff6df; }
.sla-pill.is-breached { color: #982017; background: #fff0ef; }
.sla-pill.is-unknown { color: var(--portal-muted); background: #eef2f4; }
.sla-due { display: block; margin-top: 4px; color: var(--portal-muted); white-space: nowrap; }
.quick-action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quick-action { min-height: 68px; padding: 13px; display: block; color: var(--portal-ink); background: #f4f8fa; border: 1px solid var(--portal-line); text-decoration: none; }
.quick-action:hover { border-color: var(--portal-blue); }
.quick-action strong, .quick-action small { display: block; }
.quick-action small { margin-top: 2px; color: var(--portal-muted); }

.client-header { position: sticky; top: 0; z-index: 30; color: #fff; background: var(--portal-navy); }
.client-header__inner { width: min(1400px, calc(100% - 52px)); min-height: 70px; margin: auto; display: flex; align-items: center; gap: 32px; }
.client-header nav { display: flex; align-items: center; gap: 4px; flex: 1; }
.client-header nav a { min-height: 42px; padding: 0 13px; display: inline-flex; align-items: center; color: #bfd3dc; text-decoration: none; border-radius: 3px; }
.client-header nav a:hover { color: #fff; background: #153d52; }
.client-header__account { color: #d7e5ea; font-size: 12px; white-space: nowrap; }
.client-main { width: min(1400px, calc(100% - 52px)); min-height: calc(100vh - 136px); margin: auto; padding: 34px 0 64px; }
.client-home .topline { border: 0; margin-bottom: 22px; padding: 0; }
.client-home .topline h1 { font-size: clamp(31px, 4vw, 42px); font-weight: 500; }
.client-service-status { margin-bottom: 16px; padding: 12px 15px; display: flex; align-items: center; gap: 9px; flex-wrap: wrap; color: #0c6040; background: #eaf7f1; border: 1px solid #bfe1d2; border-radius: 5px; }
.client-service-status::before { content: ''; width: 9px; height: 9px; flex: 0 0 9px; border-radius: 50%; background: var(--portal-success); }
.client-home-metrics { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; margin-bottom: 16px; }
.client-home-metric { min-width: 0; padding: 17px; background: #fff; border: 1px solid var(--portal-line); border-top: 3px solid var(--portal-blue); border-radius: 5px; }
.client-home-metric span { display: block; color: var(--portal-muted); font-family: 'IBM Plex Mono', monospace; font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }
.client-home-metric strong { display: block; margin: 6px 0 2px; font-size: 24px; }
.client-home-metric small { color: var(--portal-success); }
.client-home-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(310px, .8fr); gap: 15px; }
.client-home-grid > * { min-width: 0; }
.client-home .panel { margin: 0 0 15px; padding: 20px; overflow-x: auto; border-top-width: 1px; border-radius: 6px; }
.client-health-summary { padding: 13px; display: flex; justify-content: space-between; gap: 12px; background: #f4f8fa; border: 1px solid var(--portal-line); border-radius: 5px; }
.client-health-summary + .client-health-summary { margin-top: 9px; }
.client-health-summary strong, .client-health-summary small { display: block; }
.client-health-summary small { color: var(--portal-muted); }
.client-health-check { width: 34px; height: 34px; flex: 0 0 34px; display: grid; place-items: center; color: var(--portal-success); background: #dff3e9; border-radius: 50%; font-weight: 600; }
.client-work-item { padding: 12px 0; border-top: 1px solid #e4ecef; }
.client-work-item:first-child { border-top: 0; }
.client-work-item time { color: var(--portal-muted); font-family: 'IBM Plex Mono', monospace; font-size: 9px; letter-spacing: .06em; text-transform: uppercase; }
.client-work-item strong { display: block; margin: 3px 0; }
.client-work-item p { margin: 0; }
.client-home-details { display: grid; grid-template-columns: minmax(0,1fr); gap: 15px; margin-top: 18px; }
.client-home-details > * { min-width: 0; }
.report-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 16px; }
.report-toolbar form { display: flex; align-items: end; gap: 12px; margin: 0; }
.report-toolbar label { margin: 0; min-width: 210px; }
.report-metrics { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 14px; margin: 18px 0; }
.report-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; }
.report-grid > * { min-width: 0; }

@media (max-width: 1100px) {
  .command-metrics, .client-home-metrics, .report-metrics { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .command-grid, .client-home-grid, .client-home-details, .report-grid { grid-template-columns: minmax(0,1fr); }
}

@media (max-width: 900px) {
  .admin-mobile-bar { min-height: 64px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; color: #fff; background: var(--portal-navy); }
  .admin-mobile-bar .admin-brand img { width: 34px; height: 34px; }
  .admin-menu-toggle { min-height: 38px; color: #fff; background: #12394d; border-color: #426477; }
  .admin-sidebar { width: min(290px, 88vw); transform: translateX(-102%); transition: transform .18s ease; box-shadow: 16px 0 40px rgba(4,19,29,.28); }
  .admin-sidebar.is-open { transform: translateX(0); }
  .admin-main { margin-left: 0; padding: 25px 20px 56px; }
  .client-header__inner { width: min(100% - 32px, 1400px); }
  .client-header nav { display: none; }
  .client-header__account { margin-left: auto; }
  .client-main { width: min(100% - 32px, 1400px); padding-top: 26px; }
  .portal-header__inner { min-height: 62px; }
  .portal-brand__copy small { display: none; }
  .portal-header nav a:not(:last-child) { display: none; }
  .wrap { padding-top: 26px; }
  .topline { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 760px) {
  .command-metrics, .client-home-metrics, .report-metrics { grid-template-columns: minmax(0,1fr); }
  .report-toolbar, .report-toolbar form { align-items: stretch; flex-direction: column; }
  .report-toolbar form, .report-toolbar label, .report-toolbar button { width: 100%; }
  .command-row { grid-template-columns: 9px minmax(0,1fr); }
  .command-row .status-pill { grid-column: 2; justify-self: start; }
  .quick-action-grid { grid-template-columns: minmax(0,1fr); }
  .client-header__account { display: none; }
  .client-main { width: min(100% - 24px, 1400px); }
  .client-home .topline .actions { width: 100%; }
  .client-service-status span { flex: 1 1 100%; }
  .client-home .panel { padding: 18px 16px; }
  .portal-header__inner, .wrap, .portal-footer__inner { width: min(100% - 24px, 1360px); }
  .portal-context__badge { display: none; }
  .portal-brand img { width: 36px; height: 36px; }
  .portal-header nav a { padding-inline: 10px; }
  .wrap { padding-bottom: 48px; }
  .panel { padding: 19px 16px; }
  .topline h1, .panel h1 { font-size: 31px; }
  .actions, .actions .btn, .actions button, .actions .inline { width: 100%; }
  .actions .inline button { width: 100%; }
  .metric { min-height: 0; }
  table { min-width: 620px; }
  .auth-panel { margin-block: 28px; }
  .auth-links { align-items: flex-start; flex-direction: column; }
  .portal-footer__inner { padding: 18px 0; align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; }
}

.compact-client-form { max-width: 1040px; }
.compact-client-form .compact-fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 14px; }
.compact-client-form label { margin: 0; }
.compact-client-form textarea { min-height: 68px; }
.client-device-groups { display: grid; gap: 10px; }
.client-device-group, .installed-software { border: 1px solid var(--portal-line); border-radius: 7px; background: #fff; overflow: hidden; }
.portal-body.dark-mode .client-device-group,
.portal-body.dark-mode .installed-software,
.portal-body.dark-mode .panel,
.portal-body.dark-mode .card,
.portal-body.dark-mode .command-metric,
.portal-body.dark-mode .quick-action,
.portal-body.dark-mode .client-home-metric,
.portal-body.dark-mode .client-health-summary { background: #0d222c; }
.portal-body.dark-mode .btn.light,
.portal-body.dark-mode .light { color: var(--portal-blue-dark); background: #0d222c; border-color: var(--portal-line); }
.client-device-group > summary, .installed-software > summary { padding: 14px 16px; font-weight: 600; color: var(--portal-ink); background: var(--portal-blue-soft); cursor: pointer; }
.client-device-group .table-wrap, .installed-software .installed-software__content { margin: 0; padding: 12px; }
.audit-evidence { min-width: 190px; }
.audit-evidence summary { cursor: pointer; font-weight: 600; color: var(--portal-blue-dark); }
.audit-evidence pre { max-width: 420px; max-height: 260px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; padding: 10px; border: 1px solid var(--portal-line); border-radius: 8px; background: var(--portal-blue-soft); font: 12px/1.45 "IBM Plex Mono", monospace; }
.server-attention { border-left: 5px solid #d97706; background: #fff7ed; }
.portal-body.dark-mode .server-attention { background: #352311; }
.technician-type { display: inline-flex; margin-top: 4px; padding: 2px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--portal-blue-soft); color: var(--portal-blue-dark); }
@media (max-width: 1050px) { .compact-client-form .compact-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) { .compact-client-form .compact-fields { grid-template-columns: 1fr; } }
