/* K2 MSP Ticketing System - Base Stylesheet */

:root {
    --k2-blue:      #1a3a5c;
    --k2-blue-light:#2563a8;
    --k2-accent:    #e8f0fe;
    --danger:       #c0392b;
    --success:      #27ae60;
    --warning:      #e67e22;
    --text:         #1f2937;
    --text-muted:   #6b7280;
    --border:       #d1d5db;
    --bg:           #f3f4f6;
    --white:        #ffffff;
    --radius:       6px;
    --shadow:       0 1px 4px rgba(0,0,0,.12);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--k2-blue-light); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===================== Navbar ===================== */
.navbar {
    background: var(--k2-blue);
    color: var(--white);
    display: flex;
    align-items: center;
    padding: 0 24px;
    height: 52px;
    gap: 24px;
    flex-shrink: 0;
}
.nav-brand { font-size: 16px; font-weight: 700; white-space: nowrap; }
.nav-links { display: flex; gap: 16px; flex: 1; }
.nav-links a { color: rgba(255,255,255,.85); font-size: 13px; }
.nav-links a:hover { color: var(--white); text-decoration: none; }
.nav-user { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.nav-user span { color: rgba(255,255,255,.8); }
.btn-logout {
    background: rgba(255,255,255,.15);
    color: var(--white) !important;
    border-radius: var(--radius);
    padding: 4px 12px;
    font-size: 12px;
}
.btn-logout:hover { background: rgba(255,255,255,.25); text-decoration: none; }

/* ===================== Role badges ===================== */
.role-badge {
    font-size: 11px;
    border-radius: 99px;
    padding: 2px 8px;
    font-weight: 600;
    background: rgba(255,255,255,.2);
    color: var(--white) !important;
}

/* ===================== Main content ===================== */
.main-content { flex: 1; padding: 32px 32px 16px; max-width: 1200px; width: 100%; margin: 0 auto; }

.page-header { margin-bottom: 24px; }
.page-header h2 { font-size: 22px; color: var(--k2-blue); }
.subtitle { color: var(--text-muted); margin-top: 4px; }

/* ===================== Cards ===================== */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}
.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}
.card h3 { font-size: 15px; color: var(--k2-blue); margin-bottom: 8px; }
.card p  { color: var(--text-muted); margin-bottom: 14px; line-height: 1.5; }

/* ===================== Buttons ===================== */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-align: center;
    transition: opacity .15s;
}
.btn:hover { opacity: .88; text-decoration: none; }
.btn-primary   { background: var(--k2-blue-light); color: var(--white); }
.btn-secondary { background: var(--white); color: var(--k2-blue); border: 1px solid var(--border); }
.btn-danger    { background: var(--danger); color: var(--white); }
.btn-full      { display: block; width: 100%; }

/* ===================== Alerts ===================== */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 13px;
}
.alert-error   { background: #fde8e8; color: var(--danger); border: 1px solid #f5c6c6; }
.alert-success { background: #d4edda; color: #155724;       border: 1px solid #c3e6cb; }
.alert-info    { background: var(--k2-accent); color: var(--k2-blue); border: 1px solid #b6d0f5; }

/* ===================== Info box ===================== */
.info-box {
    background: var(--k2-accent);
    border: 1px solid #b6d0f5;
    border-radius: var(--radius);
    padding: 14px 18px;
    color: var(--k2-blue);
    font-size: 13px;
    margin-bottom: 20px;
}

/* ===================== Login page ===================== */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--k2-blue);
    min-height: 100vh;
}
.login-card {
    background: var(--white);
    border-radius: 10px;
    padding: 40px 36px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 8px 32px rgba(0,0,0,.25);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo h1 { font-size: 28px; color: var(--k2-blue); letter-spacing: 2px; }
.login-logo p  { color: var(--text-muted); margin-top: 4px; }
.login-footer  { text-align: center; color: var(--text-muted); font-size: 11px; margin-top: 20px; }

/* ===================== Forms ===================== */
.login-form { display: flex; flex-direction: column; gap: 14px; }
.form-group  { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-weight: 600; font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.form-group input,
.form-group select,
.form-group textarea {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 9px 12px;
    font-size: 14px;
    color: var(--text);
    outline: none;
    transition: border-color .15s;
    width: 100%;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--k2-blue-light); }

/* ===================== Tables ===================== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--white); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
thead { background: var(--k2-blue); color: var(--white); }
th, td { padding: 10px 14px; text-align: left; font-size: 13px; }
th { font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:hover { background: var(--k2-accent); }

/* ===================== Footer ===================== */
.footer { text-align: center; padding: 14px; color: var(--text-muted); font-size: 11px; }

/* ===================== Status badges ===================== */
.status-badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
}
.status-new                { background: #dbeafe; color: #1e40af; }
.status-open               { background: #dcfce7; color: #166534; }
.status-in-progress        { background: #fef9c3; color: #854d0e; }
.status-waiting-on-customer{ background: #fde68a; color: #92400e; }
.status-waiting-on-vendor  { background: #ede9fe; color: #4c1d95; }
.status-resolved           { background: #d1fae5; color: #065f46; }
.status-closed             { background: #f3f4f6; color: #6b7280; }

/* ===================== Priority badges ===================== */
.priority-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .3px;
}
.priority-emergency { background: #fee2e2; color: #b91c1c; }
.priority-critical  { background: #fed7aa; color: #c2410c; }
.priority-normal    { background: #f3f4f6; color: #374151; }
.priority-low       { background: #f0fdf4; color: #15803d; }

/* ===================== Category tag ===================== */
.category-tag {
    display: inline-block;
    background: var(--k2-accent);
    color: var(--k2-blue);
    border-radius: 4px;
    font-size: 10px;
    padding: 1px 6px;
    margin-left: 4px;
    font-weight: 600;
    text-transform: uppercase;
}

/* ===================== Quick filter badges ===================== */
.filter-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.filter-badge {
    padding: 5px 14px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--border);
    background: var(--white);
    color: var(--text);
    cursor: pointer;
    text-decoration: none !important;
    display: flex;
    align-items: center;
    gap: 6px;
}
.filter-badge:hover { background: var(--k2-accent); border-color: var(--k2-blue-light); }
.filter-badge.active { background: var(--k2-blue); color: var(--white); border-color: var(--k2-blue); }
.badge-count {
    background: rgba(0,0,0,.12);
    border-radius: 99px;
    padding: 1px 7px;
    font-size: 11px;
}
.filter-badge.active .badge-count { background: rgba(255,255,255,.25); }

/* Priority filter badge variants */
.filter-badge.badge-emergency { border-color: #fca5a5; color: #b91c1c; }
.filter-badge.badge-emergency:hover,
.filter-badge.badge-emergency.active { background: #b91c1c; color: #fff; border-color: #b91c1c; }

.filter-badge.badge-critical { border-color: #fdba74; color: #c2410c; }
.filter-badge.badge-critical:hover,
.filter-badge.badge-critical.active { background: #c2410c; color: #fff; border-color: #c2410c; }

.filter-badge.badge-priority-normal { border-color: #d1d5db; color: #374151; }
.filter-badge.badge-priority-normal:hover,
.filter-badge.badge-priority-normal.active { background: #374151; color: #fff; border-color: #374151; }

.filter-badge.badge-priority-low { border-color: #86efac; color: #15803d; }
.filter-badge.badge-priority-low:hover,
.filter-badge.badge-priority-low.active { background: #15803d; color: #fff; border-color: #15803d; }

/* Separator between status and priority badge groups */
.filter-badge-sep {
    display: inline-flex;
    align-items: center;
    width: 1px;
    background: var(--border);
    margin: 2px 4px;
    align-self: stretch;
}

/* ===================== Filter bar ===================== */
.filter-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    align-items: center;
}
.filter-bar select {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 7px 10px;
    font-size: 13px;
    color: var(--text);
    background: var(--white);
    cursor: pointer;
}

/* ===================== Ticket list ===================== */
.ticket-row { cursor: pointer; }
.ticket-num { font-weight: 700; color: var(--k2-blue-light); }
.ticket-subject { font-weight: 600; color: var(--text); }
.ticket-subject:hover { color: var(--k2-blue-light); }
.text-muted { color: var(--text-muted); }

/* ===================== Pagination ===================== */
.pagination {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    justify-content: center;
}
.page-info { color: var(--text-muted); font-size: 13px; }

/* ===================== Empty state ===================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

/* ===================== Ticket detail ===================== */
.breadcrumb {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 16px;
}
.breadcrumb a { color: var(--k2-blue-light); }

.ticket-header { margin-bottom: 20px; }
.ticket-header h2 { font-size: 20px; color: var(--k2-blue); line-height: 1.3; }
.ticket-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; font-size: 12px; }

.ticket-layout {
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: 24px;
    align-items: start;
}
@media (max-width: 800px) {
    .ticket-layout { grid-template-columns: 1fr; }
}

/* Note cards */
.note-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 12px;
    overflow: hidden;
}
.note-description { border-left: 4px solid var(--k2-blue); }
.note-internal    { border-left: 4px solid #f59e0b; background: #fffbeb; }
.note-public      { border-left: 4px solid var(--k2-blue-light); }
.note-customer_reply { border-left: 4px solid var(--success); }
.note-system      { border-left: 4px solid #d1d5db; background: #f9fafb; }

.note-header {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    flex-wrap: wrap;
}
.note-author   { font-weight: 700; }
.note-time     { margin-left: auto; }
.note-type-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    padding: 2px 8px;
    border-radius: 99px;
}
.note-type-label.system   { background: #f3f4f6; color: #6b7280; }
.note-type-label.internal { background: #fef3c7; color: #92400e; }
.note-type-label.public   { background: #dbeafe; color: #1e40af; }
.note-type-label.customer { background: #dcfce7; color: #166534; }

.note-body { padding: 14px; font-size: 13px; line-height: 1.6; }

.company-pill {
    background: var(--k2-accent);
    color: var(--k2-blue);
    border-radius: 99px;
    padding: 2px 10px;
    font-size: 11px;
    font-weight: 600;
}

/* Add note form */
.add-note-form {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    margin-top: 8px;
}
.add-note-form h4 { font-size: 14px; color: var(--k2-blue); margin-bottom: 12px; }
.radio-label, .checkbox-label { font-size: 13px; cursor: pointer; display: flex; align-items: center; gap: 5px; }

/* Sidebar */
.ticket-sidebar { display: flex; flex-direction: column; gap: 0; }
.sidebar-section {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 10px;
}
.sidebar-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.sidebar-select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 8px;
    font-size: 13px;
    color: var(--text);
    background: var(--bg);
    cursor: pointer;
}
/* Priority dropdown — color-coded to match priority badges */
.priority-select.priority-select-emergency { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; font-weight: 600; }
.priority-select.priority-select-critical  { background: #fed7aa; color: #c2410c; border-color: #fdba74; font-weight: 600; }
.priority-select.priority-select-normal    { background: #f3f4f6; color: #374151; border-color: #d1d5db; }
.priority-select.priority-select-low       { background: #f0fdf4; color: #15803d; border-color: #86efac; }
.ts-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
    padding: 3px 0;
    border-bottom: 1px solid var(--border);
}
.ts-row:last-child { border-bottom: none; }
.ts-row span:first-child { font-weight: 600; }

/* ===================== Forms (tickets/admin) ===================== */
.form-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 32px;
    max-width: 860px;
    box-shadow: var(--shadow);
}
.form-section-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    padding-bottom: 6px;
    margin-bottom: 16px;
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}
.form-row .form-group { margin-bottom: 0; }
.form-group { margin-bottom: 16px; }
.form-group textarea { resize: vertical; min-height: 80px; }
.form-actions { display: flex; gap: 12px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
.required { color: var(--danger); }

/* Role hint box */
.role-hint-box {
    margin-top: 8px;
    padding: 8px 12px;
    background: var(--k2-accent);
    border: 1px solid #b6d0f5;
    border-radius: var(--radius);
    font-size: 12px;
    color: var(--k2-blue);
    line-height: 1.5;
}

/* Inline form (add domain) */
.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form input { width: 220px; border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; font-size: 13px; }

/* ===================== Admin tables ===================== */
.role-pill {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 700;
}
.role-pill-admin            { background: #fde8e8; color: #b91c1c; }
.role-pill-technician       { background: #dbeafe; color: #1e40af; }
.role-pill-customer_user    { background: #f3f4f6; color: #374151; }
.role-pill-customer_manager { background: #ede9fe; color: #4c1d95; }

.status-dot {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 600;
}
.status-dot::before { content: '●'; font-size: 9px; }
.status-dot.active   { color: var(--success); }
.status-dot.inactive { color: var(--text-muted); }

/* ===================== Attachments ===================== */
.attachment-list { display:flex; flex-wrap:wrap; gap:6px; padding:10px 14px; }
.attachment-list-label { width:100%; font-size:11px; font-weight:700; text-transform:uppercase; color:var(--text-muted); letter-spacing:.4px; margin-bottom:4px; }
.attachment-chip {
    display:inline-flex;
    align-items:center;
    gap:6px;
    background:var(--bg);
    border:1px solid var(--border);
    border-radius:var(--radius);
    padding:4px 10px;
    font-size:12px;
    color:var(--k2-blue-light);
    text-decoration:none;
    transition:background .15s;
}
.attachment-chip:hover { background:var(--k2-accent); text-decoration:none; }
.attachment-size { color:var(--text-muted); font-size:11px; }

/* Search bar */
.search-bar {
    display:flex;
    gap:8px;
    margin-bottom:16px;
    align-items:center;
}
.search-bar input {
    flex:1;
    border:1px solid var(--border);
    border-radius:var(--radius);
    padding:8px 12px;
    font-size:14px;
}
.search-bar input:focus { border-color:var(--k2-blue-light); outline:none; }

/* ===================== Dashboard metrics ===================== */
.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}
.metric-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 16px;
    text-align: center;
    text-decoration: none !important;
    box-shadow: var(--shadow);
    transition: transform .1s, box-shadow .1s;
    border-top: 4px solid var(--border);
}
.metric-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.metric-value { font-size: 36px; font-weight: 800; line-height: 1; }
.metric-label { font-size: 12px; color: var(--text-muted); margin-top: 6px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.metric-blue   { border-top-color: var(--k2-blue-light); }
.metric-blue   .metric-value { color: var(--k2-blue-light); }
.metric-orange { border-top-color: var(--warning); }
.metric-orange .metric-value { color: var(--warning); }
.metric-teal   { border-top-color: #0d9488; }
.metric-teal   .metric-value { color: #0d9488; }
.metric-red    { border-top-color: var(--danger); }
.metric-red    .metric-value { color: var(--danger); }
.metric-yellow { border-top-color: #d97706; }
.metric-yellow .metric-value { color: #d97706; }
.metric-gray   { border-top-color: #6b7280; }
.metric-gray   .metric-value { color: #6b7280; }

/* Status breakdown bar chart */
.status-breakdown {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}
.status-breakdown h3 { font-size: 14px; color: var(--k2-blue); margin-bottom: 16px; }
.breakdown-bars { display: flex; flex-direction: column; gap: 10px; }
.breakdown-row  { display: flex; align-items: center; gap: 12px; }
.breakdown-label { font-size: 12px; font-weight: 600; color: var(--text-muted); width: 140px; flex-shrink: 0; text-align: right; }
.breakdown-bar-wrap { flex: 1; background: var(--bg); border-radius: 99px; height: 10px; overflow: hidden; }
.breakdown-bar  { background: var(--k2-blue-light); height: 100%; border-radius: 99px; transition: width .4s; }
.breakdown-count { font-size: 13px; font-weight: 700; color: var(--text); width: 36px; text-align: right; }
.breakdown-count a { color: var(--text); }

/* ===================== Attachments ===================== */
.attachment-list { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 14px; }
.attachment-list-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; width: 100%; margin-bottom: 2px; }
.attachment-chip {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--bg); border: 1px solid var(--border);
    border-radius: 99px; padding: 4px 12px;
    font-size: 12px; color: var(--k2-blue-light);
    text-decoration: none; transition: background .15s;
}
.attachment-chip:hover { background: var(--k2-accent); text-decoration: none; }
.attachment-size { font-size: 11px; color: var(--text-muted); }

/* ===================== Checkbox dropdown ===================== */
.check-dropdown { position: relative; display: inline-block; }

.check-dropdown-btn {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--white); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 7px 12px;
    font-size: 13px; cursor: pointer; color: var(--text);
    white-space: nowrap; line-height: 1.3;
    transition: border-color .15s;
}
.check-dropdown-btn:hover { border-color: var(--k2-blue-light); }
.check-dropdown-btn.has-selection {
    border-color: var(--k2-blue-light);
    background: var(--k2-accent);
    color: var(--k2-blue);
    font-weight: 600;
}
.cd-caret { font-size: 9px; color: var(--text-muted); transition: transform .15s; }
.check-dropdown.open .cd-caret { transform: rotate(180deg); }

.check-dropdown-panel {
    display: none; position: absolute; top: calc(100% + 4px); left: 0;
    background: var(--white); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: 0 6px 20px rgba(0,0,0,.13);
    z-index: 200; min-width: 210px; padding: 4px 0;
}
.check-dropdown.open .check-dropdown-panel { display: block; }

.cd-option {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 14px; cursor: pointer; font-size: 13px;
    transition: background .1s; user-select: none;
}
.cd-option:hover { background: var(--bg); }
.cd-option input[type="checkbox"] { margin: 0; cursor: pointer; accent-color: var(--k2-blue-light); width: 14px; height: 14px; flex-shrink: 0; }
.cd-divider { border: none; border-top: 1px solid var(--border); margin: 4px 0; }
.cd-clear-link { display: block; text-align: right; font-size: 11px; color: var(--text-muted); padding: 4px 14px 6px; cursor: pointer; }
.cd-clear-link:hover { color: var(--danger); }

/* Clear filters icon button */
.btn-clear-filters {
    display: inline-flex; align-items: center; justify-content: center;
    background: none; border: 1px solid var(--border); border-radius: var(--radius);
    padding: 7px 10px; cursor: pointer; color: var(--text-muted);
    font-size: 14px; line-height: 1; transition: all .15s;
    text-decoration: none;
}
.btn-clear-filters:hover {
    background: #fee2e2; border-color: var(--danger);
    color: var(--danger); text-decoration: none;
}
.btn-clear-filters[title] { position: relative; }

/* ===================== Search bar ===================== */
.search-bar {
    display: flex; gap: 8px; align-items: center;
    background: var(--white); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 6px 12px;
    margin-bottom: 16px; box-shadow: var(--shadow);
}
.search-bar input[type="text"] {
    border: none; outline: none; font-size: 14px;
    flex: 1; background: transparent; color: var(--text);
}
.search-bar input[type="text"]::placeholder { color: var(--text-muted); }
.search-jump { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* ===================== Role hint box ===================== */
.role-hint-box {
    background: var(--k2-accent); border: 1px solid #bfdbfe;
    border-radius: var(--radius); padding: 10px 14px;
    font-size: 13px; color: var(--k2-blue);
    margin-top: 8px;
}

/* ===================== Action badges (audit log) ===================== */
.action-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .3px;
    text-transform: uppercase;
    background: #e5e7eb;
    color: #374151;
    white-space: nowrap;
}
/* Greens — creation events */
.action-badge.action-ticket-created,
.action-badge.action-user-created,
.action-badge.action-company-created,
.action-badge.action-routing-rule-created {
    background: #dcfce7; color: #15803d;
}
/* Blues — update events */
.action-badge.action-ticket-updated,
.action-badge.action-user-updated,
.action-badge.action-company-updated,
.action-badge.action-status-changed,
.action-badge.action-ticket-assigned,
.action-badge.action-note-added,
.action-badge.action-portal-access-toggled {
    background: #dbeafe; color: #1d4ed8;
}
/* Oranges — toggled / state changes */
.action-badge.action-user-toggled,
.action-badge.action-ticket-reopened,
.action-badge.action-routing-rule-updated {
    background: #ffedd5; color: #c2410c;
}
/* Reds — deletions / security events */
.action-badge.action-user-deleted,
.action-badge.action-company-deleted,
.action-badge.action-login-failed,
.action-badge.action-attachment-deleted {
    background: #fee2e2; color: #b91c1c;
}
/* Purple — login / auth */
.action-badge.action-login-success,
.action-badge.action-logout {
    background: #ede9fe; color: #6d28d9;
}
/* Teal — email inbound / system events */
.action-badge.action-email-received,
.action-badge.action-email-sent,
.action-badge.action-email-check,
.action-badge.action-attachment-uploaded {
    background: #ccfbf1; color: #0f766e;
}
/* Sky blue — outbound email sends */
.action-badge.action-email-send {
    background: #e0f2fe; color: #075985;
}

/* ===================== Live refresh ===================== */
/* Pulsing green "Live" dot */
.live-indicator {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 11px; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: .4px;
    user-select: none;
}
.live-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: #22c55e;
    animation: live-pulse 2.5s ease-in-out infinite;
    flex-shrink: 0;
}
.live-dot.stale { background: #d97706; animation: none; }
@keyframes live-pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(34,197,94,.5); }
    50%       { opacity: .7; box-shadow: 0 0 0 5px rgba(34,197,94,0); }
}

/* New ticket row flash — yellow fade-out */
@keyframes row-flash-new {
    0%   { background-color: #fef3c7; }
    70%  { background-color: #fef9e7; }
    100% { background-color: transparent; }
}
.ticket-row-new { animation: row-flash-new 3s ease-out forwards; }

/* Metric value update flash */
@keyframes metric-pop {
    0%   { transform: scale(1.15); color: var(--k2-blue-light); }
    100% { transform: scale(1);    color: inherit; }
}
.metric-card.metric-updated .metric-value {
    animation: metric-pop 0.6s ease-out;
}

/* "New tickets" notification banner */
.new-tickets-banner {
    display: none;
    align-items: center; gap: 12px;
    background: #fef3c7; border: 1px solid #fbbf24;
    border-radius: var(--radius); padding: 10px 16px;
    margin-bottom: 12px; font-size: 13px; font-weight: 600; color: #92400e;
    cursor: pointer; transition: background .15s;
}
.new-tickets-banner:hover { background: #fde68a; }
.new-tickets-banner.visible { display: flex; }

/* ===================== Ticket Detail — Redesign ===================== */

/* ── Original email card ─────────────────────────────────────────── */
.email-origin-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-left: 4px solid var(--k2-blue-light);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 16px;
    cursor: pointer;
    transition: box-shadow .15s, border-color .15s;
    position: relative;
}
.email-origin-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,.12);
    border-color: var(--k2-blue);
}
.email-origin-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.email-origin-from { font-size: 13px; color: var(--text); }
.email-origin-date { font-size: 12px; margin-left: auto; }
.email-origin-body {
    font-size: 13px;
    color: var(--text);
    line-height: 1.55;
    max-height: 120px;
    overflow: hidden;
    position: relative;
    white-space: pre-wrap;
    word-break: break-word;
}
.email-origin-body::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 40px;
    background: linear-gradient(transparent, var(--white));
    pointer-events: none;
}
.email-origin-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}
.attachment-chip-sm {
    font-size: 11px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 2px 8px;
    color: var(--text-muted);
}
.email-origin-hint {
    position: absolute;
    bottom: 8px; right: 12px;
    font-size: 11px;
    color: var(--k2-blue-light);
    opacity: 0;
    transition: opacity .15s;
}
.email-origin-card:hover .email-origin-hint { opacity: 1; }

/* ── Thread sections (Email History / Notes & Activity) ──────────── */
.thread-section {
    margin-bottom: 16px;
}
.thread-section-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 6px 0 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}

/* ── Thread rows ─────────────────────────────────────────────────── */
.thread-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background .12s;
    border-bottom: 1px solid transparent;
}
.thread-row:hover { background: var(--k2-accent); }
.thread-row + .thread-row { border-top: 1px solid var(--border); }

.thread-row-icon {
    font-size: 16px;
    flex-shrink: 0;
    width: 22px;
    text-align: center;
}
.thread-row-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.thread-row-author {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.thread-row-preview {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.thread-row-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.thread-row-time {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}
.thread-attach-badge { font-size: 12px; }

/* Variant tints */
.thread-row-note-system { opacity: .75; }
.thread-row-note-system:hover { opacity: 1; }

/* ── Modal overlay ────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}
.modal-box {
    background: var(--white);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,.22);
    position: relative;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    width: 100%;
    overflow: hidden;
}
.modal-email { max-width: 680px; }
.modal-note  { max-width: 560px; }

.modal-close {
    position: absolute;
    top: 10px; right: 14px;
    background: none;
    border: none;
    font-size: 22px;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    z-index: 1;
}
.modal-close:hover { background: var(--bg); color: var(--text); }

/* ── Email modal headers ─────────────────────────────────────────── */
.email-modal-headers {
    border-bottom: 1px solid var(--border);
    padding: 16px 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex-shrink: 0;
    background: var(--bg);
    border-radius: 8px 8px 0 0;
}
.email-hdr-row {
    display: flex;
    gap: 10px;
    font-size: 13px;
    align-items: baseline;
}
.email-hdr-label {
    font-weight: 700;
    color: var(--text-muted);
    width: 56px;
    flex-shrink: 0;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.email-hdr-value {
    color: var(--text);
    word-break: break-word;
}
.email-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
}
.email-modal-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 20px 14px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}
.email-modal-attachments:empty { display: none; }

/* ── Note modal ───────────────────────────────────────────────────── */
.note-modal-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px 10px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--bg);
    border-radius: 8px 8px 0 0;
    flex-wrap: wrap;
}
.note-modal-author {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}
.note-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
}
