:root {
    --bg: #f3f5f6;
    --surface: #ffffff;
    --surface-muted: #edf4f8;
    --text: #292b2d;
    --muted: #6d747a;
    --line: #d9dfe3;
    --brand-blue: #6ba6d9;
    --primary: #397fb6;
    --primary-dark: #286794;
    --charcoal: #444444;
    --accent: #6ba6d9;
    --danger: #b84234;
    --warning: #b47a00;
    --info: #2f6f9f;
    --success: #2f7d4f;
    --shadow: 0 12px 30px rgba(35, 35, 35, 0.07);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    min-height: 100%;
    margin: 0;
    color: var(--text);
    font-family: "Avenir Next", Avenir, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.5;
    overflow-x: hidden;
}

a {
    color: inherit;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 94px;
    padding: 8px clamp(18px, 4vw, 52px);
    border-bottom: 4px solid var(--brand-blue);
    background: var(--charcoal);
    backdrop-filter: blur(10px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
    text-decoration: none;
}

.brand-logo {
    width: 84px;
    height: 64px;
    flex: 0 0 auto;
    object-fit: contain;
}

.brand-copy strong,
.brand-copy small {
    display: block;
    overflow-wrap: anywhere;
}

.brand-copy strong {
    color: #ffffff;
    font-size: 16px;
    font-weight: 600;
    text-transform: uppercase;
}

.brand-copy small {
    margin-top: 2px;
    color: #bfd5e6;
    font-size: 11px;
    text-transform: uppercase;
}

.topnav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.topnav a {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 12px;
    border-radius: 8px;
    border: 1px solid transparent;
    color: rgba(255, 255, 255, 0.82);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
}

.topnav a:hover,
.topnav a[aria-current="page"] {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.topnav .nav-strong {
    border-color: var(--brand-blue);
    background: #ffffff;
    color: var(--charcoal);
}

.topnav .nav-strong:hover {
    border-color: #ffffff;
    background: var(--brand-blue);
    color: #202224;
}

.page {
    width: min(1220px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 48px;
}

.workspace-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.75fr);
    gap: 18px;
    align-items: start;
}

.home-layout {
    display: grid;
    grid-template-columns: minmax(320px, 0.9fr) minmax(340px, 1fr);
    gap: 18px;
    align-items: start;
}

.side-stack,
.ticket-layout,
.report-grid {
    display: grid;
    gap: 18px;
}

.ticket-layout {
    grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
    align-items: start;
}

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

.portal-hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

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

.module-card {
    min-height: 220px;
    display: grid;
    align-content: start;
    gap: 12px;
    border: 1px solid var(--line);
    border-top: 4px solid var(--brand-blue);
    border-radius: 5px;
    padding: clamp(20px, 3vw, 30px);
    background: var(--surface);
    box-shadow: var(--shadow);
    text-decoration: none;
}

.module-card:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
}

.module-card-primary {
    background: #f8fbfd;
}

.module-kicker {
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.module-card strong {
    color: var(--charcoal);
    font-size: 28px;
    font-weight: 600;
    line-height: 1.1;
}

.module-card small {
    max-width: 520px;
    color: var(--muted);
    font-size: 15px;
}

.portal-note {
    margin-top: 18px;
}

.panel,
.metric {
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.panel {
    padding: clamp(18px, 3vw, 28px);
}

.panel-main {
    min-height: 620px;
    border-top: 3px solid var(--brand-blue);
}

.panel-muted {
    background: var(--surface-muted);
    box-shadow: none;
}

.panel-actions {
    margin-top: 16px;
}

.section-title {
    margin-bottom: 22px;
}

.section-title.compact {
    margin-bottom: 14px;
}

.section-title-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 14px;
}

.count-pill {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border-radius: 999px;
    padding: 5px 10px;
    background: var(--surface-muted);
    color: var(--primary-dark);
    font-size: 12px;
    font-weight: 800;
}

.eyebrow {
    display: block;
    margin-bottom: 6px;
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
    color: var(--charcoal);
    letter-spacing: 0;
    line-height: 1.15;
}

h1 {
    font-size: clamp(28px, 4vw, 44px);
    font-weight: 500;
}

h2 {
    font-size: 22px;
    font-weight: 600;
}

p {
    margin: 0;
    color: var(--muted);
}

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

.compact-form {
    align-items: end;
}

.stack-form {
    display: grid;
    gap: 14px;
}

.filter-grid {
    grid-template-columns: minmax(220px, 1fr) 170px 160px minmax(220px, 1fr) auto;
    align-items: end;
}

.filter-grid-simple {
    grid-template-columns: minmax(260px, 1fr) 190px auto;
}

label {
    display: grid;
    gap: 7px;
}

label span,
dt {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.field-help {
    margin-top: -2px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
}

.readonly-field {
    min-height: 44px;
    display: flex;
    align-items: center;
    border: 1px solid #cbd3d8;
    border-radius: 5px;
    background: #f7fafc;
    padding: 8px 12px;
}

input,
select,
textarea {
    width: 100%;
    min-height: 44px;
    border: 1px solid #cbd3d8;
    border-radius: 5px;
    background: #fff;
    color: var(--text);
    font: inherit;
    padding: 10px 12px;
    outline: none;
}

textarea {
    min-height: 132px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(107, 166, 217, 0.24);
}

.span-all {
    grid-column: 1 / -1;
}

.switch-line {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.switch-line input {
    width: 18px;
    min-height: 18px;
}

.hidden-field {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.form-section {
    margin-top: 6px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.form-actions,
.filter-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.align-end {
    align-self: end;
}

.button {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 5px;
    padding: 10px 14px;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.button-primary {
    background: var(--primary);
    color: white;
}

.button-primary:hover {
    background: var(--primary-dark);
}

.button-secondary {
    border-color: var(--primary);
    background: #fff;
    color: var(--primary);
}

.button-secondary:hover {
    border-color: var(--primary-dark);
    background: var(--surface-muted);
    color: var(--primary-dark);
}

.button-ghost {
    background: transparent;
    color: var(--muted);
}

.button-small {
    min-height: 34px;
    padding: 7px 10px;
    border-color: var(--line);
    background: #fff;
    color: var(--text);
    font-size: 13px;
}

.button-danger {
    background: var(--danger);
    color: #ffffff;
}

.button-danger:hover {
    background: #963528;
}

.alert {
    margin-bottom: 16px;
    border-radius: 5px;
    padding: 13px 15px;
    border: 1px solid var(--line);
    background: #fff;
    font-weight: 700;
}

.alert ul {
    margin: 8px 0 0 20px;
    padding: 0;
    font-weight: 500;
}

.alert-success {
    border-color: rgba(47, 125, 79, 0.35);
    background: #eef8f1;
    color: #205a37;
}

.alert-danger {
    border-color: rgba(217, 84, 69, 0.35);
    background: #fff0ee;
    color: #943125;
}

.narrow-page,
.login-wrap {
    width: min(880px, 100%);
    margin: 0 auto;
    display: grid;
    gap: 18px;
}

.login-wrap {
    min-height: 60vh;
    place-items: center;
}

.login-wrap-home {
    min-height: calc(100vh - 230px);
}

.login-panel {
    width: min(460px, 100%);
}

.login-wrap-home .login-panel {
    position: relative;
    width: min(520px, 100%);
    overflow: hidden;
    border-color: #cbdbe7;
    border-top: 5px solid var(--brand-blue);
    padding: clamp(28px, 5vw, 42px);
    box-shadow: 0 18px 45px rgba(41, 43, 45, 0.12);
}

.login-wrap-home .login-panel::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 76px;
    background: #f3f9fd;
    border-bottom: 1px solid #dfedf6;
    pointer-events: none;
}

.login-wrap-home .section-title,
.login-wrap-home .stack-form {
    position: relative;
}

.login-wrap-home .section-title {
    margin-bottom: 28px;
}

.login-wrap-home .eyebrow {
    color: var(--primary-dark);
}

.login-wrap-home h1 {
    max-width: none;
    color: #343638;
    font-size: 36px;
    font-weight: 500;
    white-space: nowrap;
}

.login-wrap-home label span {
    color: #555e66;
}

.login-wrap-home input {
    min-height: 48px;
    border-color: #c3d1db;
    background: #fbfdff;
}

.login-wrap-home .button-primary {
    min-height: 48px;
    margin-top: 2px;
    background: #397fb6;
    box-shadow: 0 10px 20px rgba(57, 127, 182, 0.18);
}

.login-wrap-home .button-primary:hover {
    background: var(--primary-dark);
}

.ticket-heading,
.admin-hero,
.admin-ticket-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.admin-hero {
    margin-bottom: 18px;
}

.admin-hero p,
.page-intro {
    max-width: 720px;
    margin-top: 8px;
}

.page-intro {
    font-size: 15px;
}

.danger-zone {
    border-color: rgba(184, 66, 52, 0.24);
    background: #fffafa;
}

.danger-zone form {
    margin-top: 18px;
}

.role-help {
    display: grid;
    gap: 10px;
    font-size: 14px;
}

.role-help strong {
    color: var(--charcoal);
}

.module-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
}

.module-tab {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 10px 14px;
    background: #fff;
    color: var(--text);
    font-weight: 800;
    text-decoration: none;
}

.module-tab:hover,
.module-tab.active {
    border-color: var(--primary);
    background: var(--surface-muted);
    color: var(--primary-dark);
}

.admin-ticket-heading {
    align-items: flex-end;
}

.back-link {
    display: inline-block;
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
}

.back-link:hover {
    color: var(--primary);
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    border-radius: 999px;
    padding: 5px 9px;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.badge-open {
    background: #ecf4ff;
    color: #275c8a;
}

.badge-info {
    background: #e8f3f7;
    color: #215875;
}

.badge-warning {
    background: #fff3d8;
    color: #7a5100;
}

.badge-danger {
    background: #ffe7e3;
    color: #a1372a;
}

.badge-success {
    background: #e8f6ed;
    color: #24623d;
}

.badge-muted {
    background: #edf0ef;
    color: #586365;
}

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

.detail-grid div {
    min-width: 0;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

dd {
    margin: 3px 0 0;
    overflow-wrap: anywhere;
    font-weight: 700;
}

.description-box {
    margin-top: 20px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: #fbfcfa;
}

.description-box strong {
    display: block;
    margin-bottom: 6px;
}

.description-box p {
    color: var(--text);
}

.success-box {
    border-color: rgba(47, 125, 79, 0.28);
    background: #f2f8f4;
}

.timeline {
    display: grid;
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.timeline li {
    border-left: 4px solid var(--primary);
    padding: 10px 0 10px 14px;
}

.timeline strong,
.timeline span {
    display: block;
}

.timeline span {
    margin-top: 2px;
    color: var(--muted);
    font-size: 13px;
}

.timeline p {
    margin-top: 6px;
    color: var(--text);
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.compact-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric {
    min-height: 112px;
    display: grid;
    align-content: space-between;
    border-top: 3px solid var(--brand-blue);
    padding: 16px;
}

.metric span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.metric strong {
    color: var(--charcoal);
    font-size: 28px;
    font-weight: 600;
    letter-spacing: 0;
}

.table-panel {
    margin-top: 18px;
}

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 980px;
}

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

th {
    color: #596168;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0;
}

td small {
    color: var(--muted);
}

.empty-state {
    padding: 18px 0;
}

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

.bar-row {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) minmax(120px, 2fr) 44px;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.bar-row span {
    overflow-wrap: anywhere;
    font-weight: 700;
}

.bar-track {
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #e4eaee;
}

.bar-fill {
    height: 100%;
    border-radius: inherit;
    background: var(--brand-blue);
}

.footer {
    width: min(1220px, calc(100% - 32px));
    margin: 0 auto;
    padding: 0 0 26px;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    color: var(--muted);
    font-size: 12px;
}

@media (max-width: 1050px) {
    .home-layout,
    .workspace-grid,
    .ticket-layout,
    .report-grid,
    .module-grid {
        grid-template-columns: 1fr;
    }

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

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

@media (max-width: 720px) {
    .topbar,
    .footer,
    .ticket-heading,
    .admin-hero,
    .admin-ticket-heading,
    .section-title-row {
        align-items: stretch;
        flex-direction: column;
    }

    .topbar {
        min-height: 0;
        padding: 12px 16px;
        gap: 12px;
    }

    .brand {
        width: 100%;
        gap: 12px;
    }

    .topnav {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        justify-content: stretch;
    }

    .topnav a {
        width: 100%;
        min-height: 42px;
        padding: 10px 8px;
        text-align: center;
    }

    .brand-logo {
        width: 68px;
        height: 52px;
    }

    .brand-copy strong {
        font-size: 14px;
        line-height: 1.25;
    }

    .login-wrap-home h1 {
        font-size: clamp(24px, 7vw, 28px);
    }

    .page {
        width: min(100% - 24px, 1220px);
        padding-top: 18px;
    }

    .panel {
        padding: 18px;
    }

    .panel-main {
        min-height: 0;
    }

    .portal-hero {
        align-items: stretch;
        flex-direction: column;
    }

    .module-card {
        min-height: 0;
        padding: 20px;
    }

    .module-card strong {
        font-size: 24px;
    }

    .module-card small {
        font-size: 14px;
    }

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

    .module-tab {
        min-width: 0;
        padding: 10px 8px;
        text-align: center;
        white-space: normal;
    }

    .form-grid,
    .filter-grid,
    .filter-grid-simple,
    .detail-grid,
    .metric-grid,
    .compact-metrics {
        grid-template-columns: 1fr;
    }

    .bar-row {
        grid-template-columns: 1fr 38px;
    }

    .bar-track {
        grid-column: 1 / -1;
        order: 3;
    }

    .button {
        width: 100%;
    }

    .form-actions,
    .filter-actions {
        width: 100%;
    }

    .metric {
        min-height: 96px;
    }

    .metric strong {
        font-size: 24px;
    }

    .badge {
        white-space: normal;
    }

    .table-panel {
        margin-top: 14px;
    }

    .table-scroll {
        overflow-x: visible;
    }

    .table-scroll table {
        width: 100%;
        min-width: 0;
        border-collapse: separate;
        border-spacing: 0 12px;
    }

    .table-scroll thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

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

    .table-scroll tr {
        overflow: hidden;
        border: 1px solid var(--line);
        border-radius: 6px;
        background: #ffffff;
        box-shadow: 0 8px 18px rgba(35, 35, 35, 0.06);
    }

    .table-scroll td {
        display: block;
        padding: 10px 12px;
        border-bottom: 1px solid #edf0f2;
        overflow-wrap: anywhere;
    }

    .table-scroll td::before {
        content: attr(data-label);
        color: #596168;
        font-size: 11px;
        font-weight: 800;
        line-height: 1.2;
        text-transform: uppercase;
        display: block;
        margin-bottom: 3px;
    }

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

    .table-scroll td .button-small {
        width: 100%;
    }
}

@media (max-width: 460px) {
    .topnav,
    .module-tabs {
        grid-template-columns: 1fr;
    }

    .login-wrap-home .login-panel {
        padding: 24px 18px;
    }

    .login-wrap-home .login-panel::before {
        height: 68px;
    }

    .table-scroll td {
        padding: 10px;
    }
}

.forms-public-body {
    background: #eef2f4;
}

.forms-public-page {
    width: min(100%, 100vw);
    padding: clamp(18px, 4vw, 38px) 16px 48px;
}

.forms-public-shell {
    width: min(760px, 100%);
    display: grid;
    gap: 12px;
    margin: 0 auto;
}

.forms-public-banner {
    width: 100%;
    height: clamp(132px, 24vw, 210px);
    display: block;
    border-radius: 8px 8px 0 0;
    object-fit: cover;
    object-position: center;
    background: var(--charcoal);
    box-shadow: var(--shadow);
}

.forms-public-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 3px 12px rgba(35, 35, 35, 0.055);
}

.forms-public-title {
    border-top: 8px solid var(--brand-blue);
    padding: clamp(22px, 4vw, 32px);
}

.forms-public-title h1 {
    max-width: 680px;
    font-size: 34px;
}

.forms-public-title p {
    max-width: 610px;
    margin-top: 10px;
}

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

.forms-question {
    padding: clamp(18px, 3vw, 24px);
}

.forms-question label {
    gap: 10px;
}

.forms-question label > span,
.forms-question legend {
    color: var(--text);
    font-size: 15px;
    font-weight: 700;
}

.forms-question strong {
    color: var(--danger);
}

.forms-question input,
.forms-question textarea {
    background: #ffffff;
}

.forms-question input:not([type="radio"]),
.forms-question textarea {
    border-width: 0 0 1px;
    border-radius: 0;
    padding-inline: 0;
}

.forms-question input:not([type="radio"]):focus,
.forms-question textarea:focus {
    box-shadow: none;
}

.forms-question fieldset {
    min-width: 0;
    display: grid;
    gap: 12px;
    margin: 0;
    padding: 0;
    border: 0;
}

.forms-radio-group {
    display: grid;
    gap: 10px;
}

.forms-radio-option {
    min-height: 34px;
    display: flex;
    grid-template-columns: none;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
}

.forms-radio-option input {
    width: 18px;
    min-height: 18px;
    margin: 0;
    accent-color: var(--primary);
}

.forms-radio-option span {
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
}

.forms-public-actions {
    display: flex;
    justify-content: flex-start;
    padding-top: 4px;
}

@media (max-width: 640px) {
    .forms-public-title h1 {
        font-size: 28px;
    }
}
