:root {
    color-scheme: light;
    --font-sans: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    --font-size-body: 14px;
    --font-size-control: 13px;
    --font-size-meta: 12px;
    --font-size-micro: 11px;
    --space-1: 4px;
    --space-2: 6px;
    --space-3: 8px;
    --space-4: 12px;
    --space-5: 16px;
    --space-6: 20px;
    --canvas: #f7f8fa;
    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --surface-hover: #f1f5f9;
    --navy: #1a2744;
    --navy-soft: #263758;
    --text: #2d3748;
    --text-strong: #152238;
    --muted: #64748b;
    --muted-light: #94a3b8;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --brand: #21538f;
    --brand-hover: #183f70;
    --brand-soft: #eaf2fb;
    --success: #167653;
    --success-soft: #e8f7f0;
    --warning: #9a5b08;
    --warning-soft: #fff7e2;
    --danger: #b4232f;
    --danger-soft: #fff0f1;
    --info: #176b87;
    --info-soft: #e9f7fb;
    --shadow: 0 1px 2px rgb(15 23 42 / 5%);
    --shadow-raised: 0 8px 24px rgb(15 23 42 / 12%);
    --radius-sm: 5px;
    --radius: 7px;
    --radius-lg: 10px;
    --sidebar-width: 220px;
    --topbar-height: 52px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    min-width: 0;
    background: var(--canvas);
    overflow-x: clip;
    -webkit-text-size-adjust: 100%;
}

body {
    min-width: 0;
    min-height: 100vh;
    margin: 0;
    background: var(--canvas);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: var(--font-size-body);
    font-weight: 400;
    line-height: 1.45;
    overflow-wrap: break-word;
}

body.nav-open {
    overflow: hidden;
}

button,
input,
select,
textarea {
    margin: 0;
    color: inherit;
    font: inherit;
}

button,
select {
    text-transform: none;
}

button,
[type="button"],
[type="submit"] {
    -webkit-appearance: button;
}

img,
svg {
    display: block;
    max-width: 100%;
}

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

a:hover {
    color: var(--brand-hover);
}

p,
ul,
ol,
dl {
    margin-block: 0 var(--space-4);
}

h1,
h2,
h3,
h4 {
    margin: 0;
    color: var(--text-strong);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

h1 {
    font-size: clamp(24px, 2vw, 27px);
}

h2 {
    font-size: 20px;
}

h3 {
    font-size: 17px;
}

h4 {
    font-size: 14px;
}

hr {
    height: 1px;
    margin: var(--space-5) 0;
    border: 0;
    background: var(--border);
}

:focus-visible {
    outline: 3px solid rgb(33 83 143 / 24%);
    outline-offset: 2px;
}

[hidden] {
    display: none !important;
}

.skip-link {
    position: fixed;
    z-index: 1000;
    top: var(--space-3);
    left: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: var(--shadow-raised);
    transform: translateY(-160%);
}

.skip-link:focus {
    transform: translateY(0);
}

.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    border: 0 !important;
    margin: -1px !important;
    clip: rect(0, 0, 0, 0) !important;
    overflow: hidden !important;
    white-space: nowrap !important;
}

.icon {
    width: 17px;
    height: 17px;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.icon-sm {
    width: 14px;
    height: 14px;
}

.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    z-index: 40;
    top: 0;
    display: flex;
    min-height: 100vh;
    max-height: 100vh;
    flex-direction: column;
    overflow-y: auto;
    background: var(--navy);
    color: #d9e2f0;
}

.sidebar-brand {
    display: flex;
    min-height: var(--topbar-height);
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid rgb(255 255 255 / 9%);
    color: #fff;
}

.sidebar-brand:hover {
    color: #fff;
}

.sidebar-logo {
    width: 29px;
    height: 29px;
    flex: 0 0 auto;
}

.sidebar-brand-text {
    min-width: 0;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.1;
}

.sidebar-brand-text small {
    display: block;
    margin-top: 2px;
    color: #8fa3c2;
    font-size: var(--font-size-micro);
    font-weight: 500;
    letter-spacing: 0;
}

.sidebar-nav {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 2px;
    padding: var(--space-4) var(--space-3);
}

.nav-label {
    padding: var(--space-4) var(--space-3) var(--space-1);
    color: #7890b2;
    font-size: var(--font-size-micro);
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.nav-link {
    display: flex;
    min-height: 34px;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    color: #c5d1e2;
    font-size: var(--font-size-control);
    font-weight: 550;
    transition: background-color 140ms ease, color 140ms ease;
}

.nav-link:hover {
    background: rgb(255 255 255 / 7%);
    color: #fff;
}

.nav-link.is-active {
    background: rgb(108 167 232 / 18%);
    color: #fff;
}

.sidebar-footer {
    padding: var(--space-3);
    border-top: 1px solid rgb(255 255 255 / 9%);
}

.sidebar-user {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr);
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2);
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: background-color 140ms ease;
}

.sidebar-user:hover {
    background: rgb(255 255 255 / 7%);
}

.sidebar-user-name {
    display: block;
    overflow: hidden;
    color: #fff;
    font-size: var(--font-size-control);
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-user-role {
    display: block;
    color: #8fa3c2;
    font-size: var(--font-size-micro);
}

.avatar {
    display: inline-flex;
    width: 30px;
    height: 30px;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--brand);
    font-size: var(--font-size-micro);
    font-weight: 800;
    text-transform: uppercase;
}

.sidebar .avatar {
    background: rgb(255 255 255 / 12%);
    color: #fff;
}

.sidebar-overlay {
    position: fixed;
    z-index: 35;
    inset: 0;
    display: none;
    border: 0;
    background: rgb(15 23 42 / 48%);
}

.app-main {
    min-width: 0;
}

.topbar {
    position: sticky;
    z-index: 30;
    top: 0;
    display: flex;
    min-height: var(--topbar-height);
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-5);
    border-bottom: 1px solid var(--border);
    background: rgb(255 255 255 / 96%);
    backdrop-filter: blur(8px);
}

.topbar-leading,
.topbar-actions,
.cluster {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: var(--space-3);
}

.topbar-title {
    overflow: hidden;
    color: var(--text-strong);
    font-size: 14px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notification-button {
    position: relative;
}

.notification-button.has-unread {
    color: var(--brand);
}

.notification-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    display: inline-flex;
    min-width: 16px;
    height: 16px;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--surface);
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    line-height: 1;
}

.nav-toggle {
    display: none;
}

.icon-btn.nav-toggle {
    display: none;
}

.main-content {
    width: 100%;
    min-width: 0;
    padding: var(--space-5);
}

.page-stack,
.stack {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: var(--space-4);
}

.stack-tight {
    gap: var(--space-3);
}

.page-header {
    display: flex;
    min-width: 0;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
}

.page-heading {
    min-width: 0;
}

.page-heading p,
.section-heading p {
    margin: var(--space-1) 0 0;
    color: var(--muted);
    font-size: var(--font-size-control);
}

.page-actions {
    display: flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: var(--space-3);
}

.section-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
}

.section-title {
    font-size: 15px;
    font-weight: 700;
}

.card {
    min-width: 0;
    max-width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header,
.card-footer {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-4);
}

.card-header {
    border-bottom: 1px solid var(--border);
}

.card-footer {
    border-top: 1px solid var(--border);
}

.card-body {
    min-width: 0;
    padding: var(--space-4);
}

.card-body-lg {
    padding: var(--space-5);
}

.notification-list {
    display: flex;
    flex-direction: column;
}

.notification-item {
    display: grid;
    grid-template-columns: 8px minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.notification-item:last-child {
    border-bottom: 0;
}

.notification-item.is-unread {
    background: color-mix(in srgb, var(--brand-soft) 42%, var(--surface));
}

.notification-mark {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--border-strong);
}

.notification-item.is-unread .notification-mark {
    background: var(--brand);
}

.notification-copy {
    min-width: 0;
}

.notification-copy h3 {
    color: var(--text-strong);
    font-size: var(--font-size-control);
    font-weight: 700;
}

.notification-copy p {
    margin: 2px 0 0;
    color: var(--text);
    font-size: var(--font-size-meta);
    line-height: 1.45;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-4);
}

.stat-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 36px;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
}

.stat-label {
    color: var(--muted);
    font-size: var(--font-size-meta);
    font-weight: 600;
}

.stat-value {
    margin-top: 1px;
    color: var(--text-strong);
    font-size: 23px;
    font-weight: 750;
    letter-spacing: -0.03em;
    line-height: 1.15;
}

.stat-detail {
    margin-top: 2px;
    color: var(--muted);
    font-size: var(--font-size-micro);
}

.stat-icon {
    display: inline-flex;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    background: var(--brand-soft);
    color: var(--brand);
}

.content-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(250px, 0.34fr);
    gap: var(--space-4);
    align-items: start;
}

.ticket-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: var(--space-4);
    align-items: start;
}

.grid-2,
.grid-3,
.form-grid {
    display: grid;
    gap: var(--space-4);
}

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

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

.align-start {
    align-items: start;
}

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

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

.field {
    min-width: 0;
}

.field label,
.field-label {
    display: block;
    margin-bottom: var(--space-1);
    color: var(--text);
    font-size: var(--font-size-meta);
    font-weight: 700;
}

.field-required::after {
    margin-left: 2px;
    color: var(--danger);
    content: "*";
}

.input,
.select,
.textarea {
    display: block;
    width: 100%;
    min-width: 0;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-strong);
    font-size: var(--font-size-control);
    transition: border-color 140ms ease, box-shadow 140ms ease;
}

.input,
.select {
    height: 35px;
    padding: 0 10px;
}

.select {
    padding-right: 30px;
}

.select[multiple] {
    height: auto;
    min-height: 112px;
    padding: var(--space-2) var(--space-3);
}

.select[multiple] option {
    padding: var(--space-1) var(--space-2);
}

.textarea {
    min-height: 96px;
    padding: var(--space-3) 10px;
    line-height: 1.45;
    resize: vertical;
}

.textarea-lg {
    min-height: 180px;
}

.input:hover,
.select:hover,
.textarea:hover {
    border-color: #aebdce;
}

.input:focus,
.select:focus,
.textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgb(33 83 143 / 12%);
    outline: none;
}

.input[aria-invalid="true"],
.select[aria-invalid="true"],
.textarea[aria-invalid="true"] {
    border-color: var(--danger);
}

.field-hint,
.field-error,
.meta {
    margin-top: var(--space-1);
    color: var(--muted);
    font-size: var(--font-size-micro);
    line-height: 1.4;
}

.field-error {
    color: var(--danger);
    font-weight: 600;
}

.check-field {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    font-size: var(--font-size-control);
}

.check-field input {
    width: 16px;
    height: 16px;
    margin-top: 2px;
    accent-color: var(--brand);
}

.check-row {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    padding: var(--space-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-muted);
    color: var(--text);
    cursor: pointer;
    font-size: var(--font-size-control);
}

.check-row input {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
    margin-top: 2px;
    accent-color: var(--brand);
}

.check-row strong,
.check-row small {
    display: block;
}

.check-row small {
    margin-top: 2px;
    color: var(--muted);
    font-size: var(--font-size-micro);
    font-weight: 500;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-3);
    padding-top: var(--space-3);
    border-top: 1px solid var(--border);
}

.btn,
.icon-btn {
    display: inline-flex;
    min-width: 0;
    height: 35px;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--font-size-control);
    font-weight: 700;
    line-height: 1;
    text-align: center;
    transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, opacity 140ms ease;
    white-space: nowrap;
}

.btn {
    padding: 0 var(--space-4);
}

.icon-btn {
    width: 35px;
    padding: 0;
}

.btn-primary {
    border-color: var(--brand);
    background: var(--brand);
    color: #fff;
}

.btn-primary:hover {
    border-color: var(--brand-hover);
    background: var(--brand-hover);
    color: #fff;
}

.btn-secondary,
.icon-btn {
    border-color: var(--border-strong);
    background: var(--surface);
    color: var(--text);
}

.btn-secondary:hover,
.icon-btn:hover {
    border-color: #aebdce;
    background: var(--surface-hover);
    color: var(--text-strong);
}

.btn-quiet {
    border-color: transparent;
    background: transparent;
    color: var(--muted);
}

.btn-quiet:hover {
    background: var(--surface-hover);
    color: var(--text-strong);
}

.btn-danger {
    border-color: #e7b9be;
    background: var(--surface);
    color: var(--danger);
}

.btn-danger:hover {
    background: var(--danger-soft);
    color: #8f1721;
}

.btn-sm {
    height: 30px;
    padding-inline: var(--space-3);
    font-size: var(--font-size-meta);
}

.btn:disabled,
.icon-btn:disabled,
.is-disabled {
    cursor: not-allowed;
    opacity: 0.52;
}

.is-busy {
    pointer-events: none;
}

.is-busy::before {
    width: 12px;
    height: 12px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 650ms linear infinite;
    content: "";
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-size: var(--font-size-control);
}

.alert-success {
    border-color: #b9e4d2;
    background: var(--success-soft);
    color: #0e6446;
}

.alert-warning {
    border-color: #eed89a;
    background: var(--warning-soft);
    color: #7b4702;
}

.alert-danger {
    border-color: #efc7cb;
    background: var(--danger-soft);
    color: #901923;
}

.alert-info {
    border-color: #b6dce8;
    background: var(--info-soft);
    color: #125e76;
}

.badge,
.status-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.badge {
    max-width: 100%;
    min-height: 22px;
    padding: 2px var(--space-3);
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: var(--font-size-micro);
    font-weight: 750;
    line-height: 1.25;
    white-space: nowrap;
}

.badge-neutral {
    border-color: var(--border);
    background: var(--surface-muted);
    color: var(--muted);
}

.badge-brand,
.badge-primary,
.badge-open,
.badge-new {
    border-color: #c8dcef;
    background: var(--brand-soft);
    color: var(--brand);
}

.badge-success,
.badge-resolved,
.badge-closed,
.badge-active,
.badge-published {
    border-color: #bfe7d5;
    background: var(--success-soft);
    color: var(--success);
}

.badge-warning,
.badge-pending,
.badge-waiting,
.badge-high {
    border-color: #f0d99b;
    background: var(--warning-soft);
    color: var(--warning);
}

.badge-danger,
.badge-urgent,
.badge-inactive,
.badge-failed {
    border-color: #efc7cb;
    background: var(--danger-soft);
    color: var(--danger);
}

.badge-info,
.badge-in-progress {
    border-color: #b9deea;
    background: var(--info-soft);
    color: var(--info);
}

.status-dot {
    width: 8px;
    height: 8px;
    margin-right: var(--space-2);
    border-radius: 50%;
    background: var(--muted-light);
}

.status-dot.is-ok { background: var(--success); }
.status-dot.is-warning { background: #d3921d; }
.status-dot.is-error { background: var(--danger); }

.table-wrap {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-control);
}

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

.table th {
    background: var(--surface-muted);
    color: var(--muted);
    font-size: var(--font-size-micro);
    font-weight: 750;
    letter-spacing: 0.025em;
    text-transform: uppercase;
    white-space: nowrap;
}

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

.table tbody tr:hover {
    background: #fbfcfd;
}

.table-title {
    display: block;
    max-width: 440px;
    overflow: hidden;
    color: var(--text-strong);
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table-subtitle {
    display: block;
    max-width: 440px;
    margin-top: 1px;
    overflow: hidden;
    color: var(--muted);
    font-size: var(--font-size-micro);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
    white-space: nowrap;
}

.table-mobile-detail,
.user-action-icon {
    display: none;
}

.text-right {
    text-align: right !important;
}

.filters {
    display: grid;
    grid-template-columns: minmax(190px, 1.4fr) repeat(4, minmax(130px, 0.7fr)) auto;
    gap: var(--space-3);
    align-items: end;
}

.filters.filters-customer {
    grid-template-columns: minmax(220px, 1.5fr) repeat(2, minmax(140px, 0.7fr)) auto;
}

.filters.filters-knowledge {
    grid-template-columns: minmax(220px, 1.5fr) minmax(150px, 0.7fr) minmax(130px, 0.6fr) auto;
}

.filters.filters-users {
    grid-template-columns: minmax(220px, 1.5fr) minmax(150px, 0.7fr) minmax(130px, 0.6fr) auto;
}

.search-field {
    position: relative;
}

.search-field .icon {
    position: absolute;
    top: 50%;
    left: 10px;
    color: var(--muted);
    pointer-events: none;
    transform: translateY(-50%);
}

.search-field .input {
    padding-left: 34px;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
}

.pagination-info {
    color: var(--muted);
    font-size: var(--font-size-meta);
}

.pagination-links {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.page-link {
    display: inline-flex;
    min-width: 30px;
    height: 30px;
    align-items: center;
    justify-content: center;
    padding: 0 var(--space-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: var(--font-size-meta);
    font-weight: 650;
}

.page-link:hover,
.page-link.is-current {
    border-color: var(--brand);
    background: var(--brand-soft);
    color: var(--brand);
}

.page-link.is-current {
    pointer-events: none;
}

.page-link.is-disabled {
    pointer-events: none;
}

.empty-state {
    display: flex;
    min-height: 170px;
    align-items: center;
    justify-content: center;
    padding: var(--space-6);
    text-align: center;
}

.empty-state-inner {
    max-width: 420px;
}

.empty-icon {
    display: inline-flex;
    width: 42px;
    height: 42px;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-3);
    border-radius: 50%;
    background: var(--surface-hover);
    color: var(--muted);
}

.empty-state h3 {
    font-size: 15px;
}

.empty-state p {
    margin: var(--space-1) 0 var(--space-4);
    color: var(--muted);
    font-size: var(--font-size-control);
}

.definition-list {
    display: grid;
    grid-template-columns: minmax(90px, 0.42fr) minmax(0, 1fr);
    gap: var(--space-3) var(--space-4);
    margin: 0;
}

.definition-list dt {
    color: var(--muted);
    font-size: var(--font-size-meta);
    font-weight: 600;
}

.definition-list dd {
    min-width: 0;
    margin: 0;
    color: var(--text-strong);
    font-size: var(--font-size-control);
    font-weight: 600;
    text-align: right;
}

.conversation {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.message {
    min-width: 0;
    padding: var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.message.is-internal {
    border-color: #e9d694;
    background: #fffaf0;
}

.message-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.message-author {
    color: var(--text-strong);
    font-size: var(--font-size-control);
    font-weight: 700;
}

.message-time {
    color: var(--muted);
    font-size: var(--font-size-micro);
    white-space: nowrap;
}

.message-body,
.prose {
    min-width: 0;
    color: var(--text);
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.message-body {
    white-space: pre-wrap;
}

.ticket-description {
    border-left: 3px solid var(--brand);
    padding-left: var(--space-4);
    color: var(--text-strong);
    line-height: 1.65;
}

.prose > :last-child {
    margin-bottom: 0;
}

.prose pre,
.prose code {
    max-width: 100%;
    border-radius: var(--radius-sm);
    background: #eef2f6;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 12px;
}

.prose code {
    padding: 2px var(--space-1);
}

.prose pre {
    padding: var(--space-3);
    overflow-x: auto;
}

.tabs {
    display: flex;
    gap: var(--space-1);
    padding: var(--space-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-muted);
}

.tab {
    flex: 1;
    padding: var(--space-2) var(--space-3);
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: var(--font-size-meta);
    font-weight: 700;
}

.tab[aria-selected="true"],
.tab.is-active {
    background: var(--surface);
    box-shadow: var(--shadow);
    color: var(--text-strong);
}

.settings-tabs {
    justify-content: flex-start;
    overflow-x: auto;
}

.settings-tabs .tab {
    flex: 0 0 auto;
    white-space: nowrap;
}

.ai-panel {
    border-color: #cdddf1;
    background: linear-gradient(180deg, #fbfdff 0%, #f6f9fd 100%);
}

.ai-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
}

.ai-actions .btn {
    justify-content: flex-start;
}

.ai-output {
    min-height: 100px;
    padding: var(--space-3);
    border: 1px solid #cdddf1;
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: var(--font-size-control);
    line-height: 1.55;
    white-space: pre-wrap;
}

.activity-list,
.article-list,
.integration-list {
    display: flex;
    flex-direction: column;
}

.activity-item,
.article-item,
.integration-item {
    display: flex;
    min-width: 0;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
}

.activity-item:last-child,
.article-item:last-child,
.integration-item:last-child {
    border-bottom: 0;
}

.activity-content,
.article-content,
.integration-content {
    min-width: 0;
    flex: 1;
}

.activity-title,
.article-title,
.integration-title {
    color: var(--text-strong);
    font-size: var(--font-size-control);
    font-weight: 700;
}

.article-title:hover {
    color: var(--brand);
}

.activity-meta,
.article-meta,
.integration-meta {
    margin-top: 2px;
    color: var(--muted);
    font-size: var(--font-size-micro);
}

.integration-item {
    align-items: center;
}

.integration-icon {
    display: inline-flex;
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    background: var(--surface-hover);
    color: var(--brand);
}

.metric-bar {
    display: grid;
    grid-template-columns: minmax(90px, 0.35fr) minmax(120px, 1fr) 50px;
    align-items: center;
    gap: var(--space-3);
    font-size: var(--font-size-control);
}

.metric-track {
    height: 7px;
    border-radius: 999px;
    background: var(--surface-hover);
    overflow: hidden;
}

.metric-fill {
    width: calc(var(--value, 0) * 1%);
    max-width: 100%;
    height: 100%;
    border-radius: inherit;
    background: var(--brand);
}

.metric-value {
    color: var(--muted);
    font-size: var(--font-size-meta);
    text-align: right;
}

.progress {
    width: 100%;
    height: 7px;
    border: 0;
    border-radius: 999px;
    background: var(--surface-hover);
    overflow: hidden;
}

.progress::-webkit-progress-bar {
    border-radius: 999px;
    background: var(--surface-hover);
}

.progress::-webkit-progress-value {
    border-radius: 999px;
    background: var(--brand);
}

.progress::-moz-progress-bar {
    border-radius: 999px;
    background: var(--brand);
}

.auth-page {
    display: grid;
    min-height: 100vh;
    grid-template-columns: minmax(0, 1fr) minmax(390px, 0.68fr);
    background: var(--surface);
}

.auth-brand-panel {
    position: relative;
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: center;
    padding: clamp(32px, 7vw, 100px);
    overflow: hidden;
    background: var(--navy);
    color: #fff;
}

.auth-brand-panel::before,
.auth-brand-panel::after {
    position: absolute;
    border: 1px solid rgb(255 255 255 / 8%);
    border-radius: 50%;
    content: "";
}

.auth-brand-panel::before {
    width: 460px;
    height: 460px;
    right: -170px;
    bottom: -240px;
}

.auth-brand-panel::after {
    width: 280px;
    height: 280px;
    top: -120px;
    left: -100px;
}

.auth-brand-content {
    position: relative;
    z-index: 1;
    width: min(100%, 520px);
}

.auth-logo {
    width: 42px;
    height: 42px;
    margin-bottom: var(--space-6);
}

.auth-brand-content h1 {
    max-width: 460px;
    color: #fff;
    font-size: clamp(29px, 4vw, 42px);
}

.auth-brand-content p {
    max-width: 460px;
    margin-top: var(--space-4);
    color: #aebdd3;
    font-size: 15px;
}

.auth-form-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-6);
}

.auth-card {
    width: min(100%, 390px);
}

.auth-card-header {
    margin-bottom: var(--space-6);
}

.auth-card-header p {
    margin: var(--space-2) 0 0;
    color: var(--muted);
    font-size: var(--font-size-control);
}

.auth-card .btn-primary {
    width: 100%;
}

.auth-footer {
    margin-top: var(--space-5);
    color: var(--muted);
    font-size: var(--font-size-micro);
    text-align: center;
}

.error-page {
    display: flex;
    min-height: calc(100vh - var(--topbar-height) - 32px);
    align-items: center;
    justify-content: center;
    padding: var(--space-6);
    text-align: center;
}

.error-content {
    max-width: 520px;
}

.error-code {
    color: var(--brand);
    font-size: var(--font-size-meta);
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.error-content h1 {
    margin-top: var(--space-2);
}

.error-content p {
    margin: var(--space-3) 0 var(--space-5);
    color: var(--muted);
}

.toast-region {
    position: fixed;
    z-index: 100;
    top: var(--space-4);
    right: var(--space-4);
    display: flex;
    width: min(360px, calc(100vw - 24px));
    flex-direction: column;
    gap: var(--space-3);
    pointer-events: none;
}

.toast {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr) 24px;
    align-items: start;
    gap: var(--space-3);
    padding: var(--space-3);
    border: 1px solid var(--border);
    border-left: 3px solid var(--brand);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-raised);
    color: var(--text);
    font-size: var(--font-size-control);
    pointer-events: auto;
    animation: toast-in 180ms ease-out;
}

.toast.is-success { border-left-color: var(--success); }
.toast.is-warning { border-left-color: var(--warning); }
.toast.is-error { border-left-color: var(--danger); }

.toast-close {
    display: inline-flex;
    width: 24px;
    height: 24px;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 17px;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(-6px); }
}

.dialog {
    width: min(430px, calc(100vw - 24px));
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-raised);
    color: var(--text);
}

.dialog::backdrop {
    background: rgb(15 23 42 / 50%);
    backdrop-filter: blur(2px);
}

.dialog-body {
    padding: var(--space-5);
}

.dialog-body p {
    margin: var(--space-2) 0 0;
    color: var(--muted);
    font-size: var(--font-size-control);
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border);
    background: var(--surface-muted);
}

.divider-label {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    color: var(--muted);
    font-size: var(--font-size-micro);
}

.divider-label::before,
.divider-label::after {
    height: 1px;
    flex: 1;
    background: var(--border);
    content: "";
}

.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted { color: var(--muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-sm { font-size: var(--font-size-control); }
.text-meta { font-size: var(--font-size-meta); }
.text-micro { font-size: var(--font-size-micro); }
.font-semibold { font-weight: 700; }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mb-0 { margin-bottom: 0; }
.w-full { width: 100%; }
.justify-between { justify-content: space-between; }

.cluster {
    flex-wrap: wrap;
}

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

    .filters,
    .filters.filters-customer {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filters.filters-knowledge,
    .filters.filters-users {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filters .search-field {
        grid-column: 1 / -1;
    }

    .filters .filter-actions {
        justify-self: end;
    }
}

@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: minmax(0, 1fr);
    }

    .sidebar {
        position: fixed;
        left: 0;
        width: min(var(--sidebar-width), calc(100vw - 52px));
        transform: translateX(-105%);
        transition: transform 180ms ease;
    }

    .nav-open .sidebar {
        transform: translateX(0);
    }

    .nav-open .sidebar-overlay {
        display: block;
    }

    .nav-toggle,
    .icon-btn.nav-toggle {
        display: inline-flex;
    }

    .content-grid,
    .ticket-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .ticket-sidebar {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: var(--space-4);
    }

    .table-tickets,
    .table-users {
        width: 100%;
        min-width: 0;
        table-layout: fixed;
    }

    .table-tickets th,
    .table-tickets td,
    .table-users th,
    .table-users td {
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .table-tickets .col-ticket { width: 38%; }
    .table-tickets .col-status { width: 14%; }
    .table-tickets .col-priority { width: 12%; }
    .table-tickets .col-requester,
    .table-tickets .col-assignee { display: none; }
    .table-tickets .col-updated { width: 23%; }
    .table-tickets .col-action { width: 13%; }
}

@media (max-width: 760px) {
    :root {
        --topbar-height: 52px;
    }

    .topbar,
    .main-content {
        padding-inline: var(--space-4);
    }

    .page-header,
    .section-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .page-actions {
        justify-content: flex-start;
    }

    .grid-2,
    .grid-3,
    .form-grid,
    .ticket-sidebar {
        grid-template-columns: minmax(0, 1fr);
    }

    .span-2 {
        grid-column: auto;
    }

    .btn,
    .icon-btn,
    .input,
    .select {
        min-height: 40px;
    }

    .icon-btn {
        width: 40px;
    }

    .table-tickets,
    .table-users {
        min-width: 0;
    }

    .auth-page {
        grid-template-columns: minmax(0, 1fr);
    }

    .auth-brand-panel {
        display: none;
    }

    .auth-form-panel {
        padding: var(--space-5);
    }
}

@media (max-width: 560px) {
    .main-content {
        padding: var(--space-4) var(--space-3);
    }

    .topbar {
        padding-inline: var(--space-3);
    }

    .topbar-title {
        max-width: 170px;
    }

    .topbar-create {
        display: none;
    }

    .table-tickets .col-ticket { width: 68%; }
    .table-tickets .col-status { width: 32%; }
    .table-tickets .col-priority,
    .table-tickets .col-updated,
    .table-tickets .col-action { display: none; }

    .table-tickets .table-title,
    .table-tickets .table-subtitle {
        max-width: 100%;
    }

    .table-tickets .table-title {
        overflow: visible;
        line-height: 1.35;
        overflow-wrap: anywhere;
        text-overflow: clip;
        white-space: normal;
    }

    .table-tickets .badge {
        display: flex;
        width: 100%;
        overflow: visible;
        overflow-wrap: anywhere;
        text-align: center;
        text-overflow: clip;
        white-space: normal;
    }

    .table-users .col-user { width: 50%; }
    .table-users .col-user-status { width: 22%; }
    .table-users .col-user-actions { width: 28%; }
    .table-users .col-role,
    .table-users .col-last-login { display: none; }

    .table-mobile-detail {
        display: block;
        margin-top: 2px;
        color: var(--muted);
        font-size: var(--font-size-micro);
        line-height: 1.35;
    }

    .table-users .table-actions {
        align-items: center;
        flex-direction: row;
        gap: var(--space-1);
    }

    .table-users .table-actions .user-action-btn {
        width: 40px;
        padding: 0;
    }

    .table-api-tokens,
    .table-api-tokens tbody {
        display: block;
        width: 100%;
        min-width: 0;
    }

    .table-api-tokens thead {
        display: none;
    }

    .table-api-tokens tr {
        display: grid;
        width: 100%;
        min-width: 0;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: var(--space-2) var(--space-3);
        padding: var(--space-3);
        border-bottom: 1px solid var(--border);
    }

    .table-api-tokens tbody tr:last-child {
        border-bottom: 0;
    }

    .table-api-tokens td {
        min-width: 0;
        padding: 0;
        border: 0;
    }

    .table-api-tokens .col-api-name {
        grid-column: 1;
        grid-row: 1;
    }

    .table-api-tokens .col-api-name .table-title,
    .table-api-tokens .col-api-name .table-subtitle {
        max-width: 100%;
        overflow-wrap: anywhere;
        white-space: normal;
    }

    .table-api-tokens .col-api-status {
        grid-column: 2;
        grid-row: 1;
        align-self: start;
    }

    .table-api-tokens .col-api-scopes,
    .table-api-tokens .col-api-expires,
    .table-api-tokens .col-api-last-used {
        display: grid;
        min-width: 0;
        grid-column: 1 / -1;
        grid-template-columns: 96px minmax(0, 1fr);
        gap: var(--space-2);
        overflow-wrap: anywhere;
        white-space: normal;
    }

    .table-api-tokens [data-label]::before {
        color: var(--muted);
        content: attr(data-label);
        font-size: var(--font-size-micro);
        font-weight: 650;
    }

    .table-api-tokens .col-api-action {
        grid-column: 1 / -1;
    }

    .table-api-tokens .col-api-action form {
        display: flex;
        justify-content: flex-start;
    }

    .table-api-tokens .api-token-row-revoked .col-api-action {
        display: none;
    }

    .user-action-icon {
        display: block;
    }

    .user-action-label {
        display: none;
    }

    .article-item {
        display: grid;
        grid-template-columns: 36px minmax(0, 1fr);
        align-items: start;
    }

    .article-item .article-content,
    .article-item .article-actions {
        grid-column: 2;
    }

    .article-item .article-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .stat-grid,
    .filters,
    .filters.filters-customer {
        grid-template-columns: minmax(0, 1fr);
    }

    .filters.filters-knowledge,
    .filters.filters-users {
        grid-template-columns: minmax(0, 1fr);
    }

    .filters .search-field {
        grid-column: auto;
    }

    .filters .filter-actions {
        display: grid;
        width: 100%;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filters .filter-actions .btn {
        width: 100%;
    }

    .stat-card {
        padding: var(--space-3) var(--space-4);
    }

    .stat-value {
        font-size: 21px;
    }

    .card-header,
    .card-footer,
    .card-body,
    .card-body-lg {
        padding: var(--space-3);
    }

    .notification-item {
        grid-template-columns: 7px minmax(0, 1fr);
        padding: var(--space-3);
    }

    .notification-item form {
        grid-column: 2;
    }

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

    .form-actions .btn {
        width: 100%;
    }

    .ai-actions {
        grid-template-columns: minmax(0, 1fr);
    }

    .pagination {
        align-items: flex-start;
        flex-direction: column;
    }

    .toast-region {
        top: var(--space-3);
        right: var(--space-3);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media print {
    .sidebar,
    .topbar,
    .page-actions,
    .filters,
    .btn,
    .toast-region {
        display: none !important;
    }

    .app-shell {
        display: block;
    }

    .main-content {
        padding: 0;
    }

    .card {
        break-inside: avoid;
        box-shadow: none;
    }
}
