/* ITSM Frontend Styles with Dark Mode Support */

/* Prevent Alpine.js elements from flashing before initialization */
[x-cloak] { display: none !important; }

/* ==================== CSS Variables ==================== */
:root[data-theme="light"] {
    /* Colors */
    --bg-color: #ffffff;
    --card-bg: #f8f9fa;
    --text-color: #212529;
    --text-light: #6c757d;
    --border-color: #dee2e6;

    /* Primary */
    --primary-color: #0d6efd;
    --primary-hover: #0b5ed7;

    /* Status Colors */
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;

    /* Badges */
    --badge-new: #6c757d;
    --badge-open: #0dcaf0;
    --badge-in-progress: #0d6efd;
    --badge-resolved: #198754;
    --badge-closed: #6c757d;

    /* Priority */
    --priority-low: #198754;
    --priority-medium: #ffc107;
    --priority-high: #fd7e14;
    --priority-critical: #dc3545;

    /* Navbar */
    --navbar-bg: #212529;
    --navbar-text: #ffffff;

    /* Sidebar */
    --sidebar-bg: #f8f9fa;
    --sidebar-hover: #e9ecef;
}

:root[data-theme="dark"] {
    /* Colors */
    --bg-color: #212529;
    --card-bg: #343a40;
    --text-color: #f8f9fa;
    --text-light: #adb5bd;
    --border-color: #495057;

    /* Primary */
    --primary-color: #0d6efd;
    --primary-hover: #0b5ed7;

    /* Status Colors (same) */
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;

    /* Badges */
    --badge-new: #6c757d;
    --badge-open: #0dcaf0;
    --badge-in-progress: #0d6efd;
    --badge-resolved: #198754;
    --badge-closed: #6c757d;

    /* Priority */
    --priority-low: #198754;
    --priority-medium: #ffc107;
    --priority-high: #fd7e14;
    --priority-critical: #dc3545;

    /* Navbar */
    --navbar-bg: #000000;
    --navbar-text: #ffffff;

    /* Sidebar */
    --sidebar-bg: #343a40;
    --sidebar-hover: #495057;
}

/* ==================== Base Styles ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

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

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

/* ==================== App Layout (sidebar-only, no top navbar) ==================== */
.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.app-main {
    flex: 1;
    min-width: 0; /* prevent flex item from expanding beyond viewport */
    overflow-y: auto;
    overflow-x: hidden;
    background-color: var(--bg-color);
    display: flex;
    flex-direction: column;
    transition: padding-left 0.22s ease;
}

/* When sidebar is hidden, shift content left to reclaim full width */
.app-main.sidebar-closed {
    padding-left: 0;
}

.main-content {
    flex: 1;
    padding: 2rem;
    padding-left: 2rem;
    width: 100%;
    max-width: 1400px;
    min-width: 0;
}

/* When sidebar is closed, give content a bit of left breathing room for the toggle btn */
.app-main.sidebar-closed .main-content {
    padding-left: 3rem;
}

/* Unauthenticated layout */
.auth-layout {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-color);
}

.auth-flash {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    width: 400px;
    max-width: 90vw;
}

/* ==================== Sidebar ==================== */
.sidebar {
    width: 240px;
    min-width: 240px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
}

/* Logo */
.sidebar-logo {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.sidebar-logo-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: var(--text-color);
}

.sidebar-logo-link:hover { text-decoration: none; }

.sidebar-logo-icon {
    color: var(--primary-color);
    font-size: 1.2rem;
}

.sidebar-logo-text {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-color);
}

/* Nav */
.sidebar-nav {
    flex: 1;
    padding: 0.5rem 0;
    overflow-y: auto;
}

/* Footer */
.sidebar-footer {
    flex-shrink: 0;
    border-top: 1px solid var(--border-color);
    padding: 0.75rem;
}

.theme-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-light);
    padding: 0.4rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.theme-toggle:hover {
    background: var(--sidebar-hover);
    color: var(--text-color);
}

.sidebar-user {
    position: relative;
}

.sidebar-user-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    text-align: left;
}

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

.sidebar-user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.sidebar-user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.75rem;
    color: var(--text-light);
}

.sidebar-user-menu {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.12);
    z-index: 100;
    margin-bottom: 0.25rem;
}

.sidebar-user-menu-item {
    display: block;
    padding: 0.6rem 1rem;
    color: var(--text-color);
    font-size: 0.875rem;
}

.sidebar-user-menu-item:hover {
    background: var(--sidebar-hover);
    text-decoration: none;
}

.sidebar-user-menu-item-danger { color: var(--danger-color); }

.sidebar-section {
    margin-bottom: 2rem;
}

.sidebar-section h3 {
    font-size: 0.875rem;
    text-transform: uppercase;
    color: var(--text-light);
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.sidebar-menu {
    list-style: none;
}

.sidebar-menu li {
    margin-bottom: 0.25rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.75rem;
    color: var(--text-color);
    border-radius: 4px;
    transition: background-color 0.15s;
    font-size: 0.875rem;
}

.sidebar-link:hover {
    background-color: var(--sidebar-hover);
    text-decoration: none;
}

/* ==================== Cards ==================== */
.card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

/* ==================== Forms ==================== */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background-color: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1);
}

/* ==================== Buttons ==================== */
.btn {
    padding: 0.5rem 1rem;
    background-color: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}

.btn:hover {
    background-color: var(--sidebar-hover);
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

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

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--navbar-text);
    cursor: pointer;
    font-size: 1.25rem;
    padding: 0.5rem;
}

/* ==================== Badges ==================== */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 4px;
    text-transform: uppercase;
}

.badge-new { background-color: var(--badge-new); color: white; }
.badge-open { background-color: var(--badge-open); color: black; }
.badge-in_progress { background-color: var(--badge-in-progress); color: white; }
.badge-resolved { background-color: var(--badge-resolved); color: white; }
.badge-closed { background-color: var(--badge-closed); color: white; }

.badge-priority-low { background-color: var(--priority-low); color: white; }
.badge-priority-medium { background-color: var(--priority-medium); color: black; }
.badge-priority-high { background-color: var(--priority-high); color: white; }
.badge-priority-critical { background-color: var(--priority-critical); color: white; }

/* ==================== Tables ==================== */
.table, .data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.table th, .data-table th,
.table td, .data-table td {
    padding: 0.7rem 0.875rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
}

.table th, .data-table th {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-light);
    background-color: var(--sidebar-bg);
    border-top: 1px solid var(--border-color);
    white-space: nowrap;
}

.table tbody tr, .data-table tbody tr {
    background-color: var(--bg-color);
    transition: background-color 0.1s;
}

.table tbody tr:hover, .data-table tbody tr:hover {
    background-color: var(--sidebar-hover);
}

/* Zebra striping for readability in dark mode */
:root[data-theme="dark"] .table tbody tr:nth-child(even),
:root[data-theme="dark"] .data-table tbody tr:nth-child(even) {
    background-color: rgba(255,255,255,0.03);
}

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

.link-primary:hover {
    text-decoration: underline;
}

/* ==================== Login Page ==================== */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: var(--bg-color);
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 2rem;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h2 {
    margin-bottom: 0.5rem;
}

.login-footer {
    text-align: center;
    margin-top: 1rem;
    color: var(--text-light);
}

/* ==================== Dashboard ==================== */
.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    margin-bottom: 0.5rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: box-shadow 0.15s, transform 0.15s;
    cursor: default;
}

.stat-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.stat-icon {
    font-size: 2.5rem;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
    line-height: 1;
}

/* Breadcrumb back arrow */
.breadcrumb-link i { font-size: 0.85rem; }

.dashboard-section {
    margin-bottom: 2rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

/* ==================== Modal ==================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal {
    background-color: var(--card-bg);
    border-radius: 8px;
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-color);
    line-height: 1;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* ==================== Flash Messages ==================== */
.flash-messages {
    margin-bottom: 1.5rem;
}

.alert {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.alert-success {
    background-color: rgba(25, 135, 84, 0.1);
    border: 1px solid var(--success-color);
    color: var(--success-color);
}

.alert-error {
    background-color: rgba(220, 53, 69, 0.1);
    border: 1px solid var(--danger-color);
    color: var(--danger-color);
}

.alert-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: inherit;
}

/* ==================== HTMX Indicator ==================== */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline-block;
}

/* ==================== Utilities ==================== */
.text-muted {
    color: var(--text-light);
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-light);
}

/* ==================== Icon utilities ==================== */
.ti {
    font-size: 1rem;
    vertical-align: middle;
    line-height: 1;
}

.sidebar-link .ti {
    font-size: 0.95rem;
    width: 1.1rem;
    display: inline-block;
    opacity: 0.75;
}

.sidebar-link:hover .ti { opacity: 1; }

.btn .ti, .btn-sm .ti {
    font-size: 0.9rem;
    margin-right: 0.2rem;
    vertical-align: middle;
}

.page-header h1 .ti {
    margin-right: 0.4rem;
    color: var(--primary-color);
}

/* ==================== Sidebar Collapsible ==================== */
.sidebar-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-light);
    border-radius: 4px;
}

.sidebar-section-header:hover {
    background: var(--sidebar-hover);
    color: var(--text-color);
}

.sidebar-chevron {
    font-size: 0.75rem;
    transition: transform 0.2s ease;
    display: inline-block;
    opacity: 0.6;
}

.sidebar-chevron.rotated {
    transform: rotate(-90deg);
}

.sidebar-link-action {
    color: var(--primary-color);
    font-weight: 500;
}

/* ==================== Page Layout ==================== */
.page {
    max-width: 1400px;
    margin: 0 auto;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

.page-header h1 {
    font-size: 1.75rem;
    margin-bottom: 0.25rem;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.breadcrumb-link {
    font-size: 0.875rem;
    color: var(--text-light);
    display: block;
    margin-bottom: 0.25rem;
}

.detail-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 1.5rem;
    align-items: start;
}

.detail-main { min-width: 0; }
.detail-sidebar { min-width: 0; }

.split-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
}

/* ==================== Cards ==================== */
.card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.card-header h3 {
    margin: 0;
}

.card-actions {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

/* ==================== Detail Lists ==================== */
.detail-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.5rem 1rem;
    margin: 0;
}

.detail-list dt {
    font-weight: 600;
    color: var(--text-light);
    font-size: 0.875rem;
}

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

.detail-list.compact dt,
.detail-list.compact dd {
    font-size: 0.875rem;
}

/* ==================== Tags ==================== */
.tag-chip {
    display: inline-block;
    background: var(--border-color);
    color: var(--text-color);
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    margin: 0.1rem;
}

.tags-inline {
    margin-top: 0.25rem;
}

/* ==================== Table Info ==================== */
.table-info {
    font-size: 0.875rem;
    color: var(--text-light);
    margin-bottom: 0.75rem;
}

/* ==================== Utilization Bar ==================== */
.utilization-bar {
    background: var(--border-color);
    border-radius: 4px;
    height: 6px;
    width: 80px;
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
    margin-right: 0.5rem;
}

.utilization-bar.large {
    width: 100%;
    height: 12px;
    display: block;
    margin-bottom: 1rem;
}

.utilization-fill {
    height: 100%;
    background: var(--success-color);
    border-radius: 4px;
}

.utilization-fill.warning {
    background: var(--warning-color);
}

.utilization-fill.danger {
    background: var(--danger-color);
}

/* ==================== CIDR Display ==================== */
.cidr-display {
    font-size: 1rem;
    background: var(--border-color);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    display: inline-block;
    margin-top: 0.25rem;
}

/* ==================== IP Status Badges ==================== */
.badge-ip-available { background: var(--success-color); color: white; }
.badge-ip-in_use { background: var(--primary-color); color: white; }
.badge-ip-reserved { background: var(--warning-color); color: black; }
.badge-ip-deprecated { background: var(--badge-closed); color: white; }

/* ==================== KB Access Badges ==================== */
.badge-access-public { background: var(--success-color); color: white; }
.badge-access-internal { background: var(--info-color); color: black; }
.badge-access-confidential { background: var(--danger-color); color: white; }
.badge-access-department { background: var(--warning-color); color: black; }

/* ==================== KB Status Badges ==================== */
.badge-published { background: var(--success-color); color: white; }
.badge-draft { background: var(--warning-color); color: black; }
.badge-archived { background: var(--badge-closed); color: white; }

/* ==================== Admin Badge ==================== */
.badge-admin { background: var(--danger-color); color: white; }
.badge-internal { background: var(--info-color); color: black; }

/* ==================== Article Content ==================== */
.article-summary {
    background: var(--border-color);
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

.article-content {
    line-height: 1.8;
    margin-bottom: 1.5rem;
}

.article-content h1, .article-content h2, .article-content h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.article-content code {
    background: var(--border-color);
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-family: monospace;
}

.article-content pre {
    background: var(--border-color);
    padding: 1rem;
    border-radius: 4px;
    overflow-x: auto;
}

.article-tags {
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

/* ==================== Comments ==================== */
.comments-list {
    margin-bottom: 1.5rem;
}

.comment {
    padding: 1rem;
    border-left: 3px solid var(--border-color);
    margin-bottom: 1rem;
    background: var(--bg-color);
    border-radius: 0 4px 4px 0;
}

.comment-header {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.comment-author { font-weight: 600; }
.comment-date { color: var(--text-light); }

.comment-form {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* ==================== Btn Danger ==================== */
.btn-danger {
    background-color: var(--danger-color);
    color: white;
    border-color: var(--danger-color);
}

.btn-danger:hover {
    background-color: #bb2d3b;
    color: white;
}

/* ==================== Text Utilities ==================== */
.text-sm { font-size: 0.875rem; }

/* ==================== Form Check ==================== */
.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-check input[type="checkbox"] {
    width: auto;
}

/* ==================== Ticket info grid ==================== */
.ticket-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.25rem;
    margin-top: 0.5rem;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.info-item label {
    font-weight: 600;
    color: var(--text-light);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.info-item-wide {
    grid-column: 1 / -1;
}

/* ==================== Outage Banners ==================== */
#outage-banners {
    width: 100%;
}

.outage-banner {
    width: 100%;
    padding: 0.65rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    box-sizing: border-box;
}

.outage-info {
    background-color: rgba(59, 130, 246, 0.12);
    border-bottom: 1px solid rgba(59, 130, 246, 0.3);
    color: var(--text-color);
}

.outage-warning {
    background-color: rgba(245, 158, 11, 0.12);
    border-bottom: 1px solid rgba(245, 158, 11, 0.4);
    color: var(--text-color);
}

.outage-critical {
    background-color: rgba(239, 68, 68, 0.12);
    border-bottom: 1px solid rgba(239, 68, 68, 0.4);
    color: var(--text-color);
}

/* ==================== Extra Badge variants ==================== */
.badge-info     { background-color: rgba(59,130,246,0.15); color: #2563eb; border: 1px solid rgba(59,130,246,0.3); }
.badge-pending  { background-color: rgba(245,158,11,0.15); color: #d97706; border: 1px solid rgba(245,158,11,0.3); }
.badge-warning  { background-color: rgba(245,158,11,0.15); color: #d97706; border: 1px solid rgba(245,158,11,0.3); }

/* ==================== Responsive Table Wrapper ==================== */
/* Injected by app.js around every table inside .main-content */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    /* Ensure the wrapper itself never escapes its parent */
    max-width: 100%;
    min-width: 0;
}

/* Tables inside the wrapper always use their natural layout */
.table-responsive table,
.table-responsive .table,
.table-responsive .data-table {
    display: table;
    width: 100%;
    min-width: max-content; /* let table be as wide as content needs */
    overflow-x: visible;    /* scroll is on the wrapper, not the table */
}

/* ==================== Filters Bar (list pages) ==================== */
.filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
    margin-bottom: 1.5rem;
    padding: 0.875rem 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 140px;
}

.filter-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-light);
    white-space: nowrap;
}

/* ==================== Mobile Sidebar Backdrop ==================== */
.sidebar-backdrop {
    display: none; /* hidden on desktop */
}

/* ==================== Responsive — 1024px (tablet landscape) ==================== */
@media (max-width: 1024px) {
    /* Sidebar becomes a fixed overlay — does not push content */
    .sidebar {
        position: fixed !important;
        top: 0;
        left: 0;
        z-index: 500;
        height: 100vh;
        box-shadow: 4px 0 24px rgba(0,0,0,0.18);
    }

    /* Content always takes full width since sidebar is overlaid */
    .app-main {
        width: 100%;
        padding-left: 0 !important;
    }

    /* Backdrop shown behind open sidebar */
    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
        z-index: 499;
        cursor: pointer;
    }

    /* Larger touch targets on touch devices */
    .sidebar-link {
        padding: 0.6rem 0.75rem;
        min-height: 44px;
    }

    .sidebar-section-header {
        min-height: 44px;
        padding: 0.5rem 1rem;
    }

    .btn {
        min-height: 40px;
    }

    .btn-sm {
        min-height: 34px;
    }

    /* Sidebar open toggle — always visible on tablet/mobile */
    /* (already fixed-position in base.html, no change needed) */

    /* Detail layout: stack sidebar below main */
    .detail-layout {
        grid-template-columns: 1fr;
    }
}

/* ==================== Responsive — 768px (tablet portrait / phone) ==================== */
@media (max-width: 768px) {
    /* Reduce main content padding */
    .main-content {
        padding: 1rem;
    }

    .app-main.sidebar-closed .main-content {
        padding-left: 1rem;
    }

    /* Page header: wrap title and actions */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .header-actions {
        flex-wrap: wrap;
        width: 100%;
    }

    .header-actions .btn {
        flex: 1 1 auto;
        text-align: center;
        justify-content: center;
    }

    /* Split layout: stack columns */
    .split-layout {
        grid-template-columns: 1fr;
    }

    /* Stats grid: 2 columns on tablet, 1 on very small */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.875rem;
    }

    /* Cards grid: 1 column */
    .cards-grid {
        grid-template-columns: 1fr;
    }

    /* Tables: handled by .table-responsive wrapper injected via app.js.
       The wrapper div scrolls; the table inside uses its natural layout. */
    .table-responsive {
        margin-bottom: 0;
    }
    /* Cards that contain a table get tighter padding so the scroll edge
       aligns with the card border rather than floating inside padding. */
    .card:has(.table-responsive) {
        padding: 0;
        overflow: hidden; /* clip to card's border-radius */
    }
    .card:has(.table-responsive) .card-header,
    .card:has(.table-responsive) .card-actions {
        padding: 1rem 1.25rem;
    }

    /* Filter groups: 2-column layout on tablet */
    .filter-group {
        flex: 1 1 calc(50% - 0.75rem);
        min-width: 120px;
    }

    /* AI chat panel: full-width on mobile */
    .chat-panel {
        width: calc(100vw - 1.5rem) !important;
        max-width: none !important;
    }

    /* Feedback + AI chat widget: tighter positioning */
    #feedback-btn {
        bottom: 1rem;
        left: 1rem;
    }

    #ai-chat-widget {
        bottom: 1rem;
        right: 1rem;
    }

    /* Modal: full-width with slight margin */
    .modal {
        width: 96vw;
        max-width: none;
        max-height: 92vh;
        margin: 0 auto;
    }

    /* Navbar menu hidden (legacy) */
    .navbar-menu {
        display: none;
    }

    /* Page title smaller on mobile */
    .page-header h1 {
        font-size: 1.4rem;
    }

    /* Login card: fill width on mobile */
    .login-card {
        margin: 1rem;
        padding: 1.5rem 1rem;
    }

    /* Ticket info grid: 2-col on tablet */
    .ticket-info-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ==================== Responsive — 480px (phone) ==================== */
@media (max-width: 480px) {
    /* Even tighter padding */
    .main-content {
        padding: 0.75rem;
    }

    /* Stats: single column */
    .stats-grid {
        grid-template-columns: 1fr;
    }

    /* Ticket info: single column */
    .ticket-info-grid {
        grid-template-columns: 1fr;
    }

    /* Filter groups: full width */
    .filter-group {
        flex: 1 1 100%;
    }

    /* Header actions: each button full width */
    .header-actions .btn {
        width: 100%;
    }

    /* Stat cards: compact */
    .stat-card {
        padding: 0.875rem;
    }

    .stat-number {
        font-size: 1.5rem;
    }

    .stat-icon {
        font-size: 2rem;
    }

    /* Page title: compact */
    .page-header h1 {
        font-size: 1.25rem;
    }

    /* Card padding: reduce */
    .card {
        padding: 1rem;
    }

    /* Table cells: tighter on phone */
    .table th,
    .table td,
    .data-table th,
    .data-table td {
        padding: 0.55rem 0.6rem;
        font-size: 0.8rem;
    }
}
}

/* ==================== Users list page ==================== */
/* Minimal additions for the Person cell. The table itself uses the
   shared .data-table styles with natural auto-layout — no width hints,
   no table-layout:fixed, no colgroup. That's what keeps the columns
   aligned and prevents the "shift" bug that the previous redesigns hit. */
.user-identity {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}
.user-avatar {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #fff;
    background: var(--primary-color);
    user-select: none;
}
.user-avatar--img {
    object-fit: cover;
    background: var(--border-color);
}
.user-identity-text {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}
.user-identity-line {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}
.user-name {
    font-weight: 600;
    color: var(--text-color);
}
.user-email {
    font-size: 0.8rem;
    color: var(--text-light);
    text-decoration: none;
}
.user-email:hover {
    color: var(--primary-color);
    text-decoration: underline;
}
.user-actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}
.user-action-form {
    margin: 0;
    display: inline;
}

/* ====== Profile page ====== */
.profile-card {
    margin-bottom: 1rem;
}
.profile-avatar-row {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}
.profile-avatar {
    flex: 0 0 auto;
    width: 96px;
    height: 96px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #fff;
    background: var(--primary-color);
    user-select: none;
}
.profile-avatar--img {
    object-fit: cover;
    background: var(--border-color);
}
.profile-identity {
    min-width: 0;
}
.profile-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-color);
}
.profile-email {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-top: 0.15rem;
}
.profile-meta {
    color: var(--text-light);
    font-size: 0.85rem;
    margin-top: 0.25rem;
}
.profile-upload-form input[type="file"] {
    display: block;
    margin: 0.4rem 0 0.25rem;
    color: var(--text-color);
}
.profile-upload-hint {
    color: var(--text-light);
    font-size: 0.8rem;
    margin: 0 0 0.75rem;
}
.profile-upload-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.profile-info-card {
    margin-top: 1rem;
}
.profile-section-title {
    margin: 0 0 0.75rem;
    font-size: 1rem;
}
.profile-dl {
    display: grid;
    grid-template-columns: 10rem 1fr;
    row-gap: 0.4rem;
    column-gap: 1rem;
    margin: 0 0 1rem;
}
.profile-dl dt {
    color: var(--text-light);
    font-weight: 600;
}
.profile-dl dd {
    margin: 0;
    color: var(--text-color);
    word-break: break-word;
}

/* =====================================================================
   Ticket module redesign (scoped to .ticket-ui — does not affect other
   modules). Extends the existing design tokens; theme-aware via color-mix.
   ===================================================================== */
.ticket-ui {
    --tk-status-new: var(--badge-new);
    --tk-status-open: var(--badge-open);
    --tk-status-in_progress: var(--badge-in-progress);
    --tk-status-pending: var(--priority-high);
    --tk-status-resolved: var(--badge-resolved);
    --tk-status-closed: var(--badge-closed);
    --tk-status-cancelled: var(--danger-color);
    --tk-prio-low: var(--priority-low);
    --tk-prio-medium: var(--priority-medium);
    --tk-prio-high: var(--priority-high);
    --tk-prio-critical: var(--priority-critical);
    --tk-radius: 12px;
    --tk-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 16px -8px rgba(0,0,0,0.12);
}

/* ---- Toolbar / header ---- */
.tk-toolbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}
.tk-toolbar .tk-title { display: flex; flex-direction: column; gap: 0.15rem; }
.tk-toolbar .tk-title h1 { margin: 0; font-size: 1.6rem; letter-spacing: -0.02em; }
.tk-toolbar .tk-subtitle { color: var(--text-light); font-size: 0.875rem; }
.tk-btn-new {
    display: inline-flex; align-items: center; gap: 0.45rem; font-weight: 600;
    box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--primary-color) 60%, transparent);
}

/* ---- Filter bar ---- */
.tk-filters {
    display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap;
    padding: 0.75rem 0.9rem;
    background: var(--card-bg); border: 1px solid var(--border-color);
    border-radius: var(--tk-radius); margin-bottom: 1.1rem;
}
.tk-filters form { display: contents; }
.tk-filters .tk-search { position: relative; flex: 1 1 220px; min-width: 180px; }
.tk-filters .tk-search .ti {
    position: absolute; left: 0.65rem; top: 50%; transform: translateY(-50%);
    color: var(--text-light); pointer-events: none;
}
.tk-filters .tk-search input { padding-left: 2rem; border-radius: 999px; }
.tk-filters select.form-control { width: auto; min-width: 120px; border-radius: 999px; cursor: pointer; }
.tk-filters .htmx-indicator { color: var(--text-light); font-size: 0.8rem; }

/* ---- Status & priority pills ---- */
.tk-pill {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.2rem 0.6rem 0.2rem 0.5rem;
    font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em;
    border-radius: 999px; text-transform: capitalize; white-space: nowrap;
    border: 1px solid transparent;
}
.tk-pill .tk-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.tk-status {
    color: var(--_c, var(--text-light));
    background: color-mix(in srgb, var(--_c, var(--text-light)) 13%, var(--card-bg));
    border-color: color-mix(in srgb, var(--_c, var(--text-light)) 30%, transparent);
}
.tk-status[data-s="new"]         { --_c: var(--tk-status-new); }
.tk-status[data-s="open"]        { --_c: var(--tk-status-open); }
.tk-status[data-s="in_progress"] { --_c: var(--tk-status-in_progress); }
.tk-status[data-s="pending"]     { --_c: var(--tk-status-pending); }
.tk-status[data-s="resolved"]    { --_c: var(--tk-status-resolved); }
.tk-status[data-s="closed"]      { --_c: var(--tk-status-closed); }
.tk-status[data-s="cancelled"]   { --_c: var(--tk-status-cancelled); }

.tk-prio {
    color: var(--_c, var(--text-light));
    background: color-mix(in srgb, var(--_c, var(--text-light)) 12%, var(--card-bg));
    border-color: color-mix(in srgb, var(--_c, var(--text-light)) 28%, transparent);
}
.tk-prio[data-p="low"]      { --_c: var(--tk-prio-low); }
.tk-prio[data-p="medium"]   { --_c: var(--tk-prio-medium); }
.tk-prio[data-p="high"]     { --_c: var(--tk-prio-high); }
.tk-prio[data-p="critical"] { --_c: var(--tk-prio-critical); }
.tk-prio .tk-dot { border-radius: 2px; }

/* ---- Ticket list (card rows) ---- */
.tk-list {
    background: var(--card-bg); border: 1px solid var(--border-color);
    border-radius: var(--tk-radius); box-shadow: var(--tk-shadow); overflow: hidden;
}
.tk-row {
    display: grid; grid-template-columns: 86px minmax(0,1fr) auto;
    align-items: center; gap: 1rem; padding: 0.85rem 1.1rem;
    border-left: 3px solid transparent; border-bottom: 1px solid var(--border-color);
    text-decoration: none; color: var(--text-color);
    transition: background 0.12s ease, border-color 0.12s ease;
}
.tk-row:last-child { border-bottom: none; }
.tk-row:hover { background: color-mix(in srgb, var(--primary-color) 6%, var(--bg-color)); text-decoration: none; }
.tk-row[data-p="critical"] { border-left-color: var(--tk-prio-critical); }
.tk-row[data-p="high"]     { border-left-color: var(--tk-prio-high); }
.tk-row[data-p="medium"]   { border-left-color: color-mix(in srgb, var(--tk-prio-medium) 70%, transparent); }
.tk-row[data-p="low"]      { border-left-color: color-mix(in srgb, var(--tk-prio-low) 55%, transparent); }
.tk-row .tk-num { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 0.85rem; color: var(--primary-color); }
.tk-row .tk-main { min-width: 0; }
.tk-row .tk-subject { font-weight: 600; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tk-row .tk-meta {
    display: flex; align-items: center; gap: 0.5rem 0.9rem; flex-wrap: wrap;
    margin-top: 0.3rem; font-size: 0.78rem; color: var(--text-light);
}
.tk-row .tk-meta .ti { font-size: 0.9rem; vertical-align: -2px; margin-right: 0.15rem; }
.tk-row .tk-right { display: flex; align-items: center; gap: 0.6rem; justify-content: flex-end; }
.tk-due { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.78rem; color: var(--text-light); white-space: nowrap; }
.tk-due.is-overdue { color: var(--danger-color); font-weight: 600; }
.tk-unassigned { font-style: italic; opacity: 0.75; }
@media (max-width: 720px) {
    .tk-row { grid-template-columns: 64px minmax(0,1fr); }
    .tk-row .tk-right { grid-column: 1 / -1; justify-content: flex-start; padding-left: 64px; }
}

/* ---- Pagination footer ---- */
.tk-pagination {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 0.8rem 1.1rem; background: var(--bg-color);
    border-top: 1px solid var(--border-color); font-size: 0.8rem; color: var(--text-light);
}

/* ---- Empty state ---- */
.tk-empty { text-align: center; padding: 3.5rem 1rem; color: var(--text-light); }
.tk-empty .tk-empty-icon { font-size: 2.75rem; color: color-mix(in srgb, var(--primary-color) 45%, var(--text-light)); margin-bottom: 0.5rem; }
.tk-empty h3 { margin: 0.25rem 0; color: var(--text-color); }

/* ---- Detail hero header ---- */
.tk-hero {
    background: linear-gradient(180deg, color-mix(in srgb, var(--primary-color) 8%, var(--card-bg)), var(--card-bg));
    border: 1px solid var(--border-color); border-radius: var(--tk-radius);
    padding: 1.2rem 1.4rem; margin-bottom: 1.25rem; box-shadow: var(--tk-shadow);
}
.tk-hero .tk-breadcrumb { font-size: 0.8rem; color: var(--text-light); text-decoration: none; }
.tk-hero .tk-breadcrumb:hover { color: var(--primary-color); }
.tk-hero .tk-hero-top { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-top: 0.35rem; }
.tk-hero .tk-hero-num { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.05rem; color: var(--primary-color); letter-spacing: -0.01em; }
.tk-hero h1 { margin: 0.4rem 0 0; font-size: 1.45rem; letter-spacing: -0.02em; line-height: 1.25; }
.tk-hero .tk-hero-actions { margin-left: auto; display: flex; gap: 0.4rem; }

/* ---- Section cards ---- */
.tk-card {
    background: var(--card-bg); border: 1px solid var(--border-color);
    border-radius: var(--tk-radius); box-shadow: var(--tk-shadow);
    margin-bottom: 1.25rem; overflow: hidden;
}
.tk-card > .tk-card-head {
    display: flex; align-items: center; gap: 0.5rem; padding: 0.75rem 1.1rem;
    border-bottom: 1px solid var(--border-color);
    background: color-mix(in srgb, var(--text-light) 5%, var(--card-bg));
}
.tk-card > .tk-card-head h3 {
    margin: 0; font-size: 0.82rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--text-light);
}
.tk-card > .tk-card-head .ti { color: var(--primary-color); }
.tk-card > .tk-card-body { padding: 1.1rem; }

/* ---- Refined form fields inside ticket-ui ---- */
.ticket-ui .form-control { border-radius: 8px; padding: 0.55rem 0.7rem; transition: border-color 0.12s, box-shadow 0.12s; }
.ticket-ui .form-group label, .ticket-ui .tk-field label {
    font-size: 0.78rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.03em; color: var(--text-light);
}
.tk-field { margin-bottom: 1rem; }
.tk-field .tk-hint { font-size: 0.75rem; color: var(--text-light); margin-top: 0.3rem; display: block; }
.tk-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem 1rem; }
.tk-grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 0.75rem 1rem; }
@media (max-width: 640px) { .tk-grid-2, .tk-grid-3 { grid-template-columns: 1fr; } }

/* ---- Description body ---- */
.tk-description { line-height: 1.7; color: var(--text-color); font-size: 0.95rem; }
.tk-description.is-plain { white-space: pre-wrap; }
.tk-description img { max-width: 100%; height: auto; border-radius: 6px; }
.tk-description a { color: var(--primary-color); }
.tk-description blockquote { margin: 0.5rem 0; padding-left: 0.9rem; border-left: 3px solid var(--border-color); color: var(--text-light); }
.tk-description table { border-collapse: collapse; max-width: 100%; }
.tk-description td, .tk-description th { border: 1px solid var(--border-color); padding: 0.3rem 0.5rem; }

/* ---- Comment timeline ---- */
.tk-comments { display: flex; flex-direction: column; gap: 0.9rem; }
.tk-comment { display: grid; grid-template-columns: 36px 1fr; gap: 0.7rem; }
.tk-comment .tk-avatar {
    width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
    font-weight: 700; font-size: 0.85rem; color: #fff; background: var(--primary-color); flex: none;
}
.tk-comment.is-system .tk-avatar { background: var(--text-light); }
.tk-comment .tk-bubble { background: var(--bg-color); border: 1px solid var(--border-color); border-radius: 10px; padding: 0.6rem 0.85rem; min-width: 0; }
.tk-comment.is-internal .tk-bubble {
    background: color-mix(in srgb, var(--warning-color) 12%, var(--bg-color));
    border-color: color-mix(in srgb, var(--warning-color) 35%, var(--border-color));
}
.tk-comment .tk-bubble-head { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.25rem; font-size: 0.82rem; }
.tk-comment .tk-bubble-head .tk-author { font-weight: 600; }
.tk-comment .tk-bubble-head .tk-time { color: var(--text-light); font-size: 0.75rem; }
.tk-tag-internal {
    font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
    padding: 0.1rem 0.4rem; border-radius: 4px; background: var(--warning-color); color: #000;
}
.tk-comment .tk-content { white-space: pre-wrap; line-height: 1.6; font-size: 0.9rem; }

/* email-from hint */
.tk-email-note { font-size: 0.8rem; color: var(--text-light); margin: 0.25rem 0 0.6rem; display: flex; align-items: center; gap: 0.4rem; }
.tk-email-note .ti { color: var(--primary-color); }

/* Sandboxed inbound-email HTML frame */
.tk-email-frame {
    width: 100%;
    min-height: 120px;
    border: none;
    background: #ffffff;
    border-radius: 8px;
    display: block;
}

/* ---- Ticket UI: a11y + responsive fixes (audit follow-ups) ---- */
.ticket-ui .required { color: var(--danger-color); font-weight: 600; }
/* Stronger priority rails so low/medium are distinguishable (not just faint colour) */
.tk-row[data-p="medium"] { border-left-color: var(--tk-prio-medium); }
.tk-row[data-p="low"]    { border-left-color: var(--tk-prio-low); }
/* Email iframe: keep a light canvas (emails assume white) but soften the edge in dark mode */
:root[data-theme="dark"] .tk-email-frame { box-shadow: 0 0 0 1px var(--border-color); }
@media (max-width: 480px) {
    .tk-filters { flex-direction: column; align-items: stretch; }
    .tk-filters .tk-search { min-width: 0; }
    .tk-filters select.form-control { width: 100%; }
    .tk-hero-actions { order: -1; }
}

/* ---- Ticket activity / change history timeline ---- */
.tk-activity { display: flex; flex-direction: column; gap: 0.5rem; }
.tk-act-item { display: grid; grid-template-columns: 14px 1fr; gap: 0.6rem; position: relative; padding-bottom: 0.5rem; }
.tk-act-item:not(:last-child)::before {
    content: ""; position: absolute; left: 6px; top: 14px; bottom: -2px;
    width: 1px; background: var(--border-color);
}
.tk-act-dot {
    width: 11px; height: 11px; border-radius: 50%; margin-top: 3px;
    background: var(--text-light); border: 2px solid var(--card-bg);
    box-shadow: 0 0 0 1px var(--border-color); z-index: 1;
}
.tk-act-dot[data-a="CREATE"] { background: var(--badge-resolved, #198754); }
.tk-act-dot[data-a="UPDATE"] { background: var(--primary-color); }
.tk-act-dot[data-a="STATUS_CHANGE"] { background: var(--priority-high, #fd7e14); }
.tk-act-dot[data-a="DELETE"] { background: var(--danger-color); }
.tk-act-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.4rem; font-size: 0.85rem; }
.tk-act-actor { font-weight: 600; }
.tk-act-action { color: var(--text-light); }
.tk-act-time { color: var(--text-light); font-size: 0.75rem; margin-left: auto; }
.tk-act-changes { list-style: none; margin: 0.3rem 0 0; padding: 0; font-size: 0.8rem; }
.tk-act-changes li { padding: 0.1rem 0; color: var(--text-light); }
.tk-act-field { font-weight: 600; color: var(--text-color); text-transform: capitalize; }
.tk-act-old { text-decoration: line-through; opacity: 0.8; }
.tk-act-new { color: var(--text-color); font-weight: 500; }
.tk-act-desc { font-size: 0.8rem; color: var(--text-light); margin-top: 0.2rem; }
