@import url("https://fonts.googleapis.com/css2?family=Ubuntu:wght@300;400;500;700&family=Vazirmatn:wght@300;400;500;700&display=swap");

:root {
    --bg: #F2F2F2;
    --surface: #ffffff;
    --surface-raised: #ffffff;
    --ink: #0E2940;
    --muted: rgba(14, 41, 64, 0.7);
    --quiet: rgba(14, 41, 64, 0.48);
    --accent: #265FAB;
    --accent-strong: #204F8C;
    --danger: #E80F06;
    --gold: #F9D746;
    --sand: #F3E3C6;
    --success: #265FAB;
    --warning: #204F8C;
    --border: rgba(14, 41, 64, 0.14);
    --shadow: 0 1px 2px rgba(14, 41, 64, 0.08), 0 8px 24px rgba(14, 41, 64, 0.08);
    --focus: 0 0 0 3px rgba(38, 95, 171, 0.22);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { color-scheme: light; }
body {
    min-height: 100vh;
    font-family: "Ubuntu", "Vazirmatn", "Segoe UI", sans-serif;
    font-weight: 300;
    background:
        linear-gradient(90deg, rgba(14, 41, 64, 0.04) 0 1px, transparent 1px 100%) 0 0 / 24px 24px,
        linear-gradient(180deg, rgba(38, 95, 171, 0.1), transparent 260px),
        var(--bg);
    color: var(--ink);
    letter-spacing: -0.01em;
}

button, input, select { font: inherit; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 0; box-shadow: var(--focus); }
button:disabled { opacity: 0.62; cursor: wait; }

.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 14px;
    padding: 10px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 2px rgba(14, 41, 64, 0.08);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { display: inline-flex; align-items: center; justify-content: center; font-size: 24px; line-height: 1; }
.brand h1 { font-size: 18px; font-weight: 500; letter-spacing: -0.03em; white-space: nowrap; }
.brand h1::after {
    content: "EXECUTIVE";
    display: inline-flex;
    margin-left: 8px;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(38, 95, 171, 0.1);
    color: var(--accent-strong);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    vertical-align: middle;
}

.updated-note { color: var(--quiet); font-size: 12px; font-weight: 400; white-space: nowrap; }
.refresh-btn {
    min-height: 34px;
    padding: 7px 14px;
    border: 1px solid var(--accent);
    border-radius: 6px;
    background: var(--accent);
    color: #F2F2F2;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}
.refresh-btn:hover { background: var(--accent-strong); border-color: var(--accent-strong); }

.container { max-width: 1460px; margin: 0 auto; padding: 22px 22px 44px; }
.chart-card, .stat-card, .table-wrap, .modal {
    background: var(--surface-raised);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.page-head { margin: 0 0 10px 0; padding: 0; }

.refresh-hint {
    margin: 8px 0 0 2px;
    color: var(--quiet);
    font-size: 12px;
    line-height: 1.45;
}

.section-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--accent-strong);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.section-label::before { content: ""; width: 3px; height: 16px; border-radius: 3px; background: var(--accent); }
.section-head { display: flex; align-items: center; gap: 10px; margin: 12px 0; }
.section-head.compact { margin-top: 18px; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.stat-card {
    position: relative;
    min-height: 132px;
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 12px;
    overflow: hidden;
}
.stat-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--accent); }
.stat-card::after { content: ""; position: absolute; inset: auto 12px 12px auto; width: 44px; height: 4px; border-radius: 99px; background: rgba(38, 95, 171, 0.12); }
.stat-card.warning::before { background: var(--warning); }
.stat-card.danger::before { background: var(--danger); }
.stat-card.success::before { background: var(--success); }
.stat-card.clickable, .status-item.clickable { cursor: pointer; transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease; }
.stat-card.clickable:hover { transform: translateY(-1px); border-color: var(--accent); box-shadow: 0 8px 24px rgba(38, 95, 171, 0.14); }
.stat-label, .stat-foot { position: relative; z-index: 1; color: var(--muted); font-size: 12px; font-weight: 500; }
.stat-foot { color: var(--quiet); font-weight: 400; }
.stat-value { position: relative; z-index: 1; font-size: clamp(32px, 4vw, 48px); font-weight: 500; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-card.warning .stat-value { color: var(--warning); }
.stat-card.danger .stat-value { color: var(--danger); }
.stat-card.success .stat-value { color: var(--success); }

.charts-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.chart-card { position: relative; overflow: hidden; border-radius: 8px; padding: 16px; }
.chart-card.full-width { margin-bottom: 14px; }
.chart-card.compact-chart { padding-bottom: 10px; }
.chart-card.compact-chart canvas { max-height: 240px; }
.chart-card.small-chart canvas { max-height: 220px; }
.chart-card h3, .modal-head h3 { color: var(--ink); font-size: 14px; font-weight: 500; }
.chart-card h3 { margin-bottom: 4px; }
.chart-timestamp { display: block; margin-bottom: 12px; color: var(--quiet); font-size: 11px; font-weight: 400; }
canvas { max-width: 100%; }

.table-wrap { overflow-x: auto; border-radius: 8px; box-shadow: none; }
.scroll-table { max-height: 500px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--border); text-align: left; color: var(--muted); font-size: 13px; vertical-align: middle; }
th { position: relative; color: var(--ink); background: rgba(242, 242, 242, 0.8); font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.scroll-table thead th { position: sticky; top: 0; z-index: 1; }
tbody tr:hover { background: rgba(38, 95, 171, 0.05); }
.subject-cell { max-width: 360px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.ticket-link { color: var(--accent); font-weight: 500; text-decoration: none; font-variant-numeric: tabular-nums; }
.ticket-link:hover { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 3px; }

.priority-badge { display: inline-flex; align-items: center; min-height: 22px; padding: 2px 8px; border-radius: 4px; font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; }
.priority-p1 { background: rgba(232, 15, 6, 0.1); color: var(--danger); }
.priority-p2 { background: rgba(32, 79, 140, 0.1); color: var(--accent-strong); }
.priority-p3 { background: rgba(38, 95, 171, 0.09); color: var(--accent); }
.priority-p4 { background: rgba(14, 41, 64, 0.07); color: var(--muted); }

.pagination { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 14px; }
.pagination button, .export-btn { min-height: 32px; padding: 6px 11px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--ink); font-size: 12px; font-weight: 500; cursor: pointer; }
.pagination button:hover, .export-btn:hover { border-color: var(--accent); color: var(--accent); }

.modal-overlay[hidden] { display: none; }
.modal-overlay { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(14, 41, 64, 0.54); backdrop-filter: blur(4px); }
.modal { width: min(1120px, 100%); max-height: 86vh; display: flex; flex-direction: column; padding: 18px; border-radius: 8px; }
.modal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.result-count { color: var(--muted); font-size: 13px; }
.modal-search { min-height: 32px; min-width: min(280px, 100%); margin-left: auto; padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--ink); font-size: 13px; }
.modal-close { width: 32px; height: 32px; border: 1px solid var(--border); border-radius: 6px; background: rgba(242, 242, 242, 0.78); color: var(--muted); cursor: pointer; font-size: 22px; line-height: 1; }
.modal-close:hover { color: var(--danger); border-color: var(--danger); }
.modal-table { max-height: 60vh; }

.stat-value.loading { color: transparent !important; min-width: 70px; border-radius: 6px; background: linear-gradient(90deg, rgba(242, 242, 242, 0.75) 25%, rgba(14, 41, 64, 0.1) 50%, rgba(242, 242, 242, 0.75) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.empty-note { padding: 40px 0; color: var(--quiet); font-size: 13px; text-align: center; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: 0.001ms !important; }
}
@media (max-width: 1180px) { .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 980px) { .charts-row { grid-template-columns: 1fr; } .stat-card { min-height: 112px; } }
@media (max-width: 720px) {
    .navbar { display: flex; flex-wrap: wrap; gap: 10px; padding: 10px 12px; }
    .brand { width: 100%; }
    .updated-note { width: 100%; }
    .refresh-btn { flex: 1 1 140px; }
    .container { padding: 16px 12px 30px; }
    .stats-grid { grid-template-columns: 1fr; }
    .modal-overlay { padding: 12px; align-items: flex-start; }
    .modal-head { flex-wrap: wrap; }
    .modal-search { margin-left: 0; flex: 1 1 100%; }
    th, td { padding: 10px 11px; }
}
