:root {
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --text: #0f172a;
    --text-soft: #334155;
    --text-muted: #64748b;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: #eef2ff;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --danger-soft: #fef2f2;
    --success: #15803d;
    --success-soft: #dcfce7;
    --warning: #b45309;
    --warning-soft: #fef3c7;
    --pending-row: #fffbeb;
    --sidebar: #0f172a;
    --sidebar-hover: rgba(255, 255, 255, .06);
    --sidebar-text: #cbd5e1;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .06);
    --shadow-lg: 0 24px 48px rgba(15, 23, 42, .22);
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

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

a:hover {
    text-decoration: underline;
}

h1, h2, p {
    margin: 0;
}

svg {
    flex-shrink: 0;
}

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

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

.key {
    font-family: var(--mono);
    font-size: 12.5px;
    color: var(--text);
    overflow-wrap: break-word;
}

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

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    width: 250px;
    height: 100vh;
    flex-shrink: 0;
    padding: 20px 14px;
    background: var(--sidebar);
    color: var(--sidebar-text);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 10px 24px;
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -.01em;
}

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

.brand-mark {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    font-size: 13px;
    font-weight: 800;
}

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

.nav-label {
    padding: 0 12px 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #64748b;
}

.nav-label:not(:first-child) {
    padding-top: 16px;
}

.nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-weight: 500;
}

.nav a:hover {
    background: var(--sidebar-hover);
    color: #fff;
    text-decoration: none;
}

.nav a.active {
    background: rgba(99, 102, 241, .22);
    color: #fff;
}

.nav svg {
    width: 18px;
    height: 18px;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: auto;
    padding: 16px 8px 0;
    border-top: 1px solid rgba(255, 255, 255, .08);
}

.sidebar-user-meta {
    min-width: 0;
}

.sidebar-user-name {
    overflow: hidden;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-user-role {
    color: #94a3b8;
    font-size: 12px;
}

.sidebar-user form {
    margin-left: auto;
}

.avatar {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: 50%;
    background: #334155;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
}

.avatar-light {
    background: var(--primary-soft);
    color: var(--primary);
}

.icon-button {
    display: grid;
    place-items: center;
    padding: 7px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--sidebar-text);
    cursor: pointer;
}

.icon-button:hover {
    background: rgba(255, 255, 255, .1);
    color: #fff;
}

.icon-button svg {
    width: 18px;
    height: 18px;
}

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

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -.02em;
}

.page-subtitle {
    margin-top: 4px;
    color: var(--text-muted);
}

.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.card + .card {
    margin-top: 16px;
}

.card-body {
    padding: 20px;
}

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

.filters .field {
    flex: 1 1 180px;
    margin: 0;
}

.filters .field-grow {
    flex: 3 1 260px;
}

.filters-actions {
    display: flex;
    gap: 8px;
}

.field {
    margin-bottom: 18px;
}

.label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 600;
}

.input, .select, .textarea {
    display: block;
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background-color: #fff;
    color: var(--text);
    font: inherit;
    transition: border-color .15s, box-shadow .15s;
}

.input::placeholder, .textarea::placeholder {
    color: #94a3b8;
}

.select {
    appearance: none;
    padding-right: 34px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-position: right 12px center;
    background-repeat: no-repeat;
}

.textarea {
    min-height: 70px;
    resize: vertical;
}

.input:focus, .select:focus, .textarea:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .16);
}

.is-invalid, .is-invalid:focus {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, .12);
}

.required-mark {
    color: var(--danger);
}

.field-error {
    margin-top: 6px;
    color: var(--danger);
    font-size: 12.5px;
}

.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 0;
    color: var(--text-soft);
    font-weight: 500;
    cursor: pointer;
}

.checkbox input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--primary);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font: inherit;
    font-weight: 600;
    line-height: 1.25;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color .15s, border-color .15s, color .15s;
}

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

.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .3);
}

.btn svg {
    width: 16px;
    height: 16px;
}

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

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

.btn-secondary {
    border-color: var(--border-strong);
    background: #fff;
    color: var(--text-soft);
}

.btn-secondary:hover {
    background: var(--surface-muted);
    color: var(--text);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}

.btn-ghost:hover {
    background: #eef2f7;
    color: var(--text);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

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

.btn-danger-soft {
    background: transparent;
    color: var(--danger);
}

.btn-danger-soft:hover {
    background: var(--danger-soft);
}

.btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.btn-sm {
    padding: 6px 10px;
    font-size: 13px;
}

.btn-block {
    width: 100%;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}

.badge-success {
    background: var(--success-soft);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-soft);
    color: var(--warning);
}

.badge-danger {
    background: #fee2e2;
    color: var(--danger);
}

.badge-primary {
    background: var(--primary-soft);
    color: var(--primary);
}

.badge-neutral {
    background: #f1f5f9;
    color: #475569;
}

.alert {
    margin-bottom: 20px;
    padding: 12px 16px;
    border: 1px solid;
    border-radius: var(--radius-sm);
}

.alert ul {
    margin: 0;
    padding-left: 18px;
}

.alert-success {
    border-color: #bbf7d0;
    background: #f0fdf4;
    color: #166534;
}

.alert-danger {
    border-color: #fecaca;
    background: var(--danger-soft);
    color: #991b1b;
}

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

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

.table th {
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-muted);
    color: var(--text-muted);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .05em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}

.table th:first-child {
    border-top-left-radius: var(--radius);
}

.table th:last-child {
    border-top-right-radius: var(--radius);
}

.table td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

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

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

.table tbody tr.is-pending {
    background: var(--pending-row);
}

.cell-text {
    min-width: 150px;
    max-width: 280px;
    color: var(--text-soft);
    overflow-wrap: break-word;
}

.cell-key {
    min-width: 190px;
}

.cell-index {
    min-width: 56px;
    color: var(--text-muted);
}

.sort-link {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    color: inherit;
    text-decoration: none;
}

.sort-link:hover, .sort-link.is-active {
    color: var(--text);
}

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

.doc-title {
    margin-bottom: 4px;
    font-size: 16px;
    font-weight: 700;
}

.doc-url-form {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.doc-url-form .field {
    flex: 1;
    min-width: 0;
    margin: 0;
}

.doc-url-form .btn {
    margin-top: 25px;
}

.doc-slot {
    padding: 14px 0;
    border-top: 1px solid var(--border);
}

.doc-slot-header {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
}

.doc-slot-title {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 14px;
    font-weight: 700;
}

.doc-slot .table-wrap {
    margin-top: 10px;
}

.doc-error {
    margin-bottom: 12px;
}

.doc-meta {
    margin-top: 12px;
    font-size: 13px;
}

@media (max-width: 560px) {
    .doc-section-header, .doc-url-form {
        flex-direction: column;
        align-items: stretch;
    }

    .doc-section-header .badge {
        align-self: flex-start;
    }

    .doc-url-form .btn {
        margin-top: 0;
    }
}

.log-source {
    margin-bottom: 6px;
}

.cell-changes {
    min-width: 300px;
}

.cell-nowrap {
    white-space: nowrap;
}

.cell-description {
    min-width: 240px;
    max-width: 420px;
}

.dialog-description {
    margin: 16px 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.nav-badge {
    margin-left: auto;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--warning-soft);
    color: var(--warning);
    font-size: 12px;
    font-weight: 600;
}

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

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

.detail-grid dt {
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 600;
}

.detail-grid dd {
    margin: 4px 0 0;
}

.section-title {
    margin: 0 0 16px;
    font-size: 16px;
    font-weight: 600;
}

.ticket-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.ticket-panel {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-muted);
}

.ticket-panel .dialog-description {
    margin: 0 0 12px;
}

.ticket-panel .dialog-description:last-child {
    margin-bottom: 0;
}

.timeline {
    position: relative;
    margin: 0;
    padding: 0;
    list-style: none;
}

.timeline::before {
    content: "";
    position: absolute;
    top: 20px;
    bottom: 20px;
    left: 16px;
    border-left: 2px solid var(--border);
}

.timeline-item {
    position: relative;
    display: flex;
    gap: 14px;
    padding: 10px 0;
}

.timeline-content {
    flex: 1;
    min-width: 0;
    padding-top: 7px;
}

.timeline-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    font-size: 14px;
}

.timeline-time {
    margin-left: auto;
    font-size: 12.5px;
}

.timeline-body {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
}

.timeline-bubble {
    margin-top: 8px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.timeline-bubble-appsy {
    background: var(--primary-soft);
    border-color: #c7d2fe;
}

.timeline-bubble .dialog-description {
    margin: 0 0 10px;
}

.timeline-bubble .dialog-description:last-child {
    margin-bottom: 0;
}

.reply-hint {
    margin: -8px 0 16px;
    font-size: 13px;
}

.reply-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
}

.reply-bar .field {
    margin-bottom: 0;
}

.reply-bar .btn {
    margin-bottom: 1px;
}

.thumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.thumb {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    display: block;
}

.actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
}

.actions form {
    margin: 0;
}

.pending-note {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    font-size: 12.5px;
}

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

.user-name {
    font-weight: 600;
}

.diff {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.diff + .diff {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed var(--border);
}

.diff-code {
    flex-shrink: 0;
    min-width: 30px;
    padding: 1px 6px;
    border-radius: 4px;
    background: #f1f5f9;
    color: #475569;
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    text-transform: uppercase;
}

.diff-values {
    min-width: 0;
    overflow-wrap: break-word;
}

.diff-old, .diff-new {
    padding: 1px 4px;
    border-radius: 4px;
}

.diff-old {
    background: var(--danger-soft);
    color: #b91c1c;
    text-decoration: line-through;
    text-decoration-color: rgba(185, 28, 28, .45);
}

.diff-new {
    background: #f0fdf4;
    color: #166534;
}

.diff-arrow {
    margin: 0 4px;
    color: var(--text-muted);
}

.empty {
    padding: 56px 16px;
    color: var(--text-muted);
    text-align: center;
}

.empty-title {
    margin-bottom: 4px;
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
}

.pagination-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.pagination a, .pagination span {
    display: grid;
    place-items: center;
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--text-soft);
    font-weight: 500;
}

.pagination a:hover {
    background: var(--surface-muted);
    text-decoration: none;
}

.pagination .active span {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

.pagination .disabled span {
    color: #cbd5e1;
}

.dialog {
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    padding: 0;
    border: 0;
    border-radius: 14px;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-lg);
}

.dialog-sm {
    width: min(440px, calc(100vw - 32px));
}

.dialog::backdrop {
    background: rgba(15, 23, 42, .55);
}

.dialog form {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 32px);
    margin: 0;
}

.dialog-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
}

.dialog-title {
    font-size: 17px;
    font-weight: 700;
}

.dialog-header .key {
    display: block;
    margin-top: 4px;
    color: var(--text-muted);
}

.dialog-body {
    padding: 22px;
    overflow-y: auto;
}

.dialog-body .field:last-child {
    margin-bottom: 0;
}

.dialog-text {
    margin-top: 8px;
    color: var(--text-muted);
}

.dialog-footer {
    display: flex;
    flex-direction: row-reverse;
    gap: 8px;
    padding: 14px 22px;
    border-top: 1px solid var(--border);
    border-radius: 0 0 14px 14px;
    background: var(--surface-muted);
}

.auth {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 32px 16px;
    background: radial-gradient(1200px 600px at 50% -10%, #e0e7ff, var(--bg) 70%);
}

.auth-card {
    width: 100%;
    max-width: 420px;
}

.auth-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 28px;
    color: var(--text);
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -.01em;
}

.auth .card-body {
    padding: 32px;
}

.auth-title {
    font-size: 21px;
    font-weight: 700;
    letter-spacing: -.02em;
}

.auth-subtitle {
    margin: 6px 0 26px;
    color: var(--text-muted);
}

.auth-footer {
    margin-top: 22px;
    color: var(--text-muted);
    text-align: center;
}

.select-sm {
    width: auto;
    min-width: 130px;
    padding: 5px 30px 5px 10px;
    font-size: 13px;
}

.dialog-lg {
    width: min(720px, calc(100vw - 32px));
}

.role-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.role-grid .card + .card {
    margin-top: 0;
}

.role-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.role-name {
    font-size: 16px;
    font-weight: 700;
}

.role-meta {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 13px;
}

.role-permissions {
    display: grid;
    gap: 8px;
    padding: 14px 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.role-permission {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--text-soft);
}

.role-actions {
    display: flex;
    gap: 8px;
    margin-top: 14px;
}

.role-note {
    margin-top: 14px;
    color: var(--text-muted);
    font-size: 13px;
}

.permission-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.permission-toolbar .label {
    margin: 0;
}

.permission-list {
    display: grid;
    gap: 8px;
}

.permission-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px 16px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.permission-module {
    font-weight: 600;
}

.permission-description {
    color: var(--text-muted);
    font-size: 12.5px;
}

.segmented {
    display: inline-flex;
    padding: 3px;
    border-radius: var(--radius-sm);
    background: #f1f5f9;
}

.segmented label {
    position: relative;
}

.segmented input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.segmented span {
    display: block;
    padding: 5px 12px;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

.segmented input:checked + span {
    background: #fff;
    color: var(--text);
    box-shadow: var(--shadow);
}

.segmented input[data-full]:checked + span {
    color: var(--primary);
}

.segmented input:focus-visible + span {
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .3);
}

@media (max-width: 560px) {
    .permission-row {
        grid-template-columns: minmax(0, 1fr);
    }

    .segmented {
        display: flex;
    }

    .segmented label {
        flex: 1;
    }

    .segmented span {
        text-align: center;
    }
}

@media (max-width: 900px) {
    .app {
        flex-direction: column;
    }

    .sidebar {
        position: sticky;
        z-index: 10;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        width: auto;
        height: auto;
        gap: 10px 12px;
        padding: 12px 16px 10px;
    }

    .brand {
        padding: 0;
    }

    .nav {
        order: 3;
        flex-direction: row;
        width: 100%;
        overflow-x: auto;
    }

    .nav-label {
        display: none;
    }

    .nav a {
        padding: 7px 12px;
        white-space: nowrap;
    }

    .sidebar-user {
        order: 2;
        margin: 0 0 0 auto;
        padding: 0;
        border: 0;
    }

    .sidebar-user-meta {
        display: none;
    }

    .main {
        padding: 24px 16px;
    }
}

@media (max-width: 720px) {
    .table-stack thead {
        display: none;
    }

    .table-stack tbody tr {
        display: block;
        padding: 14px 16px;
        border-bottom: 1px solid var(--border);
    }

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

    .table-stack td {
        display: block;
        max-width: none;
        padding: 4px 0;
        border: 0;
    }

    .table-stack td[data-label]::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 2px;
        color: var(--text-muted);
        font-size: 11px;
        font-weight: 600;
        letter-spacing: .05em;
        text-transform: uppercase;
    }

    .table-stack .actions {
        flex-wrap: wrap;
        justify-content: flex-start;
        margin-top: 8px;
    }
}

@media (max-width: 560px) {
    .page-header > .btn, .filters .field, .filters-actions, .filters-actions .btn {
        flex: 1 1 100%;
        width: 100%;
    }

    .auth .card-body {
        padding: 24px 20px;
    }

    .dialog-footer .btn {
        flex: 1;
    }

    .pagination-bar {
        justify-content: center;
    }
}

.step-label {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 14px;
    font-weight: 700;
}

.step {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 12px;
}

.key-builder {
    margin-bottom: 24px;
}

.key-path {
    margin-left: 10px;
    padding-left: 18px;
    border-left: 2px solid var(--primary-soft);
}

.key-level {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    margin-bottom: 12px;
}

.key-level-field {
    flex: 1;
    min-width: 0;
}

.key-level-remove {
    padding: 8px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--text-muted);
    font: inherit;
    font-size: 18px;
    line-height: 1.2;
    cursor: pointer;
}

.key-level-remove:hover {
    border-color: var(--danger);
    color: var(--danger);
}

.key-new-level {
    display: flex;
    gap: 8px;
}

.key-new-level .input {
    flex: 1;
    min-width: 0;
}

.key-add-level {
    margin: 0 0 18px 30px;
    border: 1px dashed var(--primary);
    color: var(--primary);
}

.field-hint {
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 12.5px;
}

.key-preview {
    margin-bottom: 18px;
    padding: 12px 14px;
    border: 1px solid #c7d2fe;
    border-radius: var(--radius-sm);
    background: var(--primary-soft);
}

.key-preview-label {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 4px;
    color: var(--text-muted);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.key-preview code {
    color: var(--primary);
    font-family: var(--mono);
    font-size: 14px;
    overflow-wrap: anywhere;
}

.key-preview .field-error:empty {
    display: none;
}

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

.combo {
    position: relative;
}

.combo-toggle {
    overflow: hidden;
    text-align: left;
    white-space: nowrap;
    text-overflow: ellipsis;
    cursor: pointer;
}

.combo-label.is-empty {
    color: var(--text-muted);
}

.combo-panel {
    position: absolute;
    z-index: 10;
    top: calc(100% + 4px);
    right: 0;
    left: 0;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

.combo-list {
    max-height: 220px;
    margin: 8px 0 0;
    padding: 0;
    overflow-y: auto;
    list-style: none;
}

.combo-list li {
    padding: 7px 10px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}

.combo-list li:hover, .combo-list li[aria-selected="true"] {
    background: var(--primary-soft);
    color: var(--primary);
}

.combo-list .combo-create {
    margin-top: 4px;
    border-top: 1px solid var(--border);
    border-radius: 0 0 6px 6px;
    color: var(--primary);
    font-weight: 600;
}

.combo-empty {
    margin: 8px 4px 0;
}

.dialog-footer-note {
    align-self: center;
    margin-right: auto;
    color: var(--text-muted);
    font-size: 13px;
}

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

    .key-new-level {
        flex-wrap: wrap;
    }

    .key-add-level {
        margin-left: 0;
    }

    .dialog-footer-note {
        display: none;
    }
}

/* Ticket page: Jira-style two-column layout, editing and attachment chips */
.ticket-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 20px;
    align-items: start;
}

.ticket-layout .card + .card {
    margin-top: 20px;
}

.ticket-side .card {
    position: sticky;
    top: 20px;
}

@media (max-width: 960px) {
    .ticket-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .ticket-side .card {
        position: static;
    }
}

.section-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.section-head .section-title {
    margin: 0;
}

.section-head .btn {
    margin-left: auto;
}

.edited-mark {
    font-size: 12.5px;
}

.detail-list {
    display: grid;
    gap: 14px;
    margin: 0;
}

.detail-list dt {
    color: var(--text-soft);
    font-size: 12.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.detail-list dd {
    margin: 4px 0 0;
}

.detail-note {
    display: block;
    margin-top: 6px;
    font-size: 12.5px;
}

.detail-list .status-form {
    flex-wrap: wrap;
}

.edit-form.timeline-bubble {
    margin-top: 8px;
}

.edit-form .reply-bar {
    margin-top: 4px;
}

.timeline-meta .btn-sm {
    padding: 2px 8px;
    font-size: 12.5px;
}

.lightbox {
    width: min(960px, calc(100vw - 32px));
    padding: 0;
}

.lightbox-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.lightbox-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
}

.lightbox-image {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 120px);
    margin: 0 auto;
    background: var(--surface-muted);
}

/* Attachment cards: uniform tiles in a responsive grid, long names clamped */
.attachments {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
    gap: 8px;
}

.attachment {
    display: flex;
    flex-direction: column;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    overflow: hidden;
}

.attachment-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 88px;
    padding: 0;
    border: 0;
    background: var(--surface-muted);
    color: var(--text-muted);
    cursor: zoom-in;
}

.attachment-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.attachment-file {
    cursor: pointer;
}

.attachment-file svg {
    width: 32px;
    height: 32px;
}

.attachment-name {
    padding: 6px 8px 0;
    font-size: 12.5px;
    line-height: 1.25;
    color: var(--text-soft);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow-wrap: anywhere;
}

.attachment-actions {
    display: flex;
    justify-content: flex-end;
    gap: 4px;
    padding: 6px 8px;
    margin-top: auto;
}

.attachment-action {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text-soft);
    cursor: pointer;
}

.attachment-action:hover {
    color: var(--text);
    border-color: var(--border-strong);
}

.attachment-action svg {
    width: 14px;
    height: 14px;
}

.attachment-remove:hover {
    color: var(--danger);
    border-color: var(--danger);
}

/* Rich text (editor output) and the Quill editor box */
.rich-text {
    overflow-wrap: anywhere;
}

.rich-text p, .rich-text ul, .rich-text ol, .rich-text blockquote {
    margin: 0 0 8px;
}

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

.rich-text ul, .rich-text ol {
    padding-left: 22px;
}

.rich-text blockquote {
    padding-left: 10px;
    border-left: 3px solid var(--border);
    color: var(--text-soft);
}

.editor {
    background: var(--surface);
    font-size: 14px;
}

.ql-toolbar.ql-snow {
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    background: var(--surface-muted);
}

.ql-container.ql-snow {
    border: 1px solid var(--border-strong);
    border-top: 0;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    min-height: 120px;
    font-family: inherit;
}

.ql-editor {
    min-height: 120px;
}

.ticket-key {
    font-size: 15px;
    color: var(--text-muted);
}

.cell-title {
    min-width: 180px;
    max-width: 320px;
}
