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

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;
    text-decoration: none;
}

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

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

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

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

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

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

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

.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(5, minmax(0, 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;
}

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 {
        align-items: stretch;
        flex-direction: column;
    }

    .topnav {
        justify-content: flex-start;
    }

    .brand-logo {
        width: 74px;
        height: 56px;
    }

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

    .login-wrap-home h1 {
        font-size: 28px;
    }

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

    .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%;
    }
}
