:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --ink: #16202a;
    --muted: #657386;
    --line: #dde4ee;
    --primary: #175cff;
    --primary-dark: #0d42bd;
    --success: #0b8f5a;
    --warning: #aa6a00;
    --danger: #b42318;
    --shadow: 0 20px 60px rgba(22, 32, 42, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

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

.topbar {
    align-items: center;
    background: rgba(255, 255, 255, 0.88);
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 24px;
    justify-content: space-between;
    padding: 16px clamp(18px, 4vw, 48px);
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(18px);
}

.brand,
.nav {
    align-items: center;
    display: flex;
    gap: 14px;
}

.brand {
    font-weight: 800;
    letter-spacing: 0;
}

.brand-mark {
    align-items: center;
    background: var(--ink);
    border-radius: 8px;
    color: #fff;
    display: inline-flex;
    height: 34px;
    justify-content: center;
    width: 34px;
}

.nav {
    color: var(--muted);
    font-size: 14px;
    font-weight: 650;
}

.nav a:hover,
.link-button:hover {
    color: var(--ink);
}

.link-button {
    background: transparent;
    border: 0;
    color: var(--muted);
    cursor: pointer;
    font: inherit;
    padding: 0;
}

.shell {
    margin: 0 auto;
    max-width: 1180px;
    padding: 36px clamp(18px, 4vw, 48px) 64px;
}

.hero {
    align-items: stretch;
    display: grid;
    gap: 28px;
    grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
    min-height: calc(100vh - 150px);
}

.hero-copy {
    align-self: center;
    padding: 48px 0;
}

.eyebrow {
    color: var(--primary);
    font-size: 13px;
    font-weight: 800;
    margin: 0 0 10px;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    font-size: clamp(36px, 6vw, 74px);
    letter-spacing: 0;
    line-height: 0.98;
    margin-bottom: 22px;
    max-width: 860px;
}

h2 {
    font-size: 19px;
    line-height: 1.2;
}

.hero-copy p:not(.eyebrow),
.section-head p {
    color: var(--muted);
    font-size: 17px;
    max-width: 650px;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 30px;
}

.hero-panel {
    align-content: center;
    display: grid;
    gap: 14px;
}

.metric,
.panel,
.ticket-row,
.message,
.empty-state,
.user-row {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.metric {
    padding: 26px;
}

.metric span,
.ticket-id,
.message-head span,
.message-head time,
.details dt,
.activity span,
.user-row span {
    color: var(--muted);
    font-size: 13px;
}

.metric strong {
    display: block;
    font-size: 25px;
    margin-top: 8px;
}

.button {
    align-items: center;
    background: var(--primary);
    border: 1px solid var(--primary);
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    font-size: 15px;
    font-weight: 760;
    justify-content: center;
    min-height: 44px;
    padding: 10px 18px;
}

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

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

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

.button.danger:hover {
    background: #8f1d15;
    border-color: #8f1d15;
}

.button.small {
    min-height: 36px;
    padding: 7px 12px;
}

.button.full {
    width: 100%;
}

.panel,
.empty-state {
    padding: clamp(22px, 4vw, 34px);
}

.panel.narrow {
    margin: 28px auto;
    max-width: 520px;
}

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

.row-head {
    align-items: center;
    display: flex;
    gap: 18px;
    justify-content: space-between;
}

.section-head h1,
.ticket-title h1 {
    font-size: clamp(28px, 4vw, 46px);
    line-height: 1.05;
    margin-bottom: 8px;
}

.form {
    display: grid;
    gap: 18px;
}

.form label,
.stack-form label {
    color: var(--ink);
    display: grid;
    font-size: 14px;
    font-weight: 750;
    gap: 8px;
}

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

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    outline: 3px solid rgba(23, 92, 255, 0.16);
}

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

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

.flash.success {
    background: #eaf8f1;
    color: var(--success);
}

.flash.error {
    background: #fff0ed;
    color: var(--danger);
}

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

.filters a {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
    padding: 8px 12px;
}

.filters a.active {
    background: var(--ink);
    border-color: var(--ink);
    color: #fff;
}

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

.ticket-row {
    align-items: center;
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 18px;
}

.ticket-row:hover {
    border-color: #b7c4d8;
}

.ticket-row h2 {
    margin: 5px 0 7px;
}

.ticket-row p {
    color: var(--muted);
    margin-bottom: 0;
}

.row-meta {
    align-items: flex-end;
    display: grid;
    gap: 7px;
    justify-items: end;
}

.badge {
    border-radius: 999px;
    display: inline-flex;
    font-size: 12px;
    font-weight: 800;
    padding: 5px 10px;
}

.badge.open {
    background: #eaf1ff;
    color: var(--primary-dark);
}

.badge.in_progress {
    background: #fff5dc;
    color: var(--warning);
}

.badge.waiting_customer {
    background: #f3e8ff;
    color: #6d28d9;
}

.badge.resolved,
.badge.closed {
    background: #eaf8f1;
    color: var(--success);
}

.priority,
.row-meta time {
    color: var(--muted);
    font-size: 13px;
}

.ticket-detail {
    align-items: start;
    display: grid;
    gap: 22px;
    grid-template-columns: minmax(0, 1fr) 320px;
}

.ticket-title {
    align-items: start;
    display: flex;
    gap: 16px;
    justify-content: space-between;
}

.ticket-title p {
    color: var(--muted);
    margin-bottom: 0;
}

.conversation {
    display: grid;
    gap: 14px;
    margin: 18px 0;
}

.message {
    padding: 20px;
}

.message.agent {
    border-left: 4px solid var(--primary);
}

.message.customer {
    border-left: 4px solid #7c8a9e;
}

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

.message p {
    margin-bottom: 0;
    white-space: normal;
}

.message-head {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.ticket-side {
    display: grid;
    gap: 18px;
    position: sticky;
    top: 90px;
}

.details {
    display: grid;
    gap: 10px;
    grid-template-columns: auto 1fr;
    margin: 0;
}

.details dd {
    margin: 0;
    text-align: right;
}

.stack-form {
    display: grid;
    gap: 12px;
    margin-top: 12px;
}

.check {
    align-items: center;
    display: flex !important;
    gap: 9px !important;
}

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

.check.compact {
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

.activity {
    display: grid;
    gap: 10px;
}

.activity p {
    border-bottom: 1px solid var(--line);
    margin: 0;
    padding-bottom: 10px;
}

.activity p:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.activity span {
    display: block;
}

.danger-zone {
    border-top: 1px solid var(--line);
    display: grid;
    gap: 12px;
    margin-top: 18px;
    padding-top: 18px;
}

.danger-zone p {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 0;
}

.modal-backdrop {
    align-items: center;
    background: rgba(15, 23, 42, 0.46);
    display: flex;
    inset: 0;
    justify-content: center;
    padding: 22px;
    position: fixed;
    z-index: 50;
}

.modal-backdrop[hidden] {
    display: none;
}

.modal {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 30px 90px rgba(15, 23, 42, 0.24);
    max-width: 460px;
    padding: 28px;
    width: 100%;
}

.modal h2 {
    font-size: 26px;
    margin-bottom: 10px;
}

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

.modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 22px;
}

.empty-state {
    text-align: center;
}

.empty-state p {
    color: var(--muted);
    margin-bottom: 0;
}

.user-table {
    display: grid;
    gap: 10px;
}

.user-row {
    align-items: center;
    display: grid;
    gap: 14px;
    grid-template-columns: minmax(0, 1fr) 150px 110px auto;
    padding: 14px;
}

.user-row strong,
.user-row span {
    display: block;
}

@media (max-width: 860px) {
    .topbar,
    .nav,
    .row-head,
    .ticket-title {
        align-items: flex-start;
        flex-direction: column;
    }

    .hero,
    .ticket-detail,
    .grid.two,
    .ticket-row,
    .user-row {
        grid-template-columns: 1fr;
    }

    .hero {
        min-height: auto;
    }

    .hero-copy {
        padding: 24px 0 0;
    }

    .row-meta {
        align-items: start;
        justify-items: start;
    }

    .ticket-side {
        position: static;
    }
}
