/* ============================================================
   Power Prism Admin — تصميم بهوية pp.ms
   ثيم داكن افتراضي (بني داكن + ذهبي #D5A15C) + زر تحويل للوضع الفاتح
   ============================================================ */

@font-face {
    font-family: "Ethnocentric";
    src: url("../fonts/ethnocentric.woff2") format("woff2");
    font-weight: 400 700;
    font-style: normal;
    font-display: block;
}

:root {
    --brand: #D5A15C;
    --brand-dark: #B9823F;
    --on-brand: #191310;

    --bs-primary: #D5A15C;
    --bs-primary-rgb: 213, 161, 92;
    --bs-border-radius: .875rem;
    --bs-border-radius-sm: .625rem;
    --bs-border-radius-lg: 1.25rem;
    --bs-body-font-family: "DM Sans", "Tajawal", system-ui, -apple-system, "Segoe UI", sans-serif;
    --bs-body-font-size: .95rem;
}

[data-bs-theme="dark"] {
    --panel-bg: #1B1612;
    --panel-surface: rgba(255, 255, 255, .035);
    --panel-surface-2: rgba(255, 255, 255, .06);
    --panel-border: rgba(241, 234, 223, .12);
    --brand-text: #D5A15C;
    --brand-soft: rgba(213, 161, 92, .12);
    --chart-android: #ff6a2b;
    --chart-ios: #3ddc84;
    --chart-red: #fb7185;
    --chart-track: #2a3852;
    --switch-off: #4A4034;

    --bs-body-bg: #1B1612;
    --bs-body-color: #F1EADF;
    --bs-secondary-color: #CBC2B4;
    --bs-border-color: rgba(241, 234, 223, .12);
    --bs-emphasis-color: #ffffff;
    --bs-tertiary-bg: rgba(255, 255, 255, .06);
    --bs-secondary-bg: rgba(255, 255, 255, .035);
}

[data-bs-theme="light"] {
    --panel-bg: #F7F3EA;
    --panel-surface: #ffffff;
    --panel-surface-2: #F0EADF;
    --panel-border: #E5DECD;
    --brand-text: #B9823F;
    --brand-soft: rgba(213, 161, 92, .16);
    --chart-android: #ff6a2b;
    --chart-ios: #12b76a;
    --chart-red: #e11d48;
    --chart-track: #e3e9f6;
    --switch-off: #D9D0BF;

    --bs-body-bg: #F7F3EA;
    --bs-body-color: #2A2521;
    --bs-secondary-color: #7A6F5F;
    --bs-border-color: #E5DECD;
    --bs-emphasis-color: #191310;
}

* { box-sizing: border-box; }

body {
    background: var(--panel-bg);
    letter-spacing: -.01em;
    -webkit-font-smoothing: antialiased;
}

[data-bs-theme="dark"] body {
    background: linear-gradient(180deg, #2A2521 0%, #0F0D0C 100%) fixed;
}

/* ---------- عناصر أساسية ---------- */

.card {
    background: var(--panel-surface);
    border: 1px solid var(--panel-border);
    border-radius: var(--bs-border-radius-lg);
}

.btn { font-weight: 600; }

.btn-primary {
    --bs-btn-bg: transparent;
    --bs-btn-border-color: rgba(213, 161, 92, .45);
    --bs-btn-color: var(--brand);
    --bs-btn-hover-bg: rgba(213, 161, 92, .12);
    --bs-btn-hover-border-color: var(--brand);
    --bs-btn-hover-color: var(--brand);
    --bs-btn-active-bg: rgba(213, 161, 92, .12);
    --bs-btn-active-border-color: var(--brand);
    --bs-btn-active-color: var(--brand);
    --bs-btn-disabled-bg: transparent;
    --bs-btn-disabled-border-color: rgba(213, 161, 92, .45);
    --bs-btn-disabled-color: var(--brand);
}

.btn-outline-secondary {
    --bs-btn-color: var(--bs-secondary-color);
    --bs-btn-border-color: var(--panel-border);
    --bs-btn-hover-bg: var(--panel-surface-2);
    --bs-btn-hover-border-color: var(--panel-border);
    --bs-btn-hover-color: var(--bs-body-color);
}

.btn-icon {
    --bs-btn-padding-x: 0;
    --bs-btn-padding-y: 0;
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: var(--bs-border-radius);
    color: var(--bs-secondary-color);
    background: transparent;
    font-size: 1.05rem;
}

.btn-icon:hover {
    color: var(--brand-text);
    background: var(--brand-soft);
}

.form-control,
.form-select {
    background: transparent;
    border-color: var(--panel-border);
    color: var(--bs-body-color);
    border-radius: var(--bs-border-radius);
}

.form-control:focus,
.form-select:focus {
    background: transparent;
    border-color: var(--brand);
    box-shadow: none;
    color: var(--bs-body-color);
}

.form-label {
    font-size: .8rem;
    font-weight: 600;
}

.shadow,
.shadow-sm,
.shadow-lg {
    box-shadow: none !important;
}

/* ---------- زر تبديل الثيم (شمس/قمر) ---------- */

.theme-btn .ico-moon { display: none; }

[data-bs-theme="dark"] .theme-btn .ico-sun { display: none; }
[data-bs-theme="dark"] .theme-btn .ico-moon { display: inline-block; }

/* ---------- صفحة الدخول ---------- */

.is-auth { background: var(--panel-bg); }

.auth-wrap {
    min-height: 100vh;
    width: 100%;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    border-radius: 1.75rem;
}

.auth-logo {
    width: 64px;
    height: 64px;
    display: grid;
    place-items: center;
    border-radius: 1.25rem;
    background: var(--brand);
    color: var(--on-brand);
    font-size: 1.65rem;
}

/* ---------- التنبيهات ---------- */

.pp-alert {
    border-radius: var(--bs-border-radius);
    padding: 12px 15px;
    font-size: .875rem;
    margin-bottom: 16px;
    text-align: start;
    border-inline-start: 3px solid transparent;
}

.pp-alert--error   { background: rgba(248, 113, 113, .12); color: #f87171; border-color: #f87171; }
.pp-alert--success { background: rgba(52, 211, 153, .12); color: #34d399; border-color: #34d399; }
.pp-alert--warn    { background: rgba(251, 191, 36, .12);  color: #fbbf24; border-color: #fbbf24; }

/* ---------- الواجهة بعد الدخول ---------- */

.dropdown-menu {
    --bs-dropdown-bg: var(--panel-surface);
    --bs-dropdown-border-color: var(--panel-border);
    --bs-dropdown-border-radius: 1.125rem;
    --bs-dropdown-link-hover-bg: var(--brand-soft);
    --bs-dropdown-link-hover-color: var(--brand-text);
    --bs-dropdown-link-active-bg: var(--brand-soft);
    --bs-dropdown-link-active-color: var(--brand-text);
    --bs-dropdown-item-padding-y: .55rem;
    --bs-dropdown-padding-x: .5rem;
    --bs-dropdown-padding-y: .5rem;
    box-shadow: none;
}

.dropdown-item {
    border-radius: .75rem;
    font-weight: 500;
}

.app-shell { min-height: 100vh; }

.app-sidebar {
    width: 264px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--panel-surface);
    border-inline-end: 1px solid var(--panel-border);
}

@media (min-width: 992px) {
    .app-sidebar {
        position: sticky;
        top: 0;
        align-self: flex-start;
        height: 100vh;
    }
}

.sidebar-brand {
    position: relative;
    height: 78px;
}

.brand-text {
    font-family: "Ethnocentric", "DM Sans", sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: .08em;
    direction: ltr;
    color: var(--bs-emphasis-color);
    cursor: default;
    user-select: none;
}

.brand-text:hover {
    color: var(--brand-text);
}

.app-nav {
    padding: 1rem 0;
    gap: 2px;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

.app-nav .nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: .8rem;
    width: 100%;
    padding: .8rem 1.6rem;
    border: 0;
    background: none;
    color: var(--bs-secondary-color);
    font-size: .95rem;
    font-weight: 500;
    text-align: start;
}

.app-nav .nav-link i { font-size: 1.05rem; }

.app-nav .nav-link:hover { color: var(--bs-body-color); }

.app-nav .nav-link.active {
    color: var(--brand-text);
    font-weight: 700;
}

.app-nav .nav-link.active::after {
    content: "";
    position: absolute;
    inset-inline-end: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 32px;
    border-radius: 4px 0 0 4px;
    background: var(--brand);
}

.app-nav .nav-group .caret {
    font-size: .8rem;
    transition: transform .2s;
}

.app-nav .nav-group[aria-expanded="true"] .caret { transform: rotate(180deg); }

.app-nav .nav-sub {
    padding-inline-start: 3rem;
    font-size: .9rem;
}

/* فوتر الشريط الجانبي — المستخدم + زر المظهر تحت بالزاوية */
.sidebar-footer {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-top: auto;
    padding: .85rem 1rem;
    border-top: 1px solid var(--panel-border);
}

.sidebar-footer .dropdown {
    flex: 1 1 auto;
    min-width: 0;
}

.sidebar-footer .btn-user {
    width: 100%;
    justify-content: flex-start;
    padding: .4rem .55rem;
}

.sidebar-footer .btn-user::after {
    margin-inline-start: auto;
}

.sidebar-footer .user-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-footer .theme-btn {
    flex-shrink: 0;
}

.sidebar-footer .dropdown-menu {
    min-width: 100%;
}

.app-topbar {
    height: 78px;
    padding: 0 1.75rem;
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--panel-bg);
}

.topbar-actions {
    display: none;
    align-items: center;
    gap: .35rem;
    background: var(--panel-surface);
    border-radius: 999px;
    padding: 5px 8px;
}

.btn-user {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    border: 0;
    border-radius: 999px;
    padding: .35rem .85rem;
    color: var(--bs-body-color);
    font-weight: 600;
    font-size: .9rem;
}

.btn-user:hover {
    background: var(--brand-soft);
    color: var(--bs-body-color);
}

.btn-user::after {
    margin-inline-start: .2rem;
    color: var(--bs-secondary-color);
}

.avatar {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: .7rem;
    background: var(--brand-soft);
    color: var(--brand-text);
    font-size: .85rem;
    font-weight: 700;
}

/* ---------- البحث في الصفحة ---------- */

.app-search [hidden] { display: none !important; }

.search-toggle { display: none; }

.app-search {
    position: relative;
    display: flex;
    align-items: center;
    gap: .55rem;
    width: 250px;
    height: 46px;
    padding: 0 1rem;
    border: 1px solid transparent;
    border-radius: 999px;
    background: var(--panel-surface);
    transition: border-color .2s ease;
}

.app-search:focus-within {
    border-color: var(--brand);
}

.app-search .bi-search {
    color: var(--bs-secondary-color);
    font-size: .95rem;
}

.app-search input {
    flex: 1 1 auto;
    min-width: 0;
    border: 0;
    outline: none;
    background: none;
    color: var(--bs-body-color);
    font-size: .9rem;
}

.search-clear {
    flex-shrink: 0;
    display: inline-grid;
    place-items: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--panel-surface-2);
    color: var(--bs-secondary-color);
    font-size: .7rem;
}

.search-clear:hover {
    background: var(--brand-soft);
    color: var(--brand-text);
}

.search-results {
    position: absolute;
    top: calc(100% + .6rem);
    inset-inline-end: 0;
    z-index: 40;
    width: min(420px, calc(100vw - 2.5rem));
    max-height: min(430px, 62vh);
    overflow-y: auto;
    padding: .5rem;
    border: 1px solid var(--panel-border);
    border-radius: 1.125rem;
    background: var(--panel-surface);
    animation: fade .18s ease both;
}

/* البحث جوّا الشريط الجانبي — فوق المستخدم مباشرة */
.app-sidebar .app-search {
    width: auto;
    height: 44px;
    margin: .25rem 1rem .6rem;
    flex-shrink: 0;
    background: var(--panel-bg);
    border-color: var(--panel-border);
}

.app-sidebar .app-search:focus-within {
    border-color: var(--brand);
}

.app-sidebar .search-results {
    top: auto;
    bottom: calc(100% + .6rem);
    width: 100%;
    max-height: min(380px, 60vh);
}

.search-item {
    display: flex;
    align-items: flex-start;
    gap: .7rem;
    width: 100%;
    padding: .65rem .75rem;
    border: 0;
    border-radius: .8rem;
    background: none;
    color: var(--bs-body-color);
    text-align: start;
}

.search-item + .search-item { margin-top: 1px; }

.search-item > .bi {
    margin-top: .2rem;
    color: var(--bs-secondary-color);
    font-size: .9rem;
}

.search-item:hover,
.search-item.is-active { background: var(--brand-soft); }

.search-item:hover > .bi,
.search-item.is-active > .bi { color: var(--brand-text); }

.search-item .s-main {
    flex: 1 1 auto;
    min-width: 0;
}

.search-item .s-snip {
    display: block;
    font-size: .85rem;
    line-height: 1.6;
}

.search-item mark {
    padding: 0 .15em;
    border-radius: .35em;
    background: transparent;
    color: var(--brand-text);
    font-weight: 700;
}

.search-item .s-type {
    display: inline-block;
    margin-top: .3rem;
    padding: .1rem .5rem;
    border-radius: 999px;
    background: var(--panel-surface-2);
    color: var(--bs-secondary-color);
    font-size: .68rem;
}

.search-empty {
    padding: 1.2rem .9rem;
    color: var(--bs-secondary-color);
    font-size: .875rem;
    text-align: center;
}

.search-foot {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem 1rem;
    justify-content: center;
    align-items: center;
    margin-top: .4rem;
    padding: .55rem .5rem .35rem;
    border-top: 1px solid var(--panel-border);
    color: var(--bs-secondary-color);
    font-size: .7rem;
}

.search-foot kbd {
    padding: 0 .35rem;
    border: 1px solid var(--panel-border);
    border-radius: .375rem;
    background: var(--panel-surface-2);
    color: var(--bs-secondary-color);
    font-size: .65rem;
}

/* تمييز أماكن النتائج داخل الصفحة */
.search-mark {
    outline: 2px solid rgba(213, 161, 92, .45);
    outline-offset: 3px;
    border-radius: .5rem;
}

.search-flash { animation: ppFlash 1.5s ease both; }

@keyframes ppFlash {
    0%   { box-shadow: 0 0 0 0 rgba(213, 161, 92, .55); }
    45%  { box-shadow: 0 0 0 7px rgba(213, 161, 92, .16); }
    100% { box-shadow: 0 0 0 0 rgba(213, 161, 92, 0); }
}

/* ---------- بطاقات الإحصاء (دونات أندرويد/iOS) ---------- */

.donut {
    position: relative;
    width: 100%;
    max-width: 158px;
    aspect-ratio: 1;
}

.donut svg {
    display: block;
    width: 100%;
    height: 100%;
}

.donut circle {
    fill: none;
    stroke-width: 24;
    stroke-linecap: butt;
}

.donut-track { stroke: var(--chart-track); }

/* فاصل رفيع بين اللونين — نفس العرض بالمكانين */
.donut-sep {
    stroke: var(--panel-bg);
    stroke-width: 3;
    pointer-events: none;
}

.donut-android { stroke: var(--chart-ios); }   /* Android = أخضر */
.donut-ios { stroke: var(--chart-android); }    /* iOS = برتقالي */

.donut-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.15;
    text-align: center;
    pointer-events: none;
}

.donut-value {
    color: var(--bs-emphasis-color);
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: -.02em;
}

.donut-label {
    color: var(--bs-secondary-color);
    font-size: .78rem;
    font-weight: 500;
}

.donut-sub {
    color: var(--bs-secondary-color);
    font-size: .76rem;
    line-height: 1;
}

.donut-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: .25rem 1rem;
    color: var(--bs-secondary-color);
    font-size: .78rem;
}

.lg-item {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
}

.lg-item b {
    color: var(--bs-emphasis-color);
    font-weight: 600;
}

.lg-dot {
    width: 9px;
    height: 9px;
    flex-shrink: 0;
    border-radius: 50%;
}

.lg-android { background: var(--chart-android); }
.lg-ios { background: var(--chart-ios); }

/* نقاط الليغند للدوائر — أندرويد أخضر / iOS برتقالي */
.lg-platform-android { background: var(--chart-ios); }
.lg-platform-ios { background: var(--chart-android); }

@media (max-width: 575.98px) {
    .donut { max-width: 126px; }
    .donut-value { font-size: 1.12rem; }
    .donut-label { font-size: .72rem; }
    .donut-legend { font-size: .72rem; gap: .15rem .7rem; }
}

/* ---------- تلميح الرسوم ---------- */

.chart-tip {
    position: fixed;
    z-index: 60;
    padding: .4rem .7rem;
    border: 1px solid var(--panel-border);
    border-radius: .6rem;
    background: var(--panel-surface);
    color: var(--bs-body-color);
    font-size: .78rem;
    font-weight: 600;
    direction: ltr;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 10px 24px rgba(10, 15, 25, .3);
}

.chart-tip .tip-title {
    margin-bottom: .15rem;
    color: var(--bs-secondary-color);
    font-size: .7rem;
    font-weight: 600;
}

.chart-tip .tip-row {
    font-size: .78rem;
    line-height: 1.55;
}

.chart-tip .tip-row b {
    margin-left: .4rem;
    color: var(--bs-emphasis-color);
    font-weight: 700;
}

.chart-tip .tip-key { font-weight: 600; }

.chart-tip .tt-bar { color: var(--chart-android); }
.chart-tip .tt-line { color: var(--chart-ios); }

/* ---------- رسوم بيانية مصغرة ---------- */

.mini-chart .chart-title {
    color: var(--bs-emphasis-color);
    font-size: .85rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: .55rem;
}

.mini-chart .chart-sub {
    margin-bottom: .35rem;
    color: var(--bs-secondary-color);
    font-size: .7rem;
    text-align: center;
}

/* صف الرأس: Android يمين — العنوان وسط — iOS يسار */
.mini-chart .chart-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .35rem;
    margin-bottom: .55rem;
}

.mini-chart .chart-head .chart-title {
    flex: 1 1 auto;
    margin-bottom: 0;
}

.mini-chart .ch-stat {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    white-space: nowrap;
    font-size: .72rem;
    font-weight: 600;
    color: var(--bs-secondary-color);
}

.mini-chart .ch-stat strong {
    color: var(--bs-emphasis-color);
    font-weight: 700;
}

.mini-chart .ch-stat .ch-dot {
    width: 7px;
    height: 7px;
    flex: 0 0 auto;
    border-radius: 50%;
}

/* أندرويد أخضر / iOS برتقالي — نفس ألوان الدوائر */
.mini-chart .ch-android .ch-dot { background: var(--chart-ios); }
.mini-chart .ch-ios .ch-dot { background: var(--chart-android); }

.mini-chart svg {
    display: block;
    width: 100%;
    height: auto;
}

.mini-chart .grid { stroke: var(--panel-border); }

.mini-chart .axis {
    fill: var(--bs-secondary-color);
    font-size: 7.5px;
}

.mini-chart .bar { fill: var(--chart-android); }

.mini-chart .hit {
    fill: transparent;
    stroke: none;
}

.mini-chart .line {
    fill: none;
    stroke: var(--chart-ios);
    stroke-width: 1.5;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.mini-chart .area {
    fill: var(--chart-ios);
    opacity: .12;
}

/* مخطط مشاهدات الإعلانات — مساحة/خط برتقالي (تخطيط مختلف) */
.mini-chart .line-main {
    stroke: var(--chart-android);
    stroke-width: 2;
}

.mini-chart .area-main {
    fill: var(--chart-android);
    opacity: .14;
}

/* مربع فاضي تحت أجهزة جديدة — بدون إحصائيات حالياً */
.empty-slot {
    min-height: 250px;
}

/* هياكل مخفية بضبط أحجام المربعات الفاضية (نفس مقاسات صفحة الإحصائيات) */
.empty-ghost .card-body { visibility: hidden; }

/* المربع الطويل الفاضي — بنفس طول عمود المنصات/الإصدارات/الطلبات بصفحة الإحصائيات */
.empty-tall { min-height: 668px; }

/* مربع بيانات وهوية التطبيق — حقول فاضية بقسمين */
.app-box .field {
    margin-bottom: .6rem;
}

.app-box .field:last-child {
    margin-bottom: 0;
}

/* مربعات قصيرة — صف حقول واحد بدون أقسام (معرّفات AdMob / عناوين CDN) */
.app-box .flat-fields {
    display: grid;
    gap: .8rem;
    flex: 1 1 auto;
    align-content: center;
}

.app-box .flat-fields > .field {
    margin-bottom: 0;
}

.app-box .flat-fields.cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.app-box .flat-fields.cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* مربع الإعلان والدعم — عناوين الأقسام + صفوف (حقل + زر/سويتش) */
.app-box .sec-title {
    display: flex;
    align-items: center;
    gap: .35rem;
    margin: .85rem 0 .5rem;
    font-size: .78rem;
    font-weight: 700;
    color: var(--bs-emphasis-color);
}

/* أيقونة توقيت الإعلان ⏱ — جنب عنوان «إعلان التطبيق» */
.app-box .sec-gear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--bs-secondary-color);
    font-size: .82rem;
    line-height: 1;
    cursor: pointer;
    transition: color .15s ease;
}

.app-box .sec-gear:hover,
.app-box .sec-gear:focus-visible {
    color: var(--brand);
}

.app-box .info-sec + .sec-title {
    margin-top: .5rem;
}

/* حقول بلا عنوان ظاهر — النص مخفي بصرياً، لكنه ضروري لمفتاح الحفظ */
.app-box .field-label.label-hidden {
    display: none;
}

.app-box .field-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap; /* لو العمود ضاق كتير، الزر بينزل سطر تحته بدل ما يضغط الحقل */
    gap: .5rem;
}

.app-box .field-row .form-control {
    flex: 1 1 0; /* أساس 0 — عشان عرض الرابط الطويل ما يكسّر السطر؛ الحقل بيتمدد حسب المتاح */
    min-width: 4.5rem;
}

.app-box .field-row .toggle-switch {
    flex: 0 0 auto;
}

.app-box .field-action {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 1.35rem;
    min-width: 2.5rem;
    padding: 0 .45rem;
    border-radius: 999px;
    font-size: .62rem;
    line-height: 1;
    white-space: nowrap;
}

/* مربع مفاتيح التحكم والإعلانات — قسمين أندرويد/iOS والمفاتيح أربعة تحت بعض */
.toggle-cols {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 1.4rem;
}

.toggle-col { min-width: 0; }

.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .35rem .7rem;
    padding: .55rem 0;
}

.toggle-row + .toggle-row {
    border-top: 1px solid var(--panel-border);
}

.toggle-name {
    display: block;
    color: var(--bs-emphasis-color);
    font-size: .78rem;
    font-weight: 700;
}

.toggle-sub {
    display: block;
    margin-top: .05rem;
    color: var(--bs-secondary-color);
    font-size: .66rem;
}

.toggle-ctl {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    flex: 0 0 auto;
}

/* مفتاح تشغيل — أخضر لما يشتغل */
.toggle-switch {
    position: relative;
    display: inline-flex;
    width: 2.5rem;
    height: 1.35rem;
    flex: 0 0 auto;
}

.toggle-switch input {
    appearance: none;
    -webkit-appearance: none;
    position: absolute;
    inset: 0;
    margin: 0;
    border: 0;
    border-radius: 999px;
    background-color: var(--switch-off);
    cursor: pointer;
    transition: background-color .18s ease;
}

.toggle-switch input:checked {
    background-color: var(--chart-ios);
}

.toggle-switch input:focus-visible {
    outline: 2px solid rgba(213, 161, 92, .45);
    outline-offset: 2px;
}

.toggle-knob {
    position: absolute;
    top: 50%;
    inset-inline-start: 3px;
    width: 1.05rem;
    height: 1.05rem;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .35);
    transform: translateY(-50%);
    pointer-events: none;
    transition: inset-inline-start .18s ease;
}

.toggle-switch input:checked + .toggle-knob {
    inset-inline-start: calc(100% - 1.05rem - 3px);
}

/* خط فاصل — بين مجموعات المفاتيح */
.toggle-divider {
    border: 0;
    border-top: 1px solid var(--panel-border);
    margin: 1rem 0 0;
    opacity: 1;
}

/* عنوان محركات المنصات — تحت الخط الفاصل */
.engines-title {
    margin-top: 1.15rem;
}

/* شريط الحفظ أعلى مربع المفاتيح */
.box-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .6rem;
    flex-wrap: wrap;
    padding-bottom: .75rem;
    border-bottom: 1px solid var(--panel-border);
    margin-bottom: .9rem;
}

/* أزرار الشريط الملزوقة جنب بعض (حفظ الإعدادات + تفعيل التقييمات) */
.box-actions .save-group {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    flex-wrap: wrap;
}

/* اختيار المنصة بنافذة تفعيل التقييمات (Android / iOS) */
.platform-choice {
    display: flex;
    gap: .5rem;
    margin-bottom: .9rem;
}

.platform-choice .choice-item {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    padding: .5rem .6rem;
    border: 1px solid var(--panel-border);
    border-radius: .7rem;
    cursor: pointer;
    font-size: .8rem;
    font-weight: 600;
    transition: border-color .15s ease, background-color .15s ease;
}

.platform-choice .choice-item input {
    margin: 0;
    accent-color: #D5A15C;
}

.platform-choice .choice-item:has(input:checked) {
    border-color: #D5A15C;
    background: rgba(213, 161, 92, .08);
}

.box-actions .save-btn {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .34rem .85rem;
    border-radius: .65rem;
    font-size: .74rem;
    white-space: nowrap;
}

/* زر الحفظ لما في تغييرات لسا ما انحفظت */
.save-btn.is-dirty {
    animation: savePulse 1.8s ease-in-out infinite;
}

@keyframes savePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(213, 161, 92, .5); }
    70% { box-shadow: 0 0 0 7px rgba(213, 161, 92, 0); }
}

.box-actions .last-save {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    color: var(--bs-secondary-color);
    font-size: .68rem;
    font-weight: 600;
}

/* أيقونة سجل التعديلات جنب التاريخ */
.log-btn {
    border: 0;
    background: transparent;
    color: var(--bs-secondary-color);
    padding: 0;
    font-size: .8rem;
    line-height: 1;
    cursor: pointer;
}

.log-btn:hover {
    color: var(--brand-text);
}

/* نافذة سجل التعديلات */
#logModal .modal-content {
    background: var(--panel-surface);
    border: 1px solid var(--panel-border);
}

#logModal .log-entry {
    position: relative;
    padding-block: .55rem;
    padding-inline-end: 1.7rem;
}

#logModal .log-entry + .log-entry {
    border-top: 1px solid var(--panel-border);
}

#logModal .log-del {
    position: absolute;
    top: .5rem;
    inset-inline-end: 0;
    border: 0;
    background: transparent;
    color: var(--bs-secondary-color);
    padding: .1rem;
    font-size: .78rem;
    line-height: 1;
    cursor: pointer;
}

#logModal .log-del:hover {
    color: var(--chart-red);
}

#logModal .log-time {
    margin-bottom: .3rem;
    color: var(--brand-text);
    font-size: .7rem;
    font-weight: 700;
}

#logModal .log-list {
    margin: 0;
    padding-inline-start: 1.1rem;
}

#logModal .log-list li {
    margin-bottom: .15rem;
    color: var(--bs-body-color);
    font-size: .72rem;
}

/* الحقول تتوزع وتعبّي المربع كامل مثل المربعات يلي فوق */
.app-box .card-body {
    display: flex;
    flex-direction: column;
}

.app-box .info-cols {
    flex: 1 1 auto;
}

.app-box .info-col {
    justify-content: space-between;
}

.app-box .field-label {
    display: block;
    margin-bottom: .25rem;
    color: var(--bs-secondary-color);
    font-size: .68rem;
    font-weight: 600;
}

.app-box .form-control {
    height: auto;
    font-size: .75rem;
    padding: .3rem .55rem;
}

/* حقل الرابط — "app/" داخل نفس المربع */
.app-box .field-input {
    display: flex;
    align-items: stretch;
    overflow: hidden;
    border: 1px solid var(--panel-border);
    border-radius: var(--bs-border-radius);
}

.app-box .field-input:focus-within {
    border-color: var(--brand);
}

.app-box .field-input .input-prefix {
    display: inline-flex;
    align-items: center;
    padding-inline: .55rem .1rem;
    color: var(--bs-secondary-color);
    font-size: .75rem;
    user-select: none;
}

.app-box .field-input .form-control {
    flex: 1 1 auto;
    min-width: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    padding-inline-start: .15rem;
}

/* مربع المعلومات — قسمين: أندرويد + أبل */
.info-box .card-body {
    display: flex;
    flex-direction: column;
}

.info-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    flex: 1 1 auto;
}

.info-col {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.info-col:first-child {
    padding-inline-end: .7rem;
}

.info-col + .info-col {
    padding-inline-start: .7rem;
}

.info-sec {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    margin-bottom: .5rem;
    color: var(--bs-emphasis-color);
    font-size: .78rem;
    font-weight: 700;
}

.info-list {
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: .4rem;
}

.info-list li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .1rem .4rem;
    padding: .3rem .5rem;
    border-radius: .65rem;
    background: var(--panel-bg);
    min-width: 0;
}

.info-label {
    color: var(--bs-secondary-color);
    font-size: .67rem;
    font-weight: 600;
}

.info-value {
    color: var(--bs-emphasis-color);
    font-size: .78rem;
    font-weight: 700;
}

.info-mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .62rem;
}

.info-badge {
    display: inline-flex;
    align-items: center;
    gap: .28rem;
    padding: .1rem .45rem;
    border-radius: 999px;
    font-size: .67rem;
    font-weight: 700;
}

.info-badge::before {
    content: "";
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
}

.info-badge.is-on {
    color: var(--chart-ios);
    background: rgba(61, 220, 132, .14);
}

[data-bs-theme="light"] .info-badge.is-on {
    background: rgba(18, 183, 106, .12);
}

.info-badge.is-off {
    color: var(--bs-secondary-color);
    background: var(--panel-surface-2);
}

[data-bs-theme="light"] .info-badge.is-off {
    background: #e9edf7;
}

/* شبكة صناديق المخططات — الصفوف بتتساوى بالطول (المربع الفاضي = مشاهدات الإعلانات) */
.stack-grid {
    display: grid;
    gap: 1rem;
}

.stack-grid > * { min-width: 0; }

.stack-grid > * > .card { height: 100%; }

@media (min-width: 992px) {
    .stack-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-template-rows: auto auto 1fr;
        height: 100%;
    }
    .stack-grid > .stack-wide { grid-column: 1 / -1; }
}

.mini-chart .dot {
    display: none;
    stroke: var(--panel-surface);
    stroke-width: 1.2;
    pointer-events: none;
}

.mini-chart .slot:hover .dot { display: block; }

.mini-chart .dot-green { fill: var(--chart-ios); }

.mini-chart .chart-legend {
    justify-content: center;
    margin-top: .5rem;
    font-size: .7rem;
}

/* ---------- أعمدة أفقية (المنصات/الإصدارات) ---------- */

.hbar {
    --hbar-name-w: 108px;
    --hbar-gap: 16px;
    direction: ltr;
    max-width: 860px;
    margin: 0 auto;
}

.hbar-row,
.hbar-ticks {
    display: grid;
    grid-template-columns: var(--hbar-name-w) minmax(0, 1fr);
    gap: var(--hbar-gap);
    align-items: center;
}

.hbar-row + .hbar-row { margin-top: .6rem; }

.hbar-name {
    overflow: hidden;
    color: var(--bs-secondary-color);
    font-size: .8rem;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hbar-track {
    min-width: 0;
    height: 14px;
}

.hbar-fill {
    display: block;
    height: 100%;
    min-width: 2px;
    border-radius: 5px;
    background: var(--chart-ios);
    transition: filter .15s ease;
}

.hbar-row:hover .hbar-fill { filter: brightness(1.12); }

.hbar-ticks { margin-top: .55rem; }

.hbar-ticktrack {
    display: flex;
    justify-content: space-between;
    color: var(--bs-secondary-color);
    font-size: .72rem;
}

@media (max-width: 575.98px) {
    .hbar-name { font-size: .72rem; }
    .hbar-ticktrack { font-size: .66rem; }
}

.app-content {
    padding: 1.5rem 1.75rem 2.5rem;
    animation: fade .3s ease both;
}

.min-width-0 { min-width: 0; }

@keyframes fade {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
}

/* ---------- الجوال ---------- */

@media (max-width: 991.98px) {
    .app-topbar {
        height: 66px;
        padding: 0 .875rem;
        gap: .5rem;
    }

    .app-topbar .h4 { font-size: 1.05rem; }

    .topbar-actions { display: flex; padding: 4px 6px; }

    .search-toggle { display: inline-flex; }

    .app-content { padding: .25rem .875rem 2rem; }

    .app-sidebar { width: 280px; }

    .card-body { padding: 1.1rem; }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

*,
*::before,
*::after {
    box-shadow: none !important;
    text-shadow: none !important;
}

