: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;
}

* { 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; }
: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; }

@media (max-width: 900px) {
  .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) {
  .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; }
}
