:root {
    --bg: #eef3f8;
    --panel: #ffffff;
    --panel-soft: #f7f9fc;
    --text: #182230;
    --muted: #667085;
    --line: #d8e1ea;
    --primary: #1d4ed8;
    --primary-dark: #173ea6;
    --success: #15803d;
    --warning: #b45309;
    --danger: #b42318;
    --dark: #111827;
    --sidebar: #111827;
    --sidebar-soft: #1f2937;
    --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.app-shell {
    min-height: 100vh;
    display: flex;
}

.sidebar {
    width: 286px;
    min-height: 100vh;
    background: linear-gradient(180deg, var(--sidebar) 0%, #0b1220 100%);
    color: #ffffff;
    padding: 24px 18px;
    position: sticky;
    top: 0;
}

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

.brand-block {
    margin-bottom: 30px;
}

.brand-icon {
    width: 46px;
    height: 46px;
    border-radius: 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #2563eb 0%, #14b8a6 100%);
    color: #ffffff;
    font-weight: 900;
    letter-spacing: -0.04em;
    box-shadow: 0 14px 30px rgba(37, 99, 235, 0.35);
}

.brand-icon.large {
    width: 58px;
    height: 58px;
    font-size: 18px;
}

.brand-title {
    font-weight: 800;
    font-size: 18px;
    line-height: 1.1;
}

.brand-subtitle {
    color: #cbd5e1;
    font-size: 13px;
    margin-top: 2px;
}

.nav-list {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.nav-section {
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 11px;
    margin: 18px 12px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 12px 13px;
    border-radius: 13px;
    color: #e5e7eb;
    font-weight: 600;
}

.nav-item:hover,
.nav-item.active {
    background: var(--sidebar-soft);
    color: #ffffff;
    text-decoration: none;
}

.main {
    flex: 1;
    padding: 28px;
    min-width: 0;
}

.main-public {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

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

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

.topbar h1,
.login-brand h1 {
    margin-bottom: 0;
    letter-spacing: -0.03em;
}

.login-brand p,
.card-head p {
    margin: 6px 0 0;
    color: var(--muted);
}

.user-pill {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 10px 14px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    white-space: nowrap;
}

.status-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    background: #16a34a;
    border-radius: 50%;
    margin-right: 7px;
}

.public-card,
.content-card,
.stat-card {
    background: var(--panel);
    border: 1px solid rgba(216, 225, 234, 0.9);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.public-card {
    width: min(470px, 100%);
    padding: 30px;
}

.public-card.wide {
    width: min(900px, 100%);
}

.public-footer {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    color: var(--muted);
}

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

.narrow-card {
    max-width: 920px;
}

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

.card-head h2 {
    font-size: 22px;
    margin-bottom: 0;
    letter-spacing: -0.02em;
}

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

.stat-card {
    padding: 20px;
}

.stat-card span {
    color: var(--muted);
    display: block;
    font-weight: 700;
    margin-bottom: 8px;
}

.stat-card strong {
    font-size: 34px;
    letter-spacing: -0.04em;
}

.form-grid {
    display: grid;
    gap: 16px;
    margin-top: 22px;
}

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

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

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

label {
    color: var(--text);
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    margin-top: 7px;
    border: 1px solid #cfd8e3;
    border-radius: 12px;
    padding: 11px 13px;
    font: inherit;
    color: var(--text);
    background: #ffffff;
    outline: none;
}

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

input:focus,
select:focus,
textarea:focus {
    border-color: #93c5fd;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

.form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

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

.btn {
    border: 0;
    border-radius: 12px;
    padding: 11px 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 800;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.2;
}

.btn:hover {
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
}

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

.btn-secondary {
    background: #eef2f7;
    color: #243047;
}

.btn-small {
    padding: 8px 11px;
    font-size: 13px;
}

.alert {
    border-radius: 14px;
    padding: 13px 15px;
    margin-bottom: 16px;
    border: 1px solid transparent;
    font-weight: 700;
}

.alert-success {
    color: #14532d;
    background: #dcfce7;
    border-color: #bbf7d0;
}

.alert-danger {
    color: #7f1d1d;
    background: #fee2e2;
    border-color: #fecaca;
}

.alert-warning {
    color: #78350f;
    background: #fef3c7;
    border-color: #fde68a;
}

.hint-box,
.empty-state {
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px 16px;
    color: var(--muted);
}

.table-wrap {
    overflow-x: auto;
}

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

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

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

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

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.badge-open,
.badge-in_progress,
.badge-waiting_customer {
    color: #1e3a8a;
    background: #dbeafe;
}

.badge-resolved {
    color: #14532d;
    background: #dcfce7;
}

.badge-closed {
    color: #475569;
    background: #e2e8f0;
}

.badge-priority-low {
    color: #475569;
    background: #e2e8f0;
}

.badge-priority-normal {
    color: #1e3a8a;
    background: #dbeafe;
}

.badge-priority-high {
    color: #92400e;
    background: #fef3c7;
}

.badge-priority-urgent,
.badge-internal {
    color: #7f1d1d;
    background: #fee2e2;
}

.filter-bar {
    display: grid;
    grid-template-columns: 2fr repeat(3, minmax(150px, 1fr)) auto;
    gap: 10px;
    margin-bottom: 18px;
}

.filter-bar input,
.filter-bar select {
    margin-top: 0;
}

.pagination {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 18px;
}

.page-link {
    padding: 8px 12px;
    border-radius: 10px;
    background: #eef2f7;
    font-weight: 800;
}

.page-link.active {
    background: var(--primary);
    color: #ffffff;
}

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

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

.ticket-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.message-list {
    display: grid;
    gap: 14px;
    margin-bottom: 22px;
}

.message-card {
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 16px;
}

.message-card.internal {
    background: #fff7ed;
    border-color: #fed7aa;
}

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

.message-meta span {
    color: var(--muted);
    font-size: 13px;
}

.message-body {
    white-space: normal;
    line-height: 1.55;
}

.reply-box {
    border-top: 1px solid var(--line);
    padding-top: 20px;
}

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

.detail-list dt {
    color: var(--muted);
    font-weight: 800;
}

.detail-list dd {
    margin: 0;
    min-width: 0;
    overflow-wrap: anywhere;
}

.grid-details {
    grid-template-columns: 150px minmax(0, 1fr) 150px minmax(0, 1fr);
}

.wide-details {
    grid-template-columns: 160px minmax(0, 1fr);
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.small-mono {
    font-size: 12px;
}

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

.inline-form {
    display: contents;
}

.switch-line,
.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    color: var(--text);
}

.switch-line input,
.checkbox-label input {
    width: auto;
    margin: 0;
}

.install-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
}

code {
    background: #eef2f7;
    border-radius: 7px;
    padding: 2px 6px;
}

@media (max-width: 1100px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ticket-layout,
    .two-column-layout,
    .grid-details {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 760px) {
    .app-shell {
        display: block;
    }

    .sidebar {
        width: 100%;
        min-height: auto;
        position: relative;
    }

    .main {
        padding: 18px;
    }

    .topbar,
    .card-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .stats-grid,
    .form-grid.two-cols,
    .form-row,
    .filter-bar {
        grid-template-columns: 1fr;
    }

    .form-actions {
        justify-content: stretch;
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}
