/* ========== ONE Tracking - Clean RTL Design ========== */

:root {
    --primary: #0b3d91;
    --primary-hover: #082c6b;
    --accent: #14b8a6;
    --danger: #dc2626;
    --warning: #d97706;
    --success: #16a34a;
    --info: #0284c7;

    --bg: #f4f6fb;
    --surface: #ffffff;
    --border: #e5e7eb;
    --border-strong: #cbd5e1;

    --text: #0f172a;
    --text-muted: #64748b;
    --text-soft: #94a3b8;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 10px 28px rgba(15, 23, 42, 0.12);

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;

    --header-h: 60px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f172a;
        --surface: #1e293b;
        --border: #334155;
        --border-strong: #475569;
        --text: #f1f5f9;
        --text-muted: #94a3b8;
        --text-soft: #64748b;
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    font-size: 15px;
    line-height: 1.6;
}

body { min-height: 100vh; display: flex; flex-direction: column; }

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

/* ========== Top Nav ========== */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    height: var(--header-h);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.topbar-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 16px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 18px;
    color: var(--text);
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px; height: 32px;
    background: var(--primary);
    color: white;
    border-radius: var(--radius-sm);
    font-size: 16px;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.nav-links a {
    padding: 8px 12px;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 14px;
    transition: all 0.15s;
}

.nav-links a:hover {
    background: var(--bg);
    color: var(--primary);
}

.nav-links a.cta {
    background: var(--primary);
    color: white;
}
.nav-links a.cta:hover { background: var(--primary-hover); color: white; }

.nav-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-inline-start: 16px;
    padding-inline-start: 16px;
    border-inline-start: 1px solid var(--border);
}

.nav-user-name { font-size: 13px; color: var(--text-muted); }
.logout-link { font-size: 13px; color: var(--danger); }

.menu-toggle {
    display: none;
    background: none;
    border: none;
    width: 32px; height: 32px;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    padding: 0;
}
.menu-toggle span {
    display: block;
    height: 2px;
    background: var(--text);
    border-radius: 1px;
}

@media (max-width: 900px) {
    .menu-toggle { display: flex; }
    .nav-links {
        position: absolute;
        top: var(--header-h);
        inset-inline-start: 0;
        inset-inline-end: 0;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        flex-direction: column;
        align-items: stretch;
        padding: 12px;
        gap: 4px;
        display: none;
        box-shadow: var(--shadow);
    }
    .nav-links.open { display: flex; }
    .nav-links a { padding: 12px; }
    .nav-user {
        margin-inline-start: 0;
        padding-inline-start: 0;
        border: none;
        border-top: 1px solid var(--border);
        margin-top: 8px;
        padding-top: 12px;
        justify-content: space-between;
    }
}

/* ========== Container / Layout ========== */
.container {
    flex: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px 16px 40px;
    width: 100%;
}

.footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    text-align: center;
    padding: 16px;
    color: var(--text-muted);
    font-size: 13px;
}

/* ========== Flashes ========== */
.flashes { margin-bottom: 16px; }
.flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 8px;
    font-size: 14px;
    border-inline-start: 4px solid;
    background: var(--surface);
}
.flash-success { border-color: var(--success); }
.flash-danger  { border-color: var(--danger); }
.flash-warning { border-color: var(--warning); }
.flash-info    { border-color: var(--info); }

/* ========== Page Headers ========== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
    flex-wrap: wrap;
}

.page-title {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin: 4px 0 0;
}

/* ========== Cards ========== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

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

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.card-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
}

/* ========== Stats Grid ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s, box-shadow 0.15s;
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.stat-label {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
}

.stat-card.primary  { border-top: 3px solid var(--primary); }
.stat-card.success  { border-top: 3px solid var(--success); }
.stat-card.warning  { border-top: 3px solid var(--warning); }
.stat-card.danger   { border-top: 3px solid var(--danger); }
.stat-card.info     { border-top: 3px solid var(--info); }
.stat-card.accent   { border-top: 3px solid var(--accent); }

/* ========== Forms ========== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group.full { grid-column: 1 / -1; }

.form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.form-label .req { color: var(--danger); margin-inline-start: 3px; }

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(11, 61, 145, 0.12);
}

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

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
}

.form-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    flex-wrap: wrap;
}

/* ========== Buttons ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}

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

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

.btn-success { background: var(--success); color: white; }
.btn-success:hover { filter: brightness(0.92); color: white; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { filter: brightness(0.92); color: white; }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 14px 24px; font-size: 16px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ========== Tables ========== */
.table-wrap { overflow-x: auto; margin: -8px; padding: 8px; }

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    font-size: 14px;
}

.table th {
    text-align: start;
    padding: 12px 14px;
    background: var(--bg);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}

.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--bg); }

/* ========== Badges ========== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: var(--bg);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.badge-new       { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }
.badge-assigned  { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.badge-in_progress { background: #fed7aa; color: #9a3412; border-color: #fb923c; }
.badge-report_ready { background: #ddd6fe; color: #5b21b6; border-color: #a78bfa; }
.badge-closed    { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.badge-cancelled { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }

.badge-urgent    { background: #fee2e2; color: #991b1b; }
.badge-high      { background: #ffedd5; color: #9a3412; }
.badge-normal    { background: #dbeafe; color: #1e40af; }
.badge-low       { background: #f1f5f9; color: #475569; }

/* ========== Login page ========== */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary) 0%, var(--info) 100%);
    padding: 20px;
}

.auth-card {
    background: var(--surface);
    padding: 32px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
}

.auth-title {
    text-align: center;
    margin: 0 0 8px;
    font-size: 24px;
}

.auth-sub {
    text-align: center;
    color: var(--text-muted);
    margin: 0 0 24px;
    font-size: 14px;
}

/* ========== Timeline (client portal) ========== */
.timeline {
    display: flex;
    flex-direction: column;
    gap: 0;
    position: relative;
    padding: 8px 0;
}

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

.timeline-step:not(:last-child)::before {
    content: '';
    position: absolute;
    top: 40px;
    inset-inline-start: 15px;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.timeline-step.done:not(:last-child)::before {
    background: var(--success);
}

.timeline-dot {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--border);
    color: white;
    font-weight: 700;
    z-index: 1;
    flex-shrink: 0;
}

.timeline-step.done .timeline-dot { background: var(--success); }

.timeline-content { flex: 1; }
.timeline-label { font-weight: 600; }
.timeline-time { font-size: 12px; color: var(--text-muted); }

/* ========== Utility ========== */
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.text-end { text-align: end; }
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.d-flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px dashed var(--border);
    gap: 12px;
    font-size: 14px;
}
.detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--text-muted); font-weight: 500; }
.detail-value { font-weight: 600; text-align: end; }

.avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.empty h3 { font-size: 16px; margin: 8px 0; }

.image-thumb {
    max-width: 100%;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

/* Import Cairo font */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800&display=swap');

/* ========== v2 additions ========== */

/* Brand logo */
.brand-logo {
    height: 32px;
    width: 32px;
    object-fit: cover;
    border-radius: 6px;
}

/* Notification bell */
.nav-notif {
    position: relative;
    margin-inline-start: 12px;
}

.notif-bell {
    background: none;
    border: 1px solid var(--border);
    border-radius: 999px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    position: relative;
    font-size: 18px;
    transition: background 0.15s;
}
.notif-bell:hover { background: var(--bg); }

.notif-badge {
    position: absolute;
    top: -4px;
    inset-inline-end: -4px;
    background: var(--danger);
    color: white;
    border-radius: 999px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.notif-panel {
    display: none;
    position: absolute;
    top: 50px;
    inset-inline-end: 0;
    width: 360px;
    max-width: 90vw;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    max-height: 500px;
    overflow: hidden;
    display: none;
    flex-direction: column;
}
.notif-panel.open { display: flex; }

.notif-panel-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.notif-list {
    overflow-y: auto;
    flex: 1;
    max-height: 380px;
}

.notif-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
    transition: background 0.15s;
}
.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: rgba(11, 61, 145, 0.04); border-inline-start: 3px solid var(--primary); }
.notif-item .notif-icon { font-size: 20px; }
.notif-item .notif-title { font-weight: 600; font-size: 13px; }
.notif-item .notif-body { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.notif-item .notif-time { color: var(--text-soft); font-size: 11px; margin-top: 4px; }

.notif-see-all {
    display: block;
    text-align: center;
    padding: 12px;
    border-top: 1px solid var(--border);
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
}

/* Scanner */
.scanner-wrap {
    max-width: 500px;
    margin: 0 auto;
}
#reader {
    width: 100%;
    border-radius: var(--radius);
    overflow: hidden;
    border: 2px solid var(--border);
}
#reader video { border-radius: var(--radius); }

/* SLA */
.sla-ok       { color: var(--success); }
.sla-warning  { color: var(--warning); }
.sla-breached { color: var(--danger); font-weight: 700; }
.sla-na       { color: var(--text-soft); }

/* Star rating */
.star-rate {
    display: inline-flex;
    flex-direction: row-reverse;
    gap: 4px;
}
.star-rate input[type=radio] { display: none; }
.star-rate label {
    cursor: pointer;
    font-size: 40px;
    color: #d1d5db;
    transition: color 0.15s;
}
.star-rate input:checked ~ label,
.star-rate label:hover,
.star-rate label:hover ~ label {
    color: #fbbf24;
}

/* Charts container */
.chart-container {
    position: relative;
    height: 260px;
    padding: 8px;
}
.chart-empty {
    height: 244px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-soft);
    font-size: 14px;
    background: repeating-linear-gradient(45deg, var(--bg), var(--bg) 10px, #eef2f9 10px, #eef2f9 20px);
    border-radius: var(--radius);
}

/* Comment thread */
.comment {
    padding: 12px;
    background: var(--bg);
    border-radius: var(--radius);
    margin-bottom: 8px;
    border-inline-start: 3px solid var(--primary);
}
.comment-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.comment-body { white-space: pre-wrap; }

/* Settings sidebar */
.settings-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 20px;
}
@media (max-width: 760px) {
    .settings-layout { grid-template-columns: 1fr; }
}
.settings-nav {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px;
    height: fit-content;
}
.settings-nav a {
    display: block;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 2px;
}
.settings-nav a:hover { background: var(--bg); }
.settings-nav a.active { background: var(--primary); color: white; }

/* Permission grid */
.perm-group {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 12px;
}
.perm-group-title {
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--primary);
}
.perm-check {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px;
    cursor: pointer;
    font-size: 14px;
}
.perm-check:hover { background: var(--surface); }

/* Rating display */
.rating-stars {
    color: #fbbf24;
    font-size: 20px;
}

/* ========== LTR support (English) ========== */
html[dir="ltr"] body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
}
html[dir="ltr"] .nav-user-name,
html[dir="ltr"] .brand-text {
    /* keep original */
}

.lang-toggle {
    background: rgba(255, 255, 255, 0.1);
    padding: 6px 10px;
    border-radius: 6px;
    text-decoration: none;
    color: inherit;
    font-size: 13px;
    font-weight: 600;
    margin-inline-start: 8px;
    transition: background 0.15s;
}
.lang-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Dual rating layout */
.rating-section {
    padding: 20px;
    background: var(--bg);
    border-radius: var(--radius);
    margin-bottom: 20px;
    border-inline-start: 4px solid var(--primary);
}
.rating-section h3 {
    margin: 0 0 12px 0;
    color: var(--primary);
}

/* ========== Modern Dashboard KPI Cards ========== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 12px;
    margin-bottom: 22px;
}
.kpi-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    color: var(--text);
    position: relative;
    overflow: hidden;
    transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
    cursor: pointer;
}
.kpi-card::before {
    content: "";
    position: absolute;
    inset-inline-start: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--kpi-color, var(--primary));
    opacity: 0.85;
}
.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--kpi-color, var(--primary));
    color: var(--text);
}
.kpi-card:focus { outline: none; }
.kpi-card:focus-visible {
    outline: none;
    border-color: var(--kpi-color, var(--primary));
    box-shadow: 0 0 0 3px var(--kpi-tint, rgba(11, 61, 145, 0.15));
}
.kpi-icon {
    font-size: 30px;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--kpi-tint, rgba(11, 61, 145, 0.08));
    border-radius: 12px;
    flex-shrink: 0;
}
.kpi-body { flex: 1; min-width: 0; }
.kpi-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 4px;
}
.kpi-value {
    font-size: 26px;
    font-weight: 800;
    color: var(--text);
    line-height: 1.1;
}
.kpi-arrow {
    font-size: 18px;
    color: var(--text-soft);
    opacity: 0;
    transition: opacity 0.18s, transform 0.18s;
}
.kpi-card:hover .kpi-arrow { opacity: 1; transform: translateX(-4px); }
html[dir="ltr"] .kpi-card:hover .kpi-arrow { transform: translateX(4px); }

.kpi-primary { --kpi-color: #0b3d91; --kpi-tint: rgba(11, 61, 145, 0.10); }
.kpi-accent  { --kpi-color: #14b8a6; --kpi-tint: rgba(20, 184, 166, 0.12); }
.kpi-warning { --kpi-color: #d97706; --kpi-tint: rgba(217, 119, 6, 0.12); }
.kpi-danger  { --kpi-color: #dc2626; --kpi-tint: rgba(220, 38, 38, 0.12); }
.kpi-success { --kpi-color: #16a34a; --kpi-tint: rgba(22, 163, 74, 0.12); }
.kpi-info    { --kpi-color: #0284c7; --kpi-tint: rgba(2, 132, 199, 0.12); }

/* Quick action pills */
.quick-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}
.qa-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 96px;
    padding: 12px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    font-weight: 600;
    transition: all 0.15s;
}
.qa-btn span:first-child { font-size: 24px; }
.qa-btn small { font-size: 12px; color: var(--text-muted); }
.qa-btn:hover {
    border-color: var(--primary);
    background: var(--bg);
    transform: translateY(-2px);
    color: var(--text);
}

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--border);
    flex-wrap: wrap;
}
.tab {
    padding: 10px 18px;
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s;
    border-radius: 6px 6px 0 0;
}
.tab:hover { color: var(--primary); background: var(--bg); }
.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: var(--bg);
}

/* Task rows for tech dashboard */
.task-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    background: var(--surface);
    transition: border-color 0.15s;
}
.task-row:hover { border-color: var(--primary); }
.task-row-main { flex: 1; min-width: 200px; }
.task-row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Follow-up items */
.followup-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
    background: var(--surface);
    gap: 12px;
    flex-wrap: wrap;
}
.followup-scheduled { border-inline-start: 4px solid var(--info); }
.followup-done { border-inline-start: 4px solid var(--success); opacity: 0.7; }
.followup-cancelled { border-inline-start: 4px solid var(--danger); opacity: 0.5; text-decoration: line-through; }

.followup-form {
    background: var(--bg);
    padding: 14px;
    border-radius: var(--radius);
    border: 1px dashed var(--border-strong);
}

/* Image lightbox */
.clickable-image {
    cursor: zoom-in;
    transition: opacity 0.15s;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.clickable-image:hover { opacity: 0.85; }

.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
    cursor: zoom-out;
    animation: fadeIn 0.2s;
}
.lightbox-overlay.open { display: flex; }
.lightbox-overlay img {
    max-width: 96vw;
    max-height: 92vh;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.lightbox-close {
    position: absolute;
    top: 20px;
    inset-inline-end: 20px;
    background: rgba(255,255,255,0.15);
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 22px;
    cursor: pointer;
    transition: background 0.15s;
}
.lightbox-close:hover { background: rgba(255,255,255,0.3); }

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Table hover */
.table-hover tbody tr:hover { background: var(--bg); }

/* Portal request link rows */
.request-row-link {
    display: block;
    text-decoration: none;
    color: inherit;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}
.request-row-link:hover { background: var(--bg); color: inherit; }

/* Badge status colors (ensure) */
.badge-open, .badge-new { background: #dbeafe; color: #1e40af; }
.badge-in_progress { background: #fed7aa; color: #9a3412; }
.badge-report_ready { background: #ddd6fe; color: #5b21b6; }
.badge-assigned { background: #fef3c7; color: #92400e; }
.badge-resolved { background: #bbf7d0; color: #166534; }
.badge-closed { background: #d1fae5; color: #065f46; }
.badge-cancelled { background: #fecaca; color: #991b1b; }
.badge-urgent { background: #fee2e2; color: #b91c1c; }
.badge-high { background: #ffedd5; color: #c2410c; }
.badge-normal { background: #e0e7ff; color: #3730a3; }
.badge-low { background: #f1f5f9; color: #475569; }

@media (max-width: 640px) {
    .kpi-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
    .kpi-card { padding: 14px; }
    .kpi-icon { width: 42px; height: 42px; font-size: 24px; }
    .kpi-value { font-size: 22px; }
    .quick-actions { justify-content: center; }
}

/* Follow-up scheduling form grid */
.followup-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1.5fr;
    gap: 12px;
    align-items: end;
}
@media (max-width: 640px) {
    .followup-grid { grid-template-columns: 1fr; }
}

/* ========== Print styles ========== */
.print-only { display: none; }

@media print {
    /* Hide interactive chrome */
    .topbar, .footer, .menu-toggle, .nav-notif, .nav-user, .lang-toggle,
    #installBtn, .no-print, .flashes, .lightbox-overlay,
    form.d-flex, .page-header form, .page-header .btn, .btn,
    .quick-actions, details summary {
        display: none !important;
    }

    /* Reset layout for paper */
    body { background: #fff !important; color: #000 !important; font-size: 12pt; }
    .container { max-width: 100% !important; padding: 0 !important; margin: 0 !important; }
    .card, .kpi-card {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
        break-inside: avoid;
        background: #fff !important;
        color: #000 !important;
    }
    .kpi-grid { display: grid !important; grid-template-columns: repeat(4, 1fr) !important; }
    .table { width: 100% !important; border-collapse: collapse !important; }
    .table th, .table td { border: 1px solid #ccc !important; color: #000 !important; padding: 6px 8px !important; }
    .badge { border: 1px solid #999 !important; color: #000 !important; background: #fff !important; }
    a { color: #000 !important; text-decoration: none !important; }
    .page-title, .card-title, .detail-label, .detail-value, p, span, td, th, h1, h2, h3, strong {
        color: #000 !important;
    }
    .chart-container { display: none !important; }  /* canvas charts don't print well */

    /* Print-only header on every printed page */
    .print-only { display: block !important; }
    .print-header {
        text-align: center;
        border-bottom: 2px solid #000;
        padding-bottom: 8px;
        margin-bottom: 16px;
    }
    .print-header .ph-company { font-size: 18pt; font-weight: 800; }
    .print-header .ph-sub { font-size: 11pt; color: #333 !important; }

    @page { margin: 1.4cm; }
}

/* Footer contact row */
.footer-contact {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 6px;
}
.footer-contact a { color: var(--text-muted); font-size: 13px; }
.footer-contact a:hover { color: var(--primary); }
