:root {
    --ink: #07131f;
    --navy: #0b2740;
    --blue: #17a9d6;
    --coral: #f46f47;
    --green: #14b881;
    --soft: #f5f9fc;
    --line: #dfe8ef;
    --muted: #637486;
}

* {
    box-sizing: border-box;
    letter-spacing: 0;
}

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

body.theme-dark {
    --ink: #f7fbff;
    --navy: #102a43;
    --soft: #07131f;
    --line: rgba(255,255,255,.14);
    --muted: #a9b8c8;
    background: #07131f;
    color: #f7fbff;
}

a {
    color: inherit;
}

.topbar {
    align-items: center;
    background: #fff;
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 22px;
    min-height: 72px;
    padding: 12px 28px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.theme-dark .topbar,
.theme-dark .card,
.theme-dark .form,
.theme-dark .table {
    background: #0d1b2a;
}

.theme-dark input,
.theme-dark select,
.theme-dark textarea {
    background: #07131f;
    border-color: rgba(255,255,255,.18);
    color: #f7fbff;
}

.theme-dark .table th {
    background: rgba(255,255,255,.06);
}

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

.brand-logo {
    display: block;
    flex: 0 0 auto;
    height: 54px;
    object-fit: contain;
    width: 148px;
}

.theme-dark .brand-logo {
    filter: drop-shadow(0 10px 20px rgba(0,0,0,.34));
}

.brand-title {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.brand-title strong {
    line-height: 1.05;
    white-space: nowrap;
}

.brand small {
    color: var(--muted);
    display: block;
    margin-top: 2px;
}

.nav {
    align-items: center;
    display: flex;
    flex: 1;
    gap: 8px;
}

.nav a,
.account button,
.button {
    border: 0;
    border-radius: 8px;
    display: inline-flex;
    font-size: 14px;
    font-weight: 800;
    justify-content: center;
    min-height: 42px;
    padding: 12px 14px;
    text-decoration: none;
}

.nav a {
    color: var(--muted);
}

.nav a:hover {
    background: var(--soft);
    color: var(--blue);
}

.nav .nav-cta,
.button.primary {
    background: var(--coral);
    color: #fff;
}

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

.button.ghost {
    background: transparent;
    border: 1px solid var(--line);
    color: var(--muted);
}

.account {
    align-items: center;
    display: flex;
    gap: 12px;
}

.prefs {
    align-items: center;
    display: flex;
    gap: 8px;
}

.prefs label {
    color: var(--muted);
    display: grid;
    font-size: 11px;
    gap: 3px;
    min-width: 74px;
}

.prefs select {
    min-height: 34px;
    padding: 6px 8px;
}

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

.account button {
    background: var(--ink);
    color: #fff;
    cursor: pointer;
}

.page {
    margin: 0 auto;
    max-width: 1480px;
    padding: 32px 24px 72px;
}

.dashboard-top {
    align-items: end;
    display: flex;
    gap: 20px;
    justify-content: space-between;
    margin-bottom: 22px;
}

.dashboard-top h1 {
    font-size: clamp(34px, 4vw, 56px);
    line-height: 1.05;
    margin: 0 0 10px;
}

.eyebrow {
    color: var(--blue);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0;
    margin: 0 0 8px;
    text-transform: uppercase;
}

.period-filter {
    align-items: center;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: inline-flex;
    gap: 4px;
    padding: 5px;
}

.theme-dark .period-filter {
    background: #0d1b2a;
}

.period-filter button {
    background: transparent;
    border: 0;
    border-radius: 6px;
    color: var(--muted);
    cursor: pointer;
    font: inherit;
    font-weight: 900;
    min-height: 38px;
    padding: 8px 14px;
}

.period-filter button.active,
.period-filter button:hover {
    background: var(--coral);
    color: #fff;
}

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

.metric-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 9px;
    min-height: 154px;
    padding: 22px;
}

.theme-dark .metric-card {
    background: #0d1b2a;
}

.metric-card span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
}

.metric-card strong {
    color: var(--ink);
    font-size: 44px;
    line-height: 1;
}

.metric-card small {
    color: var(--muted);
    font-size: 14px;
    font-weight: 800;
}

.metric-card.blue { border-top: 4px solid var(--blue); }
.metric-card.coral { border-top: 4px solid var(--coral); }
.metric-card.green { border-top: 4px solid var(--green); }
.metric-card.navy { border-top: 4px solid #7f93a8; }

.charts-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(320px, .85fr) minmax(0, 1.55fr);
    margin-bottom: 16px;
}

.chart-card {
    min-height: 330px;
}

.chart-title {
    align-items: center;
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.chart-title h2 {
    margin: 0 0 4px;
}

.chart-title p {
    margin: 0;
}

.status-chart {
    display: grid;
    gap: 18px;
}

.status-row {
    display: grid;
    gap: 8px;
}

.status-row-label {
    align-items: center;
    display: flex;
    justify-content: space-between;
}

.status-row-label span {
    color: var(--muted);
    font-size: 14px;
    font-weight: 900;
}

.status-row-label strong {
    font-size: 18px;
}

.status-track {
    background: rgba(127,147,168,.18);
    border-radius: 999px;
    height: 12px;
    overflow: hidden;
}

.status-track span {
    border-radius: inherit;
    display: block;
    height: 100%;
}

.status-track span.blue,
.legend i.blue { background: var(--blue); }
.status-track span.coral,
.legend i.coral { background: var(--coral); }
.status-track span.green,
.legend i.green { background: var(--green); }
.status-track span.navy,
.legend i.navy { background: #7f93a8; }

.timeline-chart {
    align-items: end;
    display: grid;
    gap: 10px;
    grid-auto-columns: minmax(38px, 1fr);
    grid-auto-flow: column;
    min-height: 220px;
    overflow-x: auto;
    padding: 12px 2px 4px;
}

.timeline-item {
    align-items: center;
    display: grid;
    gap: 8px;
    justify-items: center;
    min-width: 38px;
}

.timeline-value {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}

.timeline-bar {
    align-items: end;
    background: rgba(23,169,214,.18);
    border-radius: 8px 8px 4px 4px;
    display: flex;
    flex-direction: column;
    justify-content: end;
    min-height: 4px;
    overflow: hidden;
    width: 28px;
}

.timeline-bar span {
    display: block;
    width: 100%;
}

.bar-open { background: var(--coral); }
.bar-progress { background: var(--green); }
.bar-closed { background: #7f93a8; }

.timeline-label {
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    min-height: 30px;
    text-align: center;
    white-space: nowrap;
    writing-mode: vertical-rl;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 18px;
}

.legend span {
    align-items: center;
    color: var(--muted);
    display: inline-flex;
    font-size: 12px;
    font-weight: 900;
    gap: 7px;
}

.legend i {
    border-radius: 999px;
    display: inline-block;
    height: 10px;
    width: 10px;
}

.ops-grid {
    margin-top: 16px;
}

.hero {
    background: linear-gradient(135deg, var(--ink), var(--navy));
    border-radius: 8px;
    color: #fff;
    margin-bottom: 22px;
    padding: 34px;
}

.hero h1 {
    font-size: clamp(32px, 5vw, 54px);
    line-height: 1.05;
    margin: 0 0 12px;
}

.hero p {
    color: rgba(255,255,255,.76);
    font-size: 17px;
    line-height: 1.65;
    margin: 0;
    max-width: 760px;
}

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

.link-grid {
    align-items: start;
    grid-template-columns: minmax(320px, 520px) minmax(260px, 1fr);
}

.integration-grid {
    align-items: stretch;
    margin-bottom: 16px;
}

.section-block {
    display: grid;
    gap: 12px;
    margin-top: 20px;
}

.section-block h2 {
    margin: 0;
}

.card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 22px;
}

.card h2,
.card h3 {
    margin: 0 0 10px;
}

.muted {
    color: var(--muted);
}

.stat {
    font-size: 36px;
    font-weight: 900;
    line-height: 1;
}

.table {
    background: #fff;
    border: 1px solid var(--line);
    border-collapse: collapse;
    border-radius: 8px;
    overflow: hidden;
    width: 100%;
}

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

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

.form {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 14px;
    max-width: 760px;
    padding: 22px;
}

.ticket-form {
    max-width: 900px;
}

.integration-form {
    max-width: 980px;
}

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

.check-row {
    align-items: center;
    display: flex;
    gap: 10px;
}

.check-row input {
    min-height: auto;
    width: auto;
}

.compact-hero {
    padding: 26px 30px;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 14px;
}

.filter-bar {
    align-items: end;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(240px, 1fr) minmax(150px, 190px) minmax(150px, 190px) auto auto;
    margin-bottom: 16px;
    padding: 16px;
}

.theme-dark .filter-bar {
    background: #0d1b2a;
}

label {
    color: var(--muted);
    display: grid;
    font-size: 13px;
    font-weight: 800;
    gap: 6px;
}

input,
select,
textarea {
    border: 1px solid #cfdbe6;
    border-radius: 8px;
    color: var(--ink);
    font: inherit;
    min-height: 44px;
    padding: 10px 12px;
    width: 100%;
}

textarea {
    min-height: 130px;
}

.form-note {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    line-height: 1.45;
    margin: 0;
}

.selection-summary {
    background: rgba(23, 169, 214, .1);
    border: 1px solid rgba(23, 169, 214, .22);
    border-radius: 8px;
    color: var(--ink);
    font-size: 13px;
    font-weight: 900;
    line-height: 1.45;
    margin: 0;
    padding: 12px;
}

.suggest-field {
    display: block;
    position: relative;
}

.suggestions {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 18px 40px rgba(7, 19, 31, .16);
    display: none;
    left: 0;
    max-height: 290px;
    overflow-y: auto;
    padding: 6px;
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 30;
}

.theme-dark .suggestions {
    background: #0d1b2a;
    box-shadow: 0 18px 40px rgba(0, 0, 0, .38);
}

.suggestions.open {
    display: grid;
    gap: 4px;
}

.suggestion-item {
    background: transparent;
    border: 0;
    border-radius: 6px;
    color: var(--ink);
    cursor: pointer;
    display: grid;
    gap: 4px;
    padding: 10px;
    text-align: left;
    width: 100%;
}

.suggestion-item:hover,
.suggestion-item:focus {
    background: rgba(23, 169, 214, .12);
    outline: none;
}

.suggestion-item strong {
    font-size: 14px;
    line-height: 1.25;
}

.suggestion-item span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    line-height: 1.35;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.flash {
    border-radius: 8px;
    font-weight: 800;
    margin-bottom: 18px;
    padding: 14px 16px;
}

.flash.ok {
    background: #e6f8f1;
    color: #086b4a;
}

.flash.warn {
    background: #fff4db;
    color: #8a5b00;
}

.flash.error {
    background: #ffe7e4;
    color: #8d2419;
}

.login {
    align-items: center;
    background: linear-gradient(135deg, var(--ink), var(--navy));
    display: grid;
    min-height: 100vh;
    padding: 24px;
}

.login .form {
    margin: 0 auto;
    max-width: 430px;
    width: 100%;
}

@media (max-width: 900px) {
    .topbar,
    .nav,
    .account {
        align-items: stretch;
        flex-direction: column;
    }

    .prefs {
        align-items: stretch;
        flex-direction: row;
    }

    .brand {
        min-width: auto;
    }

    .brand-logo {
        height: 48px;
        width: 132px;
    }

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

    .dashboard-top {
        align-items: stretch;
        flex-direction: column;
    }

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

    .metric-grid,
    .charts-grid {
        grid-template-columns: 1fr;
    }

    .filter-bar {
        grid-template-columns: 1fr;
    }

    .field-pair {
        grid-template-columns: 1fr;
    }
}
