:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --ink: #162033;
    --muted: #64748b;
    --line: #dbe3ef;
    --brand: #0f766e;
    --brand-strong: #115e59;
    --accent: #b45309;
    --danger: #dc2626;
    --ok: #15803d;
    --info: #2563eb;
    --sidebar: #111827;
    --sidebar-soft: #1f2937;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--ink);
    background: var(--bg);
}

a { color: inherit; text-decoration: none; }

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(120deg, rgba(15, 118, 110, .92), rgba(17, 24, 39, .9)),
        url('/favicon.ico');
}

.login-card {
    width: min(440px, 100%);
    background: var(--panel);
    border: 1px solid rgba(219, 227, 239, .9);
    border-radius: 8px;
    padding: 32px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, .22);
}

.portal-body {
    min-height: 100vh;
    background:
        radial-gradient(circle at 12% 16%, rgba(20, 184, 166, .22), transparent 28%),
        radial-gradient(circle at 88% 8%, rgba(59, 130, 246, .18), transparent 24%),
        linear-gradient(135deg, #f0fdfa 0%, #f8fafc 48%, #eef2ff 100%);
}

.portal-shell {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 24px 0 44px;
}

.portal-topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 18px;
    margin-bottom: 22px;
    padding: 12px 14px;
    border: 1px solid rgba(219, 227, 239, .85);
    border-radius: 14px;
    background: rgba(255, 255, 255, .82);
    backdrop-filter: blur(14px);
    box-shadow: 0 16px 42px rgba(15, 23, 42, .08);
}

.portal-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
}

.portal-logo img,
.portal-logo span {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    object-fit: contain;
    background: #fff;
    border: 1px solid var(--line);
}

.portal-logo span {
    display: grid;
    place-items: center;
    background: var(--brand);
    color: #fff;
    font-weight: 800;
}

.portal-topbar nav {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.portal-topbar nav a:not(.btn) {
    color: var(--muted);
    font-weight: 700;
}

.portal-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) 320px;
    gap: 20px;
    align-items: center;
    margin-bottom: 18px;
    padding: 34px;
    border: 1px solid rgba(219, 227, 239, .88);
    border-radius: 18px;
    background: rgba(255, 255, 255, .9);
    box-shadow: 0 18px 50px rgba(15, 23, 42, .08);
    overflow: hidden;
}

.portal-hero.compact {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.portal-hero h1 {
    margin: 6px 0;
    max-width: 760px;
    font-size: 42px;
    line-height: 1.04;
}

.portal-hero p {
    max-width: 680px;
    color: var(--muted);
    font-size: 17px;
    line-height: 1.6;
}

.portal-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 18px;
}

.portal-visual {
    position: relative;
    min-height: 240px;
    border-radius: 18px;
    background:
        linear-gradient(135deg, rgba(15, 118, 110, .92), rgba(37, 99, 235, .82)),
        repeating-linear-gradient(90deg, transparent 0 18px, rgba(255, 255, 255, .12) 18px 19px);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18);
}

.portal-visual span {
    position: absolute;
    display: block;
    border-radius: 14px;
    background: rgba(255, 255, 255, .86);
    box-shadow: 0 18px 32px rgba(15, 23, 42, .18);
}

.portal-visual span:nth-child(1) { width: 180px; height: 44px; top: 34px; left: 34px; }
.portal-visual span:nth-child(2) { width: 120px; height: 86px; top: 96px; left: 52px; }
.portal-visual span:nth-child(3) { width: 96px; height: 96px; top: 78px; right: 38px; border-radius: 999px; }
.portal-visual span:nth-child(4) { width: 210px; height: 36px; bottom: 32px; right: 34px; }

.portal-section {
    margin-top: 18px;
    padding: 24px;
    border: 1px solid rgba(219, 227, 239, .88);
    border-radius: 16px;
    background: rgba(255, 255, 255, .78);
    box-shadow: 0 16px 42px rgba(15, 23, 42, .06);
}

.portal-card-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.portal-card {
    display: grid;
    gap: 10px;
    min-height: 170px;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, .92);
    box-shadow: 0 14px 34px rgba(15, 23, 42, .06);
    transition: transform .16s ease, border-color .16s ease;
}

.portal-card:hover {
    transform: translateY(-2px);
    border-color: rgba(15, 118, 110, .45);
}

.portal-card strong {
    font-size: 20px;
}

.portal-card em {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: #ecfeff;
    color: var(--brand-strong);
    font-style: normal;
    font-weight: 900;
}

.portal-card span {
    color: var(--muted);
    line-height: 1.45;
}

.portal-card.accent {
    background: #f0fdfa;
}

.portal-article-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.portal-article,
.portal-empty {
    min-height: 150px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
}

.portal-article {
    display: grid;
    gap: 9px;
    color: var(--text);
}

.portal-article span {
    color: var(--brand-strong);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.portal-article small,
.portal-empty {
    color: var(--muted);
    line-height: 1.45;
}

.portal-knowledge-content {
    max-width: 860px;
    margin: 0 auto;
    white-space: pre-line;
    line-height: 1.75;
    font-size: 16px;
}

.portal-form {
    max-width: 780px;
}

.public-timeline {
    display: grid;
    gap: 12px;
}

.public-timeline article {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}

.public-timeline span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-top: 3px;
}

.login-brand {
    display: grid;
    justify-items: center;
    gap: 6px;
    margin-bottom: 24px;
    text-align: center;
}
.login-brand small { color: var(--muted); }

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
    background: var(--sidebar);
    color: #e5e7eb;
    padding: 18px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: auto;
}

.brand {
    padding: 12px;
    border-bottom: 1px solid rgba(255,255,255,.12);
    margin-bottom: 14px;
}

.brand-heading {
    display: flex;
    gap: 10px;
    align-items: center;
}
.brand-logo {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    object-fit: contain;
    background: #fff;
    padding: 4px;
    flex: 0 0 auto;
}
.brand strong { display: block; font-size: 18px; }
.brand span { color: #9ca3af; font-size: 12px; }
.sidebar-toggle {
    display: none;
    width: 100%;
    margin-top: 12px;
}
.login-logo {
    width: 92px;
    height: 92px;
    object-fit: contain;
    margin-bottom: 8px;
}

.sidebar-menu {
    display: grid;
    gap: 6px;
    align-content: start;
}

.nav-group {
    display: grid;
    gap: 4px;
    border-radius: 10px;
}

.nav-group summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border-radius: 10px;
    color: #cbd5e1;
    cursor: pointer;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .04em;
    list-style: none;
    text-transform: uppercase;
}

.nav-group summary::-webkit-details-marker {
    display: none;
}

.nav-group summary::after {
    content: "+";
    font-size: 16px;
    line-height: 1;
}

.nav-group[open] summary {
    background: rgba(255, 255, 255, .06);
    color: #ffffff;
}

.nav-group[open] summary::after {
    content: "-";
}

.nav-group .nav-link {
    margin-left: 8px;
}

.nav-section {
    margin: 18px 10px 8px;
    color: #9ca3af;
    font-size: 11px;
    text-transform: uppercase;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: #d1d5db;
}

.nav-link:hover,
.nav-link.active {
    background: var(--sidebar-soft);
    color: #ffffff;
}

.main {
    min-width: 0;
    display: grid;
    grid-template-rows: auto 1fr auto;
}

.topbar {
    height: 64px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}
.topbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}
.notification-button.has-alert {
    border-color: rgba(220, 38, 38, .35);
    background: #fff7ed;
}

.content {
    padding: 24px;
}

.footer {
    color: var(--muted);
    font-size: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--line);
    background: var(--panel);
}

.breadcrumb {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 10px;
}

.page-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.page-title h1 { margin: 0; font-size: 24px; }

.grid {
    display: grid;
    gap: 16px;
}

.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, .04);
}

form.card {
    border-top: 4px solid rgba(15, 118, 110, .24);
}

.dashboard-hero {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    margin-bottom: 18px;
    padding: 22px;
    border: 1px solid var(--line);
    border-left: 5px solid var(--brand);
    border-radius: 8px;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 48%, #ecfdf5 100%);
    box-shadow: 0 18px 50px rgba(15, 23, 42, .08);
    animation: fadeUp .45s ease both;
}
.dashboard-hero h1 {
    margin: 4px 0 6px;
    font-size: 28px;
}
.eyebrow {
    color: var(--brand-strong);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}
.hero-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}
.metric-card {
    position: relative;
    overflow: hidden;
    min-height: 132px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 14px 36px rgba(15, 23, 42, .06);
    animation: fadeUp .45s ease both;
    animation-delay: calc(var(--i) * 80ms);
}
.metric-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 5px;
    background: var(--brand);
}
.metric-card span,
.metric-card small {
    display: block;
    color: var(--muted);
}
.metric-card strong {
    display: block;
    margin: 12px 0 6px;
    font-size: 34px;
}
.metric-total::before { background: var(--info); }
.metric-open::before { background: var(--accent); }
.metric-ok::before { background: var(--ok); }
.metric-risk::before { background: var(--danger); }
.institution-card {
    display: grid;
    grid-template-columns: minmax(220px, .8fr) minmax(0, 1.8fr);
    gap: 18px;
    align-items: center;
    margin-bottom: 16px;
}
.institution-card h2 {
    margin: 4px 0 0;
    font-size: 20px;
}
.institution-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}
.institution-grid div,
.compact-metrics div {
    min-height: 70px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}
.institution-grid span,
.compact-metrics span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 6px;
}
.dashboard-grid { margin-top: 16px; }
.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.section-heading h2 { margin: 0; font-size: 18px; }
.status-stack,
.notification-stack,
.ticket-feed,
.category-stack,
.technician-stack {
    display: grid;
    gap: 10px;
}
.status-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px 12px;
    align-items: center;
}
.status-row > div:first-child {
    display: flex;
    align-items: center;
    gap: 8px;
}
.status-dot,
.notification-state {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    flex: 0 0 auto;
}
.bar-track {
    grid-column: 1 / -1;
    height: 9px;
    overflow: hidden;
    border-radius: 999px;
    background: #e5e7eb;
}
.bar-fill {
    display: block;
    width: var(--bar-width);
    height: 100%;
    border-radius: inherit;
    animation: growBar .8s ease both;
}
.notification-item,
.ticket-feed-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
    transition: transform .16s ease, border-color .16s ease, background .16s ease;
}
.ticket-feed-item { grid-template-columns: 1fr auto; }
.notification-item:hover,
.ticket-feed-item:hover {
    transform: translateY(-2px);
    border-color: rgba(15, 118, 110, .35);
    background: #ffffff;
}
.notification-item small,
.ticket-feed-item small {
    display: block;
    color: var(--muted);
    margin-top: 3px;
}
.notification-item em {
    color: var(--muted);
    font-size: 12px;
    font-style: normal;
}
.notification-state { background: var(--muted); }
.notification-item.unread .notification-state {
    background: var(--danger);
    animation: pulseDot 1.3s ease infinite;
}
.compact-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}
.compact-metrics strong { font-size: 24px; }
.executive-signal {
    display: grid;
    gap: 7px;
    min-height: 112px;
    border-left: 5px solid var(--muted);
}
.executive-signal span,
.executive-signal small {
    color: var(--muted);
}
.executive-signal strong {
    font-size: 26px;
}
.signal-danger { border-left-color: var(--danger); }
.signal-warning { border-left-color: var(--accent); }
.signal-info { border-left-color: var(--info); }
.signal-ok { border-left-color: var(--ok); }
.location-stack {
    display: grid;
    gap: 12px;
}
.location-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 12px;
    align-items: center;
    padding: 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}
.location-row small {
    display: block;
    color: var(--muted);
    margin-top: 3px;
}
.location-row > span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}
.location-row .bar-track {
    grid-column: 1 / -1;
}
.category-row {
    display: grid;
    grid-template-columns: minmax(140px, 1fr) 2fr 44px;
    gap: 10px;
    align-items: center;
}
.technician-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}
.badge-pulse {
    animation: pulseDot 1.3s ease infinite;
}

.stat-value { font-size: 28px; font-weight: 700; margin-top: 8px; }
.muted { color: var(--muted); }

.table-wrap {
    overflow-x: auto;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, .04);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    background: #f8fafc;
}

tbody tr {
    transition: background .16s ease;
}

tbody tr:hover {
    background: #f8fafc;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 9px;
    border-radius: 999px;
    color: #fff;
    background: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--ink);
    cursor: pointer;
    font-weight: 600;
    white-space: nowrap;
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease, background .16s ease, color .16s ease;
}

.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-strong); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-muted { background: #eef2f7; color: var(--ink); }
.btn:hover {
    transform: translateY(-1px);
    border-color: rgba(15, 118, 110, .35);
    box-shadow: 0 10px 20px rgba(15, 23, 42, .08);
}
.btn:active {
    transform: translateY(0);
    box-shadow: none;
}
td > .btn,
td > form {
    margin: 2px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.field { display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label { font-weight: 700; font-size: 13px; }
.field input,
.field select,
.field textarea {
    width: 100%;
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px 10px;
    font: inherit;
    background: #fff;
    transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
.field input:focus,
.field select:focus,
.field textarea:focus,
.select-search:focus {
    outline: none;
    border-color: rgba(15, 118, 110, .65);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, .12);
    background: #ffffff;
}
.field textarea { min-height: 120px; resize: vertical; }
.searchable-select {
    display: grid;
    gap: 7px;
}
.select-search {
    min-height: 36px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 10px;
    font: inherit;
    background: #f8fafc;
    transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
.field-help {
    color: var(--muted);
    font-size: 12px;
}
.brand-preview {
    max-width: 180px;
    max-height: 90px;
    object-fit: contain;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px;
    background: #fff;
}
.favicon-preview {
    width: 42px;
    height: 42px;
    object-fit: contain;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 6px;
    background: #fff;
}
.check-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}
.check-grid label,
.permission-group label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    line-height: 1.35;
}
.permission-groups {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 12px;
}
.permission-group {
    display: grid;
    gap: 8px;
    align-content: start;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: #f8fafc;
}
.permission-group strong {
    text-transform: uppercase;
    color: var(--brand-strong);
    font-size: 12px;
}
.profile-strip {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 4px;
}
.profile-pill {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border-radius: 999px;
    padding: 3px 9px;
    background: #eef2f7;
    color: var(--ink);
    font-size: 12px;
}
.error { color: var(--danger); font-size: 13px; }

.consent-box {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #f8fafc;
    color: var(--muted);
    font-size: 14px;
}

.consent-box input {
    margin-top: 3px;
}

.quick-requester-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.quick-requester-modal {
    width: min(720px, calc(100vw - 28px));
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    background: var(--panel);
    box-shadow: 0 24px 80px rgba(15, 23, 42, .28);
}

.quick-requester-modal::backdrop {
    background: rgba(15, 23, 42, .48);
}

.modal-head,
.modal-actions {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.modal-head {
    margin-bottom: 16px;
}

.modal-head h2 {
    margin: 0 0 4px;
}

.modal-head p {
    margin: 0;
}

.modal-actions {
    justify-content: flex-end;
    margin-top: 16px;
}

.alert {
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 16px;
    border: 1px solid var(--line);
    background: #ecfdf5;
    color: #065f46;
    animation: slideFade .26s ease both;
}
.alert.error { background: #fef2f2; color: #991b1b; }
.flash-fallback.is-promoted { display: none; }

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 10px 24px rgba(15, 23, 42, .04);
}

.pagination-summary {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.pagination-links {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 34px;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    font-size: 13px;
    font-weight: 700;
    transition: transform .16s ease, border-color .16s ease, background .16s ease, color .16s ease;
}

.page-link:hover {
    transform: translateY(-1px);
    border-color: rgba(15, 118, 110, .35);
    background: #f0fdfa;
}

.page-link.active {
    border-color: var(--brand);
    background: var(--brand);
    color: #fff;
}

.page-link.disabled {
    color: #94a3b8;
    background: #f8fafc;
    cursor: not-allowed;
}

.toast-region {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 60;
    display: grid;
    gap: 10px;
    width: min(380px, calc(100vw - 32px));
    pointer-events: none;
}

.toast {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 12px;
    align-items: start;
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-left: 5px solid var(--brand);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 18px 45px rgba(15, 23, 42, .16);
    pointer-events: auto;
    animation: toastIn .24s ease both;
}

.toast.is-hiding { animation: toastOut .2s ease both; }
.toast-success { border-left-color: var(--ok); }
.toast-error { border-left-color: var(--danger); }
.toast-info { border-left-color: var(--info); }
.toast-icon {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 999px;
    color: #fff;
    background: var(--brand);
    font-size: 14px;
    font-weight: 700;
}
.toast-success .toast-icon { background: var(--ok); }
.toast-error .toast-icon { background: var(--danger); }
.toast-info .toast-icon { background: var(--info); }
.toast strong {
    display: block;
    margin-bottom: 3px;
    font-size: 14px;
}
.toast span {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
}
.toast-close {
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}

.action-progress {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 55;
    width: min(430px, calc(100vw - 32px));
}

.action-progress[hidden] { display: none; }

.action-progress-card {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 14px;
    padding: 16px;
    border: 1px solid rgba(15, 118, 110, .24);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 18px 55px rgba(15, 23, 42, .18);
    animation: toastIn .24s ease both;
}

.action-progress-spinner {
    width: 34px;
    height: 34px;
    border: 3px solid #dbeafe;
    border-top-color: var(--brand);
    border-radius: 999px;
    animation: spin .8s linear infinite;
}

.action-progress-body {
    display: grid;
    gap: 7px;
}

.action-progress-body strong { font-size: 14px; }
.action-progress-body span,
.action-progress-body small {
    color: var(--muted);
    font-size: 12px;
}

.action-progress-track {
    height: 9px;
    overflow: hidden;
    border-radius: 999px;
    background: #e5e7eb;
}

.action-progress-track span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--brand), var(--info));
    transition: width .32s ease;
}

.btn.is-loading {
    position: relative;
    pointer-events: none;
    opacity: .8;
}

.btn.is-loading::before {
    content: "";
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 999px;
    animation: spin .7s linear infinite;
}

.ticket-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 16px;
}

.ticket-hero {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
    margin-bottom: 18px;
    padding: 22px;
    border: 1px solid var(--line);
    border-left: 5px solid var(--brand);
    border-radius: 8px;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 58%, #f0fdfa 100%);
    box-shadow: 0 18px 50px rgba(15, 23, 42, .08);
    animation: fadeUp .35s ease both;
}

.ticket-hero h1 {
    margin: 4px 0 10px;
    font-size: 27px;
}

.ticket-request-card {
    margin-bottom: 16px;
    border-left: 5px solid var(--brand);
}

.ticket-request-card h3 {
    margin: 0 0 10px;
    font-size: 21px;
}

.ticket-request-card p {
    margin: 0;
    color: var(--ink);
    line-height: 1.6;
    white-space: pre-line;
}

.request-meta-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-top: 16px;
}

.request-meta-grid div {
    min-height: 72px;
    padding: 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}

.request-meta-grid span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 6px;
}

.request-meta-grid strong {
    overflow-wrap: anywhere;
}

.trace-panel {
    margin-bottom: 16px;
}

.trace-metrics {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}

.trace-metrics div {
    min-height: 74px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}

.trace-metrics span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 6px;
}

.trace-metrics strong {
    font-size: 26px;
}

.ticket-stepper {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}

.ticket-step {
    position: relative;
    display: grid;
    gap: 5px;
    min-height: 88px;
    padding: 14px 12px 12px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.ticket-step span {
    width: 14px;
    height: 14px;
    border: 3px solid #cbd5e1;
    border-radius: 999px;
    background: #fff;
}

.ticket-step.done {
    border-style: solid;
    border-color: rgba(21, 128, 61, .24);
    background: #f0fdf4;
}

.ticket-step.done span {
    border-color: var(--ok);
    background: var(--ok);
    box-shadow: 0 0 0 4px rgba(21, 128, 61, .12);
}

.ticket-step strong {
    font-size: 13px;
}

.ticket-step small {
    color: var(--muted);
    font-size: 12px;
}

.trace-list {
    display: grid;
    gap: 12px;
}

.trace-item {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.trace-item:hover {
    transform: translateY(-2px);
    border-color: rgba(15, 118, 110, .35);
    box-shadow: 0 14px 28px rgba(15, 23, 42, .07);
}

.trace-icon {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    background: var(--muted);
    color: #fff;
    font-size: 13px;
    font-weight: 800;
}

.trace-created .trace-icon { background: var(--brand); }
.trace-assigned .trace-icon { background: var(--info); }
.trace-status .trace-icon { background: var(--accent); }
.trace-message .trace-icon { background: var(--ok); }
.trace-internal .trace-icon { background: #7c3aed; }

.trace-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 4px;
}

.trace-head span {
    min-height: 24px;
    padding: 3px 9px;
    border-radius: 999px;
    background: #eef2f7;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.trace-change {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.trace-change span {
    display: grid;
    gap: 4px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
    color: var(--muted);
    font-size: 12px;
    overflow-wrap: anywhere;
}

.trace-change strong {
    color: var(--ink);
    font-size: 11px;
    text-transform: uppercase;
}

.message {
    border-left: 4px solid var(--brand);
    padding: 12px 14px;
    background: #f8fafc;
    border-radius: 8px;
    margin-bottom: 12px;
}

.message.internal { border-left-color: var(--accent); background: #fff7ed; }

.timeline-item {
    border-left: 2px solid var(--line);
    padding: 0 0 16px 14px;
    margin-left: 4px;
}

.detail-stack {
    display: grid;
    gap: 4px;
    margin: 12px 0;
}

.detail-stack small {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.detail-stack strong {
    font-size: 14px;
}

.settings-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
    padding: 22px;
    border: 1px solid var(--line);
    border-left: 5px solid var(--brand);
    border-radius: 8px;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 55%, #f0fdfa 100%);
    box-shadow: 0 18px 50px rgba(15, 23, 42, .08);
}

.settings-hero h1 {
    margin: 4px 0 6px;
    font-size: 28px;
}

.settings-status {
    min-width: 180px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.settings-status strong,
.settings-status small {
    display: block;
}

.settings-status small {
    color: var(--muted);
    margin-top: 3px;
}

.status-light {
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: 7px;
    border-radius: 999px;
    background: var(--muted);
}

.status-light.on {
    background: var(--ok);
    box-shadow: 0 0 0 5px rgba(21, 128, 61, .12);
}

.settings-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 16px;
}

.settings-panel {
    border-top: 0;
}

.settings-panel .section-heading > div {
    display: flex;
    align-items: center;
    gap: 10px;
}

.step-pill {
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 999px;
    background: var(--brand);
    color: #fff;
    font-size: 13px;
    font-weight: 800;
}

.switch-row {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
    font-weight: 700;
}

.provider-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.provider-card {
    display: grid;
    gap: 8px;
    min-height: 132px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
    cursor: pointer;
    transition: border-color .16s ease, background .16s ease, box-shadow .16s ease, transform .16s ease;
}

.provider-card:hover,
.provider-card.selected {
    transform: translateY(-1px);
    border-color: rgba(15, 118, 110, .45);
    background: #ffffff;
    box-shadow: 0 12px 28px rgba(15, 23, 42, .06);
}

.provider-card input {
    width: fit-content;
}

.provider-card strong {
    font-size: 15px;
}

.provider-card span {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
}

.settings-side {
    display: grid;
    gap: 16px;
    align-content: start;
}

.help-card {
    background: #f8fafc;
}

.help-card h2 {
    margin-top: 0;
}

.help-card code {
    display: block;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    overflow-wrap: anywhere;
}

.settings-actions {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 16px;
    text-align: right;
}

.settings-actions .muted {
    width: 100%;
}

.test-card {
    display: grid;
    gap: 14px;
    border-top: 0;
}

.test-card h2 {
    margin: 8px 0 4px;
}

.test-card.highlighted {
    border-color: rgba(15, 118, 110, .32);
    background: #f0fdfa;
}

.payload-card {
    margin-top: 16px;
}

.payload-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.payload-grid pre {
    margin: 10px 0 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #0f172a;
    color: #e5e7eb;
    overflow: auto;
    white-space: pre-wrap;
}

.connection-panel {
    margin-bottom: 16px;
    border-color: rgba(37, 99, 235, .24);
    background: #f8fbff;
}

.connection-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 16px;
    align-items: start;
}

.connection-steps {
    display: grid;
    gap: 10px;
}

.connection-steps div {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.connection-steps code {
    padding: 2px 6px;
    border-radius: 6px;
    background: #eef2f7;
    overflow-wrap: anywhere;
}

.connection-state {
    display: grid;
    gap: 12px;
}

.connection-state .settings-status {
    width: 100%;
}

.qr-preview {
    width: min(240px, 100%);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    background: #ffffff;
}

.install-box {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid rgba(180, 83, 9, .28);
    border-radius: 8px;
    background: #fff7ed;
}

.install-box span {
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.install-box code {
    display: block;
    padding: 10px;
    border-radius: 8px;
    background: #ffffff;
    color: var(--ink);
    overflow-wrap: anywhere;
}

.advanced-box {
    margin-top: 16px;
    padding: 12px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    background: #f8fafc;
}

.advanced-box summary {
    cursor: pointer;
    color: var(--brand-strong);
    font-weight: 800;
}

@media (max-width: 980px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: relative; height: auto; max-height: none; padding: 10px; }
    .sidebar-toggle { display: inline-flex; }
    .sidebar nav { display: none; }
    .sidebar.open nav { display: block; }
    .brand { margin-bottom: 0; }
    .grid,
    .grid-4,
    .grid-2,
    .portal-card-grid,
    .portal-article-grid,
    .portal-hero,
    .form-grid,
    .ticket-layout,
    .metric-grid,
    .institution-card,
    .institution-grid,
    .request-meta-grid,
    .check-grid,
    .permission-groups,
    .compact-metrics,
    .settings-layout,
    .provider-grid,
    .payload-grid,
    .connection-grid {
        grid-template-columns: 1fr !important;
    }
    .dashboard-hero, .ticket-hero, .settings-hero { align-items: flex-start; flex-direction: column; }
    .portal-topbar {
        align-items: flex-start;
        flex-direction: column;
    }
    .portal-topbar nav {
        width: 100%;
    }
    .portal-visual {
        min-height: 180px;
    }
    .hero-actions { justify-content: flex-start; }
    .settings-status { width: 100%; }
    .trace-metrics, .ticket-stepper { grid-template-columns: 1fr; }
    .trace-change { grid-template-columns: 1fr; }
    .category-row { grid-template-columns: 1fr 44px; }
    .category-row .bar-track { grid-column: 1 / -1; order: 3; }
    .topbar { height: auto; padding: 14px 16px; align-items: flex-start; gap: 10px; flex-direction: column; }
    .topbar-actions { justify-content: flex-start; }
    .profile-strip { gap: 6px; }
    .content { padding: 16px; }
    .toast-region {
        top: 10px;
        right: 10px;
        left: 10px;
        width: auto;
    }
    .action-progress {
        right: 10px;
        bottom: 10px;
        left: 10px;
        width: auto;
    }
    .pagination {
        align-items: stretch;
        flex-direction: column;
    }
    .pagination-links {
        justify-content: flex-start;
    }
    .page-link {
        flex: 1 1 auto;
    }
}

@media (max-width: 760px) {
    body {
        font-size: 14px;
    }

    .brand-heading {
        align-items: flex-start;
    }

    .brand strong {
        font-size: 16px;
    }

    .nav-link {
        min-height: 42px;
    }

    .topbar,
    .content,
    .footer {
        padding-left: 12px;
        padding-right: 12px;
    }

    .portal-shell {
        width: min(100% - 20px, 1120px);
        padding-top: 10px;
    }

    .portal-hero {
        padding: 22px;
    }

    .portal-hero h1 {
        font-size: 30px;
    }

    .portal-card {
        min-height: auto;
    }

    .topbar > div,
    .topbar-actions,
    .topbar-actions form,
    .topbar-actions .btn,
    .notification-button {
        width: 100%;
    }

    .topbar-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .profile-strip {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
    }

    .profile-pill {
        width: 100%;
        border-radius: 8px;
        white-space: normal;
    }

    .page-title {
        align-items: stretch;
        flex-direction: column;
    }

    .page-title h1 {
        font-size: 21px;
        line-height: 1.2;
    }

    .page-title .btn,
    .page-title > div,
    .hero-actions,
    .hero-actions .btn,
    .hero-actions form,
    .hero-actions button {
        width: 100%;
    }

    .card {
        padding: 14px;
    }

    .dashboard-hero,
    .ticket-hero {
        padding: 16px;
    }

    .dashboard-hero h1,
    .ticket-hero h1 {
        font-size: 22px;
        line-height: 1.22;
    }

    .metric-card {
        min-height: 112px;
    }

    .metric-card strong,
    .stat-value {
        font-size: 28px;
    }

    .section-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .settings-panel .section-heading > div {
        align-items: flex-start;
    }

    .switch-row,
    .settings-actions,
    .settings-actions .btn {
        width: 100%;
    }

    .field input,
    .field select,
    .field textarea,
    .select-search {
        min-height: 44px;
        font-size: 16px;
    }

    .btn {
        width: 100%;
        min-height: 42px;
        white-space: normal;
        text-align: center;
    }

    td > .btn,
    td > form,
    td > form .btn,
    td button {
        width: 100%;
        margin: 4px 0;
    }

    .table-wrap {
        overflow: visible;
        border: 0;
        background: transparent;
        box-shadow: none;
    }

    .table-wrap table,
    .table-wrap thead,
    .table-wrap tbody,
    .table-wrap tr,
    .table-wrap th,
    .table-wrap td {
        display: block;
        width: 100%;
    }

    .table-wrap thead {
        display: none;
    }

    .table-wrap tbody {
        display: grid;
        gap: 12px;
    }

    .table-wrap tr {
        border: 1px solid var(--line);
        border-radius: 8px;
        overflow: hidden;
        background: var(--panel);
        box-shadow: 0 10px 24px rgba(15, 23, 42, .04);
    }

    .table-wrap td {
        display: grid;
        grid-template-columns: minmax(108px, .42fr) minmax(0, 1fr);
        gap: 10px;
        align-items: start;
        min-height: 42px;
        padding: 10px 12px;
        border-bottom: 1px solid var(--line);
        overflow-wrap: anywhere;
    }

    .table-wrap td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 11px;
        font-weight: 800;
        text-transform: uppercase;
    }

    .table-wrap td:last-child {
        border-bottom: 0;
    }

    .table-wrap td[colspan] {
        grid-template-columns: 1fr;
    }

    .table-wrap td[colspan]::before {
        content: "";
        display: none;
    }

    .badge {
        width: fit-content;
        max-width: 100%;
        white-space: normal;
    }

    .trace-item {
        grid-template-columns: 1fr;
    }

    .trace-icon {
        width: 30px;
        height: 30px;
    }

    .trace-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .trace-metrics div,
    .institution-grid div,
    .compact-metrics div {
        min-height: 62px;
    }

    .ticket-step {
        min-height: 76px;
    }

    .toast {
        grid-template-columns: 1fr auto;
    }

    .toast-icon {
        display: none;
    }

    .action-progress-card {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 420px) {
    .content {
        padding-top: 12px;
    }

    .card,
    .dashboard-hero,
    .ticket-hero {
        border-radius: 8px;
    }

    .table-wrap td {
        grid-template-columns: 1fr;
        gap: 5px;
    }

    .pagination-links {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@keyframes slideFade {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(-8px) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to { opacity: 0; transform: translateY(-6px) scale(.98); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes growBar {
    from { width: 0; }
    to { width: var(--bar-width); }
}

@keyframes pulseDot {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, .35); }
    50% { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
}
