:root {
    --bg: #f2efe8;
    --bg-accent: #e4ddd1;
    --surface: rgba(255, 252, 246, 0.92);
    --surface-strong: #fffdfa;
    --text: #1f2a24;
    --muted: #5f6c65;
    --line: #d8d0c3;
    --primary: #1f6b52;
    --primary-dark: #164d3b;
    --secondary: #b85c38;
    --warning: #d97706;
    --danger: #b42318;
    --success: #1f7a45;
    --shadow: 0 18px 40px rgba(31, 42, 36, 0.08);
    --radius-lg: 22px;
    --radius-md: 16px;
    --radius-sm: 12px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(184, 92, 56, 0.08), transparent 28%),
        radial-gradient(circle at top right, rgba(31, 107, 82, 0.12), transparent 24%),
        linear-gradient(180deg, #f8f4ec 0%, var(--bg) 55%, #ece5d8 100%);
}

a {
    color: inherit;
}

.shell {
    min-height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 18px 28px;
    backdrop-filter: blur(16px);
    background: rgba(28, 41, 35, 0.88);
    color: #f8f4ec;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-block {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.brand-kicker,
.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 11px;
    font-weight: 700;
}

.brand-kicker {
    color: rgba(248, 244, 236, 0.66);
}

.brand {
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
    font-size: 24px;
    font-weight: 700;
    text-decoration: none;
}

.nav {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.nav a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 999px;
    color: #f8f4ec;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.04);
}

.nav a:hover,
.nav a:focus-visible {
    background: rgba(255, 255, 255, 0.12);
}

.nav-pill {
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--secondary);
    color: white;
    font-size: 12px;
    font-weight: 700;
}

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

.userbox-name {
    font-weight: 700;
}

.userbox-role {
    color: rgba(248, 244, 236, 0.7);
    font-size: 13px;
}

.container {
    width: min(1400px, calc(100vw - 32px));
    margin: 0 auto;
    padding: 28px 0 56px;
}

.hero {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 20px;
    align-items: start;
    padding: 24px 28px;
    margin-bottom: 20px;
    background: linear-gradient(140deg, rgba(255, 252, 246, 0.95), rgba(228, 221, 209, 0.8));
    border: 1px solid rgba(31, 107, 82, 0.14);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

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

.hero h1,
.card h1,
.card h2,
.card h3 {
    margin: 0;
}

.hero h1 {
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
    font-size: clamp(32px, 4vw, 46px);
    line-height: 1.05;
    margin-top: 8px;
    margin-bottom: 10px;
}

.lead {
    font-size: 17px;
    line-height: 1.6;
}

.card,
.metric-card {
    background: var(--surface);
    border: 1px solid rgba(31, 107, 82, 0.12);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.card {
    padding: 22px;
    margin-bottom: 20px;
}

.card.narrow {
    max-width: 520px;
    margin: 52px auto;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 18px;
}

.section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
}

.metric-grid.compact {
    min-width: min(100%, 520px);
}

.metric-card {
    padding: 18px;
}

.metric-title {
    color: var(--muted);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 10px;
}

.metric-value {
    font-size: 32px;
    font-weight: 700;
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
}

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

.pill,
.pill-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 7px 14px;
    border-radius: 999px;
    background: rgba(31, 107, 82, 0.08);
    color: var(--primary-dark);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
}

.pill-link:hover {
    background: rgba(31, 107, 82, 0.16);
}

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

.note,
.input-note {
    font-size: 13px;
    color: var(--muted);
}

code {
    font-family: "IBM Plex Mono", "SFMono-Regular", monospace;
    font-size: 12px;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stack-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.grid-form,
.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

.filter-grid {
    align-items: end;
}

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

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

.detail-grid div {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 14px;
    background: rgba(31, 107, 82, 0.05);
    border-radius: var(--radius-sm);
}

.detail-layout {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.ticket-shell {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 0.9fr);
    gap: 20px;
    margin-bottom: 20px;
}

.ticket-side {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.ticket-main {
    margin-bottom: 0;
}

.subsection {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.action-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 18px;
}

.inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: end;
}

#auth-status {
    min-height: 1.5em;
}

.top-gap {
    margin-top: 16px;
}

label {
    display: flex;
    flex-direction: column;
    gap: 7px;
    font-size: 14px;
    font-weight: 600;
}

.checkbox {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    grid-column: 1 / -1;
}

.full-width {
    grid-column: 1 / -1;
}

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.88);
    color: var(--text);
}

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

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
    outline: 2px solid rgba(31, 107, 82, 0.24);
    outline-offset: 2px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 18px;
    border: none;
    border-radius: 999px;
    background: linear-gradient(120deg, var(--primary), var(--primary-dark));
    color: white;
    cursor: pointer;
    text-decoration: none;
    font-weight: 700;
}

.button.secondary {
    background: linear-gradient(120deg, #6b756c, #465149);
}

.button.ghost {
    background: transparent;
    color: var(--primary-dark);
    border: 1px solid rgba(31, 107, 82, 0.22);
}

.flash-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 18px;
}

.flash {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
}

.flash.error {
    border-color: rgba(180, 35, 24, 0.18);
    background: rgba(180, 35, 24, 0.08);
    color: var(--danger);
}

.flash.success {
    border-color: rgba(31, 122, 69, 0.2);
    background: rgba(31, 122, 69, 0.08);
    color: var(--success);
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.status-new {
    background: #d8ecff;
    color: #0d4f87;
}

.status-triaged {
    background: #ede3ff;
    color: #5b2abf;
}

.status-in_progress {
    background: #ffe9ba;
    color: #855200;
}

.status-waiting_employee {
    background: #ffd7c2;
    color: #8b3e0a;
}

.status-planned {
    background: #e4e1da;
    color: #544b40;
}

.status-resolved {
    background: #d5f2da;
    color: #1d6c35;
}

.status-closed {
    background: #dde4df;
    color: #415149;
}

.priority-high {
    background: rgba(180, 35, 24, 0.12);
    color: var(--danger);
}

.priority-normal {
    background: rgba(217, 119, 6, 0.12);
    color: #9a5707;
}

.priority-low {
    background: rgba(31, 107, 82, 0.12);
    color: var(--primary-dark);
}

.warning {
    background: rgba(217, 119, 6, 0.14);
    color: #9a5707;
}

.waiting {
    background: rgba(184, 92, 56, 0.14);
    color: #8e4429;
}

.internal {
    background: rgba(31, 42, 36, 0.08);
    color: #39463f;
}

.kanban-board {
    display: grid;
    grid-template-columns: repeat(5, minmax(250px, 1fr));
    gap: 16px;
    align-items: start;
    overflow-x: auto;
    padding-bottom: 8px;
}

.kanban-column {
    min-height: 340px;
    display: flex;
    flex-direction: column;
    background: rgba(255, 252, 246, 0.7);
    border: 1px solid rgba(31, 107, 82, 0.12);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.kanban-column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    font-weight: 700;
}

.kanban-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    border-radius: 999px;
    background: rgba(31, 107, 82, 0.08);
    color: var(--primary-dark);
}

.kanban-dropzone {
    min-height: 250px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: background 140ms ease;
}

.kanban-dropzone.is-over {
    background: rgba(31, 107, 82, 0.08);
}

.ticket-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(31, 107, 82, 0.12);
    background: var(--surface-strong);
    cursor: grab;
}

.ticket-card.is-overdue {
    border-color: rgba(217, 119, 6, 0.35);
    box-shadow: inset 0 0 0 1px rgba(217, 119, 6, 0.08);
}

.ticket-card-top,
.ticket-card-foot,
.list-card-top,
.card-foot,
.message-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.ticket-card h3 {
    font-size: 17px;
}

.ticket-id,
.ticket-age {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.ticket-meta,
.list-card-meta,
.table-subtitle {
    color: var(--muted);
    font-size: 13px;
}

.ticket-link {
    color: var(--primary-dark);
    font-weight: 700;
    text-decoration: none;
}

.table-wrap {
    overflow: auto;
}

.table-wrap .inline-form {
    min-width: 320px;
}

.table-wrap .inline-form input,
.table-wrap .inline-form select {
    min-width: 140px;
}

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

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

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.table-title {
    font-weight: 700;
    margin-bottom: 4px;
}

.list-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(31, 107, 82, 0.12);
    background: rgba(255, 255, 255, 0.8);
    color: inherit;
    text-decoration: none;
}

.list-card.compact {
    gap: 6px;
}

.list-card.unread {
    border-color: rgba(184, 92, 56, 0.28);
    background: rgba(255, 248, 242, 0.95);
}

.message-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 18px;
}

.message {
    padding: 14px 16px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.76);
    border: 1px solid rgba(31, 107, 82, 0.1);
}

.message.internal {
    background: rgba(31, 42, 36, 0.05);
}

.message p {
    margin-bottom: 0;
    line-height: 1.55;
}

.event-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.event-list li {
    padding: 14px 16px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(31, 107, 82, 0.08);
}

.trend-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.trend-row {
    display: grid;
    grid-template-columns: 120px 1fr 40px;
    gap: 12px;
    align-items: center;
}

.trend-label,
.trend-value {
    font-size: 13px;
    color: var(--muted);
}

.trend-bar-wrap {
    height: 14px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(31, 107, 82, 0.08);
}

.trend-bar {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(120deg, var(--secondary), var(--primary));
}

.knowledge-body {
    white-space: pre-line;
    line-height: 1.65;
}

.empty-state {
    padding: 22px;
    border-radius: var(--radius-md);
    background: rgba(31, 107, 82, 0.05);
    color: var(--muted);
    text-align: center;
}

.empty-state.small {
    padding: 14px;
}

code {
    background: rgba(31, 42, 36, 0.08);
    padding: 2px 6px;
    border-radius: 6px;
}

@media (max-width: 1080px) {
    .hero,
    .hero.slim,
    .ticket-shell {
        grid-template-columns: 1fr;
    }

    .kanban-board {
        grid-template-columns: repeat(2, minmax(260px, 1fr));
    }
}

@media (max-width: 760px) {
    .topbar,
    .section-head,
    .ticket-card-top,
    .ticket-card-foot,
    .list-card-top,
    .message-head,
    .card-foot,
    .userbox {
        align-items: flex-start;
        flex-direction: column;
    }

    .container {
        width: min(100vw - 24px, 100%);
    }

    .hero,
    .card {
        padding: 18px;
    }

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

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