:root {
  color-scheme: light;
  --ink: #123b3b;
  --deep: #0d2929;
  --ocean: #2f7075;
  --lime: #d8f36a;
  --paper: #f3f4ed;
  --line: #d7ded7;
  --muted: #657371;
  font-family: "DM Sans", Arial, sans-serif;
}

* { box-sizing: border-box; }
body { min-height: 100vh; margin: 0; color: var(--deep); background: var(--paper); line-height: 1.55; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.portal-header { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 12px max(24px, calc((100vw - 1240px) / 2)); background: #fff; border-bottom: 1px solid var(--line); }
.portal-brand { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; color: var(--ink); background: var(--lime); font-weight: 800; }
.portal-brand strong, .portal-brand small { display: block; line-height: 1.2; }
.portal-brand strong { font-size: 13px; letter-spacing: .04em; }
.portal-brand small { margin-top: 4px; color: var(--muted); font-size: 9px; letter-spacing: .12em; }
.header-actions { display: flex; align-items: center; gap: 14px; font-size: 12px; }
.connection-state { color: var(--muted); }
.connection-state[data-online="true"] { color: #22633c; }
.connection-state[data-online="false"] { color: #9e431e; }
.portal-main { width: min(1240px, calc(100% - 40px)); min-height: calc(100vh - 136px); margin: 0 auto; padding: 48px 0 64px; }
.login-card { width: min(540px, 100%); margin: 40px auto; padding: clamp(24px, 5vw, 48px); background: #fff; border-top: 4px solid var(--lime); box-shadow: 0 16px 46px rgba(18, 59, 59, .08); }
.eyebrow { margin: 0 0 13px; color: var(--ocean); font-size: 10px; font-weight: 800; letter-spacing: .16em; }
h1, h2, h3 { color: var(--ink); line-height: 1.05; }
h1 { margin: 0 0 16px; font-size: clamp(34px, 5vw, 54px); letter-spacing: -.035em; }
h1 em { color: var(--ocean); font-style: normal; }
h2 { margin: 0; font-size: 21px; }
.login-card > p:not(.eyebrow) { color: var(--muted); font-size: 13px; }
form { display: grid; gap: 14px; }
label { display: grid; gap: 6px; color: var(--ink); font-size: 11px; font-weight: 700; }
input, select, textarea { width: 100%; min-height: 42px; padding: 10px 11px; border: 1px solid #cbd4cd; border-radius: 2px; color: var(--deep); background: #fff; font-size: 13px; font-weight: 400; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(47, 112, 117, .24); border-color: var(--ocean); }
.primary-button { min-height: 43px; padding: 10px 16px; border: 0; color: var(--deep); background: var(--lime); font-size: 12px; font-weight: 800; }
.primary-button:hover { background: #c9e75a; }
.quiet-button { padding: 7px 10px; border: 1px solid var(--line); color: var(--ink); background: white; font-size: 11px; font-weight: 700; }
.quiet-button:hover { border-color: var(--ocean); }
.form-message, .global-message { min-height: 18px; margin: 0; color: #9a321f; font-size: 11px; }
.privacy-hint { margin: 24px 0 0 !important; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted) !important; font-size: 10px !important; }
.welcome-row { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.welcome-row h1 { margin-bottom: 0; }
.queue-state { color: var(--muted); font-size: 11px; }
.queue-state[data-pending="true"] { color: #8d4b00; }
.admin-tools { display: grid; grid-template-columns: 1fr 2fr; gap: 14px; margin-bottom: 18px; }
.admin-tools #enquiry-admin { grid-column: 1 / -1; }
.admin-tools details, .jobs-panel, .detail-panel { border: 1px solid var(--line); background: #fff; }
.admin-tools details { padding: 13px 15px; }
.admin-tools #user-directory { grid-column: 1 / -1; }
.admin-tools summary { color: var(--ink); cursor: pointer; font-size: 12px; font-weight: 800; }
.user-directory-heading { padding: 10px 0; border: 0; }
.user-list { display: grid; gap: 10px; }
.user-card { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--line); background: #f8f9f5; }
.user-card-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.user-card-heading strong { font-size: 12px; }
.user-card-heading span { color: var(--muted); font-size: 10px; }
.user-edit-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.user-edit-form label { font-size: 10px; }
.user-edit-form input, .user-edit-form select { min-height: 36px; font-size: 11px; }
.user-edit-form .span-all { grid-column: 1 / -1; }
.compact-form { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding-top: 14px; }
.compact-form label { font-size: 10px; }
.compact-form input, .compact-form select { min-height: 38px; font-size: 11px; }
.compact-form .primary-button, .compact-form .form-message, .field-note { grid-column: 1 / -1; }
.field-note { margin: 0; color: var(--muted); font-size: 10px; }
.enquiry-list { display: grid; gap: 10px; margin-top: 12px; }
.enquiry-card { display: grid; gap: 9px; padding: 12px; border: 1px solid var(--line); background: #f8f9f5; }
.enquiry-card h3 { margin: 0; font-size: 14px; }
.enquiry-card p { margin: 0; color: var(--muted); font-size: 10px; white-space: pre-wrap; }
.enquiry-card-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.enquiry-card-form .span-all { grid-column: 1 / -1; }
.workspace-grid { display: grid; grid-template-columns: minmax(290px, .75fr) minmax(0, 1.5fr); gap: 16px; align-items: start; }
.jobs-panel, .detail-panel { min-width: 0; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { font-size: 17px; }
.jobs-list { display: grid; }
.job-search { padding: 12px 15px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 9px; }
.job-search input { min-height: 36px; margin-top: 5px; font-size: 11px; }
.job-card { display: grid; gap: 5px; padding: 15px 16px; border: 0; border-bottom: 1px solid var(--line); color: inherit; background: white; text-align: left; }
.job-card:hover, .job-card[aria-current="true"] { background: #f4f7f0; }
.job-ref { color: var(--ocean); font-size: 10px; font-weight: 800; }
.job-card strong { font-size: 13px; }
.job-meta { color: var(--muted); font-size: 10px; }
.status-pill { width: fit-content; padding: 3px 7px; color: var(--ink); background: #e7ede5; font-size: 9px; font-weight: 800; }
.detail-panel { padding: 20px; }
.detail-panel > p { color: var(--muted); font-size: 12px; }
.detail-header { display: flex; align-items: start; justify-content: space-between; gap: 15px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.detail-header h2 { margin: 5px 0; }
.detail-header p { margin: 0; color: var(--muted); font-size: 11px; }
.pipeline { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); margin: 20px 0; padding: 0; list-style: none; }
.pipeline li { position: relative; min-width: 0; padding: 25px 6px 0; color: #75827c; font-size: 9px; text-align: center; }
.pipeline li::before { position: absolute; z-index: 1; top: 0; left: calc(50% - 6px); width: 12px; height: 12px; border: 2px solid #bec9c1; border-radius: 50%; background: white; content: ""; }
.pipeline li:not(:last-child)::after { position: absolute; top: 5px; left: 50%; width: 100%; height: 2px; background: #d7ded7; content: ""; }
.pipeline li.complete::before, .pipeline li.current::before { border-color: var(--ocean); background: var(--lime); }
.pipeline li.complete::after { background: var(--ocean); }
.pipeline li.current { color: var(--ink); font-weight: 800; }
.data-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; margin: 15px 0; }
.data-tile { padding: 10px; background: #f4f6f1; }
.data-tile span { display: block; color: var(--muted); font-size: 9px; }
.data-tile strong { display: block; overflow-wrap: anywhere; margin-top: 4px; color: var(--ink); font-size: 11px; }
.detail-section { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.detail-section h3 { margin: 0 0 10px; font-size: 14px; }
.detail-section > p { color: var(--muted); font-size: 11px; }
.event-list { display: grid; gap: 8px; max-height: 260px; overflow: auto; }
.event-item { padding: 10px; border-left: 3px solid var(--ocean); background: #f5f7f3; }
.event-item.alert { border-color: #bd5429; }
.event-item strong { display: block; font-size: 11px; }
.event-item p { margin: 3px 0; font-size: 10px; }
.event-item small { color: var(--muted); font-size: 9px; }
.inline-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.inline-actions .primary-button, .inline-actions .quiet-button { width: auto; }
.field-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.field-form .span-all { grid-column: 1 / -1; }
.media-input { padding: 7px; font-size: 10px; }
.geo-state { min-height: 16px; color: var(--muted); font-size: 9px; }
.telemetry-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.telemetry-item { padding: 9px; background: #f4f6f1; }
.telemetry-item strong { display: block; color: var(--ink); font-size: 12px; }
.telemetry-item small { color: var(--muted); font-size: 9px; }
.cert-link { color: var(--ocean); font-size: 11px; font-weight: 800; }
.analytics-panel { margin-top: 18px; border: 1px solid var(--line); background: #fff; }
.analytics-content { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; padding: 16px; }
.analytics-group { min-width: 0; }
.analytics-group h3 { margin: 0 0 8px; font-size: 12px; }
.analytics-table { width: 100%; border-collapse: collapse; font-size: 10px; }
.analytics-table td { padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.analytics-table td:last-child { text-align: right; white-space: nowrap; }
.portal-footer { display: flex; justify-content: space-between; gap: 15px; padding: 18px max(20px, calc((100vw - 1240px) / 2)); color: #d6e0dc; background: var(--deep); font-size: 10px; }
.portal-footer a { color: var(--lime); }
.verify-card { width: min(600px, 100%); }
#verify-form { margin-top: 24px; }
#verify-status { padding: 13px; background: #f2f5ef; font-size: 12px; }
#verify-status[data-result="valid"] { color: #185c35; background: #e5f3e8; }
#verify-status[data-result="invalid"] { color: #8b271d; background: #f9e9e6; }

@media (max-width: 820px) {
  .workspace-grid { grid-template-columns: 1fr; }
  .analytics-content { grid-template-columns: 1fr; }
  .admin-tools { grid-template-columns: 1fr; }
  .user-edit-form { grid-template-columns: 1fr; }
  .user-edit-form .span-all { grid-column: 1; }
  .detail-panel { min-height: 300px; }
}

@media (max-width: 520px) {
  .portal-header { min-height: 64px; padding: 10px 14px; }
  .portal-brand strong { font-size: 11px; }
  .header-actions { gap: 7px; font-size: 10px; }
  #identity { max-width: 95px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .portal-main { width: calc(100% - 24px); padding: 28px 0 42px; }
  .login-card { margin: 15px auto; padding: 23px 18px; }
  .welcome-row { align-items: start; flex-direction: column; }
  .compact-form { grid-template-columns: 1fr; }
  .compact-form .primary-button, .compact-form .form-message, .field-note, .enquiry-card-form .span-all { grid-column: 1; }
  .detail-panel { padding: 14px; }
  .detail-header { flex-direction: column; }
  .pipeline li { padding-right: 2px; padding-left: 2px; font-size: 8px; }
  .data-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field-form { grid-template-columns: 1fr; }
  .field-form .span-all { grid-column: 1; }
  .portal-footer { flex-direction: column; padding: 16px 12px; }
}
