:root {
    --atc-primary: #0F766E;
    --atc-secondary: #0EA5A4;
    --atc-dark: #0F172A;
    --atc-success: #16A34A;
    --atc-warning: #F59E0B;
    --atc-danger: #DC2626;
    --atc-bg: #F8FAFC;
    --atc-card-bg: #FFFFFF;
    --atc-text: #0F172A;
    --atc-text-muted: #64748B;
    --atc-border: #E2E8F0;
    --atc-sidebar-bg: #0F172A;
    --atc-sidebar-active: #0F766E;
    --sidebar-width: 260px;
    --topbar-height: 72px;
}

[data-theme="dark"] {
    --atc-bg: #0B1220;
    --atc-card-bg: #131C2E;
    --atc-text: #E2E8F0;
    --atc-text-muted: #94A3B8;
    --atc-border: #24304A;
    --atc-sidebar-bg: #0B1220;
}

html[dir="rtl"] body { font-family: "Cairo", "Tajawal", sans-serif; }
html[dir="ltr"] body { font-family: "Inter", sans-serif; }

body {
    background: var(--atc-bg);
    color: var(--atc-text);
    font-size: 14px;
}

a { text-decoration: none; }

/* ===== Topbar ===== */
.atc-topbar {
    height: var(--topbar-height);
    background: var(--atc-card-bg);
    border-bottom: 1px solid var(--atc-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.atc-topbar .search-box {
    max-width: 420px;
    width: 100%;
}

.atc-topbar .search-box input {
    border-radius: 10px;
    background: var(--atc-bg);
    border: 1px solid var(--atc-border);
}

.atc-user-chip { display: flex; align-items: center; gap: 10px; }
.atc-user-chip img {
    width: 42px; height: 42px; border-radius: 50%; object-fit: cover;
}
.atc-user-chip .name { font-weight: 700; font-size: 14px; color: var(--atc-text); }
.atc-user-chip .role { font-size: 12px; color: var(--atc-text-muted); }

.atc-icon-btn {
    width: 40px; height: 40px; border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--atc-bg); border: 1px solid var(--atc-border);
    color: var(--atc-text); position: relative;
}
.atc-icon-btn:hover { background: var(--atc-border); }
.atc-icon-btn .badge-dot {
    position: absolute; top: -6px; inset-inline-end: -6px;
    background: var(--atc-success); color: #fff; font-size: 10px;
    min-width: 18px; height: 18px; border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 4px; font-weight: 700;
}

.atc-logo-block { text-align: end; line-height: 1.1; }
.atc-logo-block .brand { font-weight: 800; font-size: 20px; color: var(--atc-primary); }
.atc-logo-block .brand span { color: var(--atc-dark); }
[data-theme="dark"] .atc-logo-block .brand span { color: #E2E8F0; }
.atc-logo-block .tagline { font-size: 11px; color: var(--atc-text-muted); }
.atc-logo-icon {
    width: 42px; height: 42px; border-radius: 12px;
    background: linear-gradient(135deg, var(--atc-secondary), var(--atc-primary));
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff; font-size: 18px;
}

/* ===== Layout shell ===== */
.atc-shell { display: flex; min-height: 100vh; }

.atc-sidebar {
    width: var(--sidebar-width);
    background: var(--atc-sidebar-bg);
    color: #CBD5E1;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    transition: margin .2s ease;
}
.atc-sidebar.collapsed { margin-inline-start: calc(var(--sidebar-width) * -1); }

.atc-sidebar .nav-link {
    color: #CBD5E1;
    padding: 11px 18px;
    margin: 2px 12px;
    border-radius: 10px;
    font-size: 14px;
    display: flex; align-items: center; gap: 12px;
    justify-content: space-between;
}
.atc-sidebar .nav-link .link-main { display: flex; align-items: center; gap: 12px; }
.atc-sidebar .nav-link i.icon { width: 18px; text-align: center; color: #94A3B8; }
.atc-sidebar .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.atc-sidebar .nav-link.active {
    background: var(--atc-sidebar-active);
    color: #fff;
    font-weight: 700;
}
.atc-sidebar .nav-link.active i.icon { color: #fff; }
.atc-sidebar .nav-section-title {
    font-size: 11px; color: #64748B; padding: 16px 20px 6px; text-transform: uppercase; letter-spacing: .05em;
}

.atc-main { flex-grow: 1; min-width: 0; max-width: 100%; overflow-x: hidden; }
.atc-content { padding: 24px; max-width: 100%; }
.atc-card { max-width: 100%; overflow-x: hidden; }
.atc-card .table-responsive { overflow-x: auto; }

.atc-filter-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.atc-filter-bar .form-select {
    border-radius: 10px; border: 1px solid var(--atc-border); background: var(--atc-card-bg); color: var(--atc-text);
    font-size: 13px; padding: 8px 14px;
}

.atc-page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.atc-page-header h1 { font-size: 26px; font-weight: 800; margin: 0; }
.atc-page-header p { color: var(--atc-text-muted); margin: 4px 0 0; font-size: 14px; }

/* ===== Cards ===== */
.atc-card {
    background: var(--atc-card-bg);
    border: 1px solid var(--atc-border);
    border-radius: 16px;
    padding: 20px;
    height: 100%;
}
.atc-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.atc-card-header h3 { font-size: 16px; font-weight: 700; margin: 0; }

.atc-stat-card { display: flex; flex-direction: column; gap: 14px; }
.atc-stat-icon {
    width: 46px; height: 46px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.atc-stat-value { font-size: 26px; font-weight: 800; }
.atc-stat-label { font-size: 13px; color: var(--atc-text-muted); }
.atc-stat-trend { font-size: 12px; display: flex; align-items: center; gap: 6px; }
.atc-stat-trend.up { color: var(--atc-success); }
.atc-stat-trend.down { color: var(--atc-danger); }
.atc-stat-trend .muted { color: var(--atc-text-muted); }

.atc-legend-item { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; font-size: 13px; }
.atc-legend-item .dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-inline-end: 8px; }
.atc-legend-item .pct { font-weight: 700; margin-inline-end: 6px; }

.atc-donut-total { text-align: center; }
.atc-donut-total .value { font-size: 20px; font-weight: 800; }
.atc-donut-total .label { font-size: 12px; color: var(--atc-text-muted); }

.atc-org-row { margin-bottom: 14px; }
.atc-org-row .top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.atc-org-row .bar-bg { background: var(--atc-border); border-radius: 6px; height: 8px; overflow: hidden; }
.atc-org-row .bar-fg { height: 100%; border-radius: 6px; background: var(--atc-primary); }

.atc-alert-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--atc-border); }
.atc-alert-item:last-child { border-bottom: none; }
.atc-alert-icon { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.atc-alert-text { font-size: 13px; }
.atc-alert-time { font-size: 11px; color: var(--atc-text-muted); }

.atc-mini-card { border: 1px solid var(--atc-border); border-radius: 12px; padding: 14px; }
.atc-mini-card .icon { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; margin-bottom: 10px; }
.atc-mini-card .value { font-size: 18px; font-weight: 800; }
.atc-mini-card .label { font-size: 12px; color: var(--atc-text-muted); }

.atc-footer {
    display: flex; justify-content: space-between; padding: 16px 24px; color: var(--atc-text-muted); font-size: 12px;
    border-top: 1px solid var(--atc-border);
}

@media (max-width: 991px) {
    .atc-sidebar { position: fixed; z-index: 1040; margin-inline-start: calc(var(--sidebar-width) * -1); }
    .atc-sidebar.show { margin-inline-start: 0; }
}

/* ===== Health Card visual ===== */
.atc-health-card {
    width: 100%;
    max-width: 440px;
    min-height: 230px;
    border-radius: 20px;
    background: linear-gradient(135deg, #0F172A 0%, var(--atc-primary) 100%);
    color: #fff;
    padding: 22px 24px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(15, 23, 42, .25);
}
.atc-health-card::before {
    content: "";
    position: absolute; inset-inline-end: -60px; top: -60px;
    width: 200px; height: 200px; border-radius: 50%;
    background: rgba(255,255,255,.06);
}
.atc-health-card .hc-top { display: flex; justify-content: space-between; align-items: flex-start; }
.atc-health-card .hc-brand { display: flex; align-items: center; gap: 8px; }
.atc-health-card .hc-brand-icon {
    width: 30px; height: 30px; border-radius: 8px; background: rgba(255,255,255,.15);
    display: flex; align-items: center; justify-content: center; font-size: 13px;
}
.atc-health-card .hc-brand-name { font-weight: 800; font-size: 15px; }
.atc-health-card .hc-qr { background: #fff; padding: 6px; border-radius: 10px; width: 74px; height: 74px; }
.atc-health-card .hc-qr img { width: 100%; height: 100%; }
.atc-health-card .hc-member-no { font-size: 11px; opacity: .75; margin-top: 18px; }
.atc-health-card .hc-name { font-size: 19px; font-weight: 800; margin-top: 4px; }
.atc-health-card .hc-bottom { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 22px; }
.atc-health-card .hc-field-label { font-size: 10px; opacity: .7; }
.atc-health-card .hc-field-value { font-size: 13px; font-weight: 700; }
.atc-health-card .hc-status-badge {
    position: absolute; top: 20px; inset-inline-start: 24px;
    font-size: 10px; padding: 3px 10px; border-radius: 20px; font-weight: 700;
}
