/* ─────────────────────────────────────────────
   Diyar Admin Panel — Stylesheet
───────────────────────────────────────────── */

:root {
    --c-bg:           #F4F1FB;
    --c-bg-2:         #ECE6F8;
    --c-card:         #FFFFFF;
    --c-text:         #1F1640;
    --c-text-soft:    #5A4D85;
    --c-text-muted:   #8C82AB;
    --c-primary:      #5B3FBF;
    --c-primary-2:    #7A5BFF;
    --c-primary-soft: #EDE7FB;
    --c-pink:         #FF6FAE;
    --c-blue:         #5BC0FF;
    --c-green:        #22C55E;
    --c-red:          #E94B6F;
    --c-amber:        #F59E0B;
    --c-border:       #E4DEF3;
    --c-sidebar-bg:   #1F1640;
    --c-sidebar-bg-2: #2C1A66;

    --r-sm:  10px;
    --r-md:  14px;
    --r-lg:  20px;
    --r-xl:  28px;

    --shadow-sm: 0 2px 6px rgba(31, 22, 64, 0.05);
    --shadow:    0 8px 24px rgba(31, 22, 64, 0.08);
    --shadow-lg: 0 16px 48px rgba(91, 63, 191, 0.18);

    --sidebar-w: 260px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    font-family: 'Peyda', system-ui, -apple-system, 'Segoe UI', sans-serif;
    color: var(--c-text);
    background: var(--c-bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body {
    min-height: 100vh;
    background:
        radial-gradient(1200px 600px at 100% -10%, rgba(122, 91, 255, 0.10), transparent 60%),
        radial-gradient(1000px 500px at -10% 100%, rgba(255, 111, 174, 0.08), transparent 60%),
        var(--c-bg);
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; }
svg { width: 100%; height: 100%; display: block; }

/* ───── Auth pages (setup, login) ───── */

.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(800px 400px at 50% 0%,  rgba(255, 111, 174, 0.18), transparent 60%),
        radial-gradient(900px 500px at 0% 100%, rgba(122, 91, 255, 0.18), transparent 60%),
        radial-gradient(900px 500px at 100% 100%, rgba(91, 192, 255, 0.12), transparent 60%),
        var(--c-bg);
}

.auth-shell {
    width: 100%;
    max-width: 520px;
}

.auth-card {
    background: var(--c-card);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-lg);
    padding: 36px 32px;
    border: 1px solid var(--c-border);
}

.auth-header { text-align: center; margin-bottom: 28px; }

.auth-logo {
    width: 64px;
    height: 64px;
    margin: 0 auto 18px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--c-primary-2), var(--c-primary));
    color: #fff;
    box-shadow: 0 12px 28px rgba(91, 63, 191, 0.45);
}

.auth-logo svg { width: 32px; height: 32px; }

.auth-header h1 {
    font-size: 22px;
    font-weight: 800;
    color: var(--c-text);
    margin-bottom: 6px;
}

.auth-header p {
    color: var(--c-text-muted);
    font-size: 13.5px;
    font-weight: 500;
}

/* Stepper */
.stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 24px;
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    opacity: 0.5;
    transition: opacity 0.3s;
}

.step.active, .step.done { opacity: 1; }

.step-num {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--c-primary-soft);
    color: var(--c-primary);
    font-weight: 800;
    display: grid;
    place-items: center;
    font-size: 14px;
    border: 2px solid transparent;
    transition: all 0.3s;
}

.step.active .step-num {
    background: var(--c-primary);
    color: #fff;
    box-shadow: 0 8px 18px rgba(91, 63, 191, 0.35);
}

.step.done .step-num {
    background: var(--c-green);
    color: #fff;
}

.step-label {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--c-text-soft);
}

.step-line {
    width: 60px;
    height: 2px;
    background: var(--c-border);
    margin-bottom: 18px;
    transition: background 0.3s;
}

.step-line.done { background: var(--c-green); }

/* Forms (auth) */
.auth-form { display: flex; flex-direction: column; gap: 16px; }

.form-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 14px;
}

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

.form-group label {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--c-text-soft);
}

.form-group input,
.form-group textarea {
    padding: 13px 14px;
    border: 1.5px solid var(--c-border);
    border-radius: var(--r-md);
    font-size: 14px;
    font-weight: 600;
    color: var(--c-text);
    background: #fff;
    transition: border-color 0.18s, box-shadow 0.18s;
    width: 100%;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 4px rgba(91, 63, 191, 0.10);
}

.form-group input[dir="ltr"] { letter-spacing: 0.4px; }

.form-hint {
    font-size: 11.5px;
    color: var(--c-text-muted);
    line-height: 1.7;
    margin-top: -4px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 20px;
    border-radius: var(--r-md);
    font-size: 14.5px;
    font-weight: 800;
    transition: transform 0.15s, box-shadow 0.2s, opacity 0.2s;
    cursor: pointer;
}

.btn svg { width: 18px; height: 18px; }

.btn-primary {
    background: linear-gradient(135deg, var(--c-primary-2), var(--c-primary));
    color: #fff;
    box-shadow: 0 12px 28px rgba(91, 63, 191, 0.40);
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 16px 36px rgba(91, 63, 191, 0.50); }
.btn-primary:active { transform: translateY(0); }

.btn-soft {
    background: var(--c-primary-soft);
    color: var(--c-primary);
    padding: 10px 16px;
    font-size: 13px;
}
.btn-soft:hover { background: #E0D6F8; }

.btn-pink {
    background: linear-gradient(135deg, var(--c-pink), #C24A8C);
    color: #fff;
    box-shadow: 0 12px 28px rgba(255, 111, 174, 0.40);
}
.btn-pink:hover { transform: translateY(-1px); box-shadow: 0 16px 36px rgba(255, 111, 174, 0.50); }
.btn-pink:active { transform: translateY(0); }

.btn[disabled] { opacity: 0.6; cursor: not-allowed; transform: none !important; }

/* Alerts */
.alert {
    padding: 12px 14px;
    border-radius: var(--r-md);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 16px;
    line-height: 1.7;
}

.alert-success {
    background: #DCFCE7;
    color: #166534;
    border: 1px solid #86EFAC;
}

.alert-danger {
    background: #FEE2E2;
    color: #991B1B;
    border: 1px solid #FECACA;
}

/* ───── Main layout ───── */

.layout {
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
}

.sidebar {
    background: linear-gradient(180deg, var(--c-sidebar-bg), var(--c-sidebar-bg-2));
    color: #fff;
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 6px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--c-primary-2), var(--c-pink));
    display: grid;
    place-items: center;
    box-shadow: 0 8px 18px rgba(122, 91, 255, 0.55);
    color: #fff;
}
.brand-mark svg { width: 22px; height: 22px; }

.brand-title {
    font-size: 17px;
    font-weight: 900;
    color: #fff;
}

.brand-sub {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.55);
    font-weight: 600;
    margin-top: 2px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1 1 auto;
    min-height: 0;        /* required for flex child to shrink */
    overflow-y: auto;     /* scroll when items don't fit (mobile / many sections) */
    overflow-x: hidden;
    /* Slimmer scrollbar so it doesn't clash with the dark sidebar */
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.18) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.18);
    border-radius: 3px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.32); }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--r-md);
    font-size: 13.5px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.72);
    transition: background 0.18s, color 0.18s;
    cursor: pointer;
}

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.nav-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(122, 91, 255, 0.35), rgba(255, 111, 174, 0.25));
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

/* Unread/pending counter on nav items (e.g., support tickets needing
   admin reply). Pushed to the far edge of the row, pulses softly so the
   admin notices without the badge being visually loud. */
.nav-badge {
    margin-inline-start: auto;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    background: linear-gradient(135deg, #FF4D6D, #C9184A);
    color: #fff;
    font-size: 11px;
    font-weight: 900;
    line-height: 22px;
    text-align: center;
    box-shadow:
        0 0 0 2px rgba(255, 77, 109, 0.22),
        0 4px 10px rgba(201, 24, 74, 0.45);
    animation: navBadgePulse 2.2s ease-in-out infinite;
}
@keyframes navBadgePulse {
    0%, 100% { box-shadow: 0 0 0 2px rgba(255, 77, 109, 0.22), 0 4px 10px rgba(201, 24, 74, 0.45); }
    50%      { box-shadow: 0 0 0 5px rgba(255, 77, 109, 0.08), 0 4px 12px rgba(201, 24, 74, 0.55); }
}

.sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 14px;
}

.user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: var(--r-md);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--c-primary-2), var(--c-pink));
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 800;
    text-transform: uppercase;
}

.user-info { flex: 1; min-width: 0; }
.user-name {
    font-size: 13px;
    font-weight: 800;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-role {
    font-size: 10.5px;
    color: rgba(255, 255, 255, 0.55);
    font-weight: 600;
}

.logout-btn {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.7);
    display: grid;
    place-items: center;
    transition: background 0.18s, color 0.18s;
}

.logout-btn:hover { background: rgba(233, 75, 111, 0.25); color: #fff; }
.logout-btn svg { width: 16px; height: 16px; }

/* Sidebar overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(31, 22, 64, 0.5);
    backdrop-filter: blur(2px);
    z-index: 90;
}

.sidebar-overlay.open { display: block; }

/* Main content */
.main {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    background: rgba(244, 241, 251, 0.85);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    padding: 16px 28px;
    display: flex;
    align-items: center;
    gap: 14px;
    border-bottom: 1px solid var(--c-border);
}

.menu-toggle {
    display: none;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--c-card);
    border: 1px solid var(--c-border);
    color: var(--c-text);
    align-items: center;
    justify-content: center;
}
.menu-toggle svg { width: 20px; height: 20px; }

.page-title {
    font-size: 17px;
    font-weight: 800;
    color: var(--c-text);
}

.content {
    flex: 1;
    padding: 28px;
    max-width: 1180px;
    margin: 0 auto;
    width: 100%;
}

/* ───── Dashboard ───── */

.welcome-card {
    background: linear-gradient(135deg, var(--c-primary), var(--c-primary-2));
    border-radius: var(--r-xl);
    padding: 28px;
    color: #fff;
    box-shadow: 0 18px 48px rgba(91, 63, 191, 0.30);
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    overflow: hidden;
    position: relative;
}

.welcome-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(400px 200px at 100% 0%, rgba(255, 111, 174, 0.4), transparent 60%);
    pointer-events: none;
}

.welcome-text { position: relative; }
.welcome-text h2 {
    font-size: 24px;
    font-weight: 900;
    margin-bottom: 6px;
}
.welcome-text p {
    color: rgba(255, 255, 255, 0.85);
    font-size: 13.5px;
    font-weight: 500;
}

.welcome-mark {
    width: 96px;
    height: 96px;
    color: rgba(255, 255, 255, 0.18);
    flex-shrink: 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--c-card);
    border: 1px solid var(--c-border);
    border-radius: var(--r-lg);
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow-sm);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    color: #fff;
    flex-shrink: 0;
}

.stat-icon svg { width: 22px; height: 22px; }

.stat-icon-purple { background: linear-gradient(135deg, var(--c-primary-2), var(--c-primary)); }
.stat-icon-pink   { background: linear-gradient(135deg, var(--c-pink),     #C24A8C); }
.stat-icon-blue   { background: linear-gradient(135deg, var(--c-blue),     #2E8FCC); }

.stat-body { flex: 1; min-width: 0; }
.stat-label { font-size: 12px; color: var(--c-text-muted); font-weight: 700; margin-bottom: 4px; }
.stat-value { font-size: 16px; color: var(--c-text); font-weight: 800; }

.stat-value.state-on { color: var(--c-green); }
.stat-value.state-off { color: var(--c-amber); }

.info-card {
    background: #FFF8E1;
    border: 1px solid #F9D77F;
    border-radius: var(--r-lg);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.info-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--c-amber);
    color: #fff;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}
.info-icon svg { width: 22px; height: 22px; }

.info-body { flex: 1; }
.info-title { font-weight: 800; color: #78350F; font-size: 14.5px; margin-bottom: 4px; }
.info-text  { font-size: 12.5px; color: #92400E; line-height: 1.7; }

/* ───── Settings / Cards ───── */

.settings-form { max-width: 760px; }

.card {
    background: var(--c-card);
    border: 1px solid var(--c-border);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    padding: 22px;
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid var(--c-border);
}

.card-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--c-primary-2), var(--c-primary));
    color: #fff;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    box-shadow: 0 10px 22px rgba(91, 63, 191, 0.30);
}
.card-icon svg { width: 22px; height: 22px; }

.card-icon.icon-pink {
    background: linear-gradient(135deg, var(--c-pink), #C24A8C);
    box-shadow: 0 10px 22px rgba(255, 111, 174, 0.35);
}

.card-footer-split {
    justify-content: space-between;
    gap: 10px;
}

.test-result:empty { display: none; }
.test-result { margin-top: 14px; }
.test-result .alert { margin-bottom: 0; }

/* ───── Modal ───── */

.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: none;
}

.modal.open { display: block; }

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(31, 22, 64, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    animation: m-fade 0.22s ease;
}

.modal-card {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--c-card);
    border-radius: var(--r-xl);
    width: min(480px, calc(100vw - 32px));
    max-height: calc(100vh - 64px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 24px 64px rgba(31, 22, 64, 0.30);
    animation: m-pop 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}

/* Forms inside modals wrap header+body+footer; without making the form
   itself a flex column, the inner modal-body can't claim flex:1 + scroll. */
.modal-card > form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    max-height: 100%;
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 20px 22px 18px;
    border-bottom: 1px solid var(--c-border);
    flex-shrink: 0;
}

.modal-title-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--c-pink), #C24A8C);
    color: #fff;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    box-shadow: 0 8px 18px rgba(255, 111, 174, 0.35);
}
.modal-icon svg { width: 20px; height: 20px; }

.modal-header h3 {
    font-size: 16px;
    font-weight: 800;
    color: var(--c-text);
    margin-bottom: 2px;
}
.modal-header p {
    font-size: 12px;
    color: var(--c-text-muted);
    font-weight: 500;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    color: var(--c-text-muted);
    display: grid;
    place-items: center;
    transition: background 0.18s, color 0.18s;
    flex-shrink: 0;
}
.modal-close:hover { background: var(--c-primary-soft); color: var(--c-primary); }
.modal-close svg { width: 18px; height: 18px; }

.modal-body {
    padding: 20px 22px;
    overflow-y: auto;
    overscroll-behavior: contain;
    flex: 1 1 auto;
    min-height: 0;
}

.modal-footer {
    padding: 14px 22px;
    background: #FAFAFA;
    border-top: 1px solid var(--c-border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-shrink: 0;
}

.modal-footer .btn { padding: 11px 18px; font-size: 13.5px; }

@keyframes m-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes m-pop {
    from { opacity: 0; transform: translate(-50%, -46%) scale(0.95); }
    to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@keyframes m-sheet {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

@media (max-width: 480px) {
    .modal-card {
        top: auto;
        bottom: 0;
        left: 0;
        transform: none;
        width: 100%;
        max-width: 100%;
        max-height: 90vh;
        border-radius: 24px 24px 0 0;
        animation: m-sheet 0.30s cubic-bezier(0.32, 0.72, 0, 1);
    }
    .modal-header { padding: 18px 18px 14px; }
    .modal-body   { padding: 16px 18px; }
    .modal-footer { padding: 14px 18px; }
}

/* ───── Sidebar nav section heading ───── */

.nav-section {
    color: rgba(255, 255, 255, 0.45);
    font-size: 10.5px;
    font-weight: 800;
    text-transform: none;
    padding: 14px 14px 6px;
    letter-spacing: 0.4px;
}

/* ───── Items management (slides, ai-tools, popular-tools) ───── */

.section-title {
    font-size: 14px;
    font-weight: 800;
    color: var(--c-text);
    margin: 8px 0 14px;
    padding-top: 14px;
    border-top: 1px dashed var(--c-border);
}

.section-title:first-child {
    border-top: none;
    padding-top: 0;
}

.empty-state {
    padding: 40px 20px;
    text-align: center;
    background: var(--c-primary-soft);
    color: var(--c-primary);
    border-radius: var(--r-md);
    font-size: 13px;
    font-weight: 600;
}

.info-collapsible {
    background: #FFF8E1;
    border: 1px solid #F9D77F;
    border-radius: var(--r-md);
    padding: 0;
    margin-bottom: 18px;
}

.info-collapsible summary {
    padding: 12px 16px;
    cursor: pointer;
    font-weight: 800;
    font-size: 13px;
    color: #78350F;
    list-style: none;
    user-select: none;
}
.info-collapsible summary::-webkit-details-marker { display: none; }
.info-collapsible summary::before {
    content: '▼';
    margin-left: 8px;
    font-size: 10px;
    transition: transform 0.2s;
    display: inline-block;
}
.info-collapsible[open] summary::before {
    transform: rotate(180deg);
}

.info-collapsible-body {
    padding: 0 16px 14px;
    font-size: 12.5px;
    line-height: 1.9;
    color: #78350F;
}
.info-collapsible-body p { margin-bottom: 8px; }
.info-collapsible-body code {
    background: rgba(255, 255, 255, 0.6);
    padding: 1px 6px;
    border-radius: 4px;
    font-family: 'Menlo', 'Consolas', monospace;
    font-size: 11.5px;
    direction: ltr;
    display: inline-block;
}
.info-collapsible-body ul {
    margin-top: 6px;
    margin-right: 20px;
}
.info-collapsible-body li { margin-bottom: 4px; }

select {
    padding: 13px 14px;
    border: 1.5px solid var(--c-border);
    border-radius: var(--r-md);
    font-size: 14px;
    font-weight: 600;
    color: var(--c-text);
    background: #fff;
    width: 100%;
    cursor: pointer;
    transition: border-color 0.18s, box-shadow 0.18s;
    font-family: inherit;
}
select:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 4px rgba(91, 63, 191, 0.10);
}

.toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    margin-top: 26px;
}
.toggle-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--c-primary);
}

/* ═══════════════════════════════════════════════════════════════
   ANNOUNCEMENTS PAGE — admin broadcasts to users
   ═══════════════════════════════════════════════════════════════ */
.announcement-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.announcement-row {
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: 14px;
    padding: 14px 16px;
    box-shadow: 0 4px 12px rgba(91, 63, 191, 0.05);
}
.announcement-row-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.announcement-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 14.5px;
    font-weight: 800;
    color: var(--c-text);
    flex: 1;
    min-width: 0;
}
.announcement-date {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11.5px;
    color: var(--c-text-muted);
    font-weight: 700;
    flex-shrink: 0;
}
.announcement-date svg { width: 12px; height: 12px; }
.announcement-body {
    background: #fafafe;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 13.5px;
    line-height: 1.95;
    color: var(--c-text);
    white-space: pre-wrap;
    word-break: break-word;
    margin-bottom: 10px;
}
.announcement-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}
.announcement-actions .btn-sm svg,
.announcement-actions .icon-btn svg { width: 14px; height: 14px; }
.announcement-actions .icon-btn { width: 32px; height: 32px; }

/* ═══════════════════════════════════════════════════════════════
   SUPPORT PAGE — user-submitted questions / issues
   ═══════════════════════════════════════════════════════════════ */
.support-tickets {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.support-ticket {
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: 16px;
    padding: 18px;
    box-shadow: 0 4px 14px rgba(91, 63, 191, 0.05);
    transition: box-shadow 0.18s, border-color 0.18s;
}
.support-ticket:hover { box-shadow: 0 8px 22px rgba(91, 63, 191, 0.10); }

/* "new" tickets stand out with a soft purple bar on the right */
.support-ticket-new {
    border-right: 4px solid var(--c-primary);
    background: linear-gradient(to left, #fafafe, #fff);
}
.support-ticket-resolved {
    opacity: 0.85;
    background: #fafafe;
}

.support-ticket-header {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    margin-bottom: 14px;
}
.support-ticket-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: linear-gradient(135deg, #FF6FAE, #7A5BFF, #5B3FBF);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 22px;
    font-weight: 800;
    box-shadow: 0 6px 14px rgba(91, 63, 191, 0.20);
}
.support-ticket-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.support-ticket-meta {
    flex: 1;
    min-width: 0;
}
.support-ticket-name {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 15px;
    font-weight: 800;
    color: var(--c-text);
    margin-bottom: 4px;
}
.support-ticket-phone {
    font-size: 12.5px;
    color: var(--c-text-muted);
    font-weight: 700;
    margin-bottom: 4px;
}
.support-ticket-date {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11.5px;
    color: var(--c-text-muted);
    font-weight: 600;
}
.support-ticket-date svg { width: 12px; height: 12px; }

.support-ticket-message {
    background: #fafafe;
    border: 1px solid var(--c-border);
    border-radius: 12px;
    padding: 14px 16px;
    font-size: 14px;
    line-height: 1.9;
    color: var(--c-text);
    white-space: pre-wrap;
    word-break: break-word;
    margin-bottom: 14px;
}

.support-ticket-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.support-ticket-actions .btn-sm {
    padding: 7px 12px;
    font-size: 12.5px;
}
.support-ticket-actions .btn-sm svg { width: 14px; height: 14px; }
.support-ticket-actions .icon-btn {
    width: 34px;
    height: 34px;
}
.support-ticket-actions .icon-btn svg { width: 14px; height: 14px; }

.badge-resolved { background: #DCFCE7; color: #15803D; }

@media (max-width: 540px) {
    .support-ticket { padding: 14px; }
    .support-ticket-header { gap: 10px; }
    .support-ticket-avatar { width: 44px; height: 44px; font-size: 18px; }
    .support-ticket-actions { gap: 6px; }
    .support-ticket-actions .btn-sm { flex: 1 1 calc(50% - 4px); justify-content: center; }
}

/* ═══════════════════════════════════════════════════════════════
   USERS PAGE — list, search, detail
   ═══════════════════════════════════════════════════════════════ */

/* Search bar */
.users-search-form {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
}
.users-search-input {
    position: relative;
    flex: 1;
    min-width: 0;
}
.users-search-input > svg {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    right: 14px;
    width: 18px;
    height: 18px;
    color: var(--c-text-muted);
    pointer-events: none;
}
.users-search-input input {
    width: 100%;
    height: 46px;
    padding: 0 44px;
    border-radius: 12px;
    border: 1.5px solid var(--c-border);
    background: #fff;
    font-size: 15px;
    font-weight: 600;
    color: var(--c-text);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.users-search-input input:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 4px rgba(122, 91, 255, 0.10);
}
.users-search-input input::placeholder {
    text-align: right;
}
.users-search-clear {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: 12px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--c-primary-soft);
    color: var(--c-primary);
    display: grid;
    place-items: center;
    text-decoration: none;
}
.users-search-clear svg { width: 13px; height: 13px; }
.users-search-clear:hover { background: var(--c-primary); color: #fff; }

.users-result-summary {
    font-size: 13px;
    color: var(--c-text-muted);
    margin-bottom: 12px;
    font-weight: 600;
}
.users-result-summary code {
    background: var(--c-primary-soft);
    color: var(--c-primary);
    padding: 1px 8px;
    border-radius: 6px;
    font-weight: 700;
}

/* Users grid — responsive: 1 col mobile, 2 col tablet, 3 col desktop */
.users-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}
/* `.users-list-card` instead of `.user-card` to avoid collision with the
   sidebar's admin-profile chip which already owns `.user-card`. */
.users-list-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border-radius: 14px;
    background: #fff;
    border: 1px solid var(--c-border);
    text-decoration: none;
    color: var(--c-text);
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.users-list-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(91, 63, 191, 0.10);
    border-color: var(--c-primary);
}
.user-card-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, #FF6FAE, #7A5BFF, #5B3FBF);
    display: grid;
    place-items: center;
    flex-shrink: 0;
    overflow: hidden;
    color: #fff;
    font-size: 20px;
    font-weight: 800;
    box-shadow: 0 6px 14px rgba(91, 63, 191, 0.25);
}
.user-card-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.user-card-body {
    flex: 1;
    min-width: 0;
}
.user-card-name {
    font-size: 14px;
    font-weight: 800;
    color: var(--c-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}
.user-card-phone {
    font-size: 12.5px;
    color: var(--c-text-muted);
    font-weight: 600;
    margin-bottom: 6px;
}
.user-card-meta {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.user-card-plan,
.user-card-credits {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
}
.user-card-plan {
    background: var(--c-primary-soft);
    color: var(--c-primary);
}
.user-card-plan svg { width: 11px; height: 11px; }
.user-card-credits {
    background: #FFF4E0;
    color: #B45309;
}
.user-card-arrow {
    color: var(--c-text-muted);
    flex-shrink: 0;
    transition: transform 0.15s, color 0.15s;
}
.users-list-card:hover .user-card-arrow {
    color: var(--c-primary);
    transform: translateX(-3px);
}
.user-card-arrow svg { width: 18px; height: 18px; }

/* ─── Detail view ─── */
.user-detail-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
}
.user-profile-card {
    overflow: hidden;
    padding: 0 !important;
}
.user-profile-cover {
    height: 80px;
    background: linear-gradient(135deg, #FF6FAE, #7A5BFF, #5B3FBF);
}
.user-profile-body {
    padding: 0 22px 18px;
    display: flex;
    align-items: flex-end;
    gap: 16px;
    margin-top: -44px;
}
.user-profile-avatar {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: linear-gradient(135deg, #FF6FAE, #7A5BFF, #5B3FBF);
    border: 4px solid #fff;
    display: grid;
    place-items: center;
    overflow: hidden;
    color: #fff;
    font-size: 36px;
    font-weight: 800;
    flex-shrink: 0;
    box-shadow: 0 8px 20px rgba(91, 63, 191, 0.25);
}
.user-profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.user-profile-info {
    flex: 1;
    min-width: 0;
    padding-bottom: 4px;
}
.user-profile-info h2 {
    font-size: 20px;
    font-weight: 900;
    color: var(--c-text);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-profile-phone {
    font-size: 14px;
    color: var(--c-text-muted);
    font-weight: 700;
}

.user-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    padding: 0 18px 22px;
}
.user-stat {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: #fafafe;
    border: 1px solid var(--c-border);
    border-radius: 14px;
}
.user-stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}
.user-stat-icon svg { width: 20px; height: 20px; }
.user-stat-label {
    font-size: 11.5px;
    color: var(--c-text-muted);
    font-weight: 600;
    margin-bottom: 2px;
}
.user-stat-value {
    font-size: 15px;
    font-weight: 900;
    color: var(--c-text);
}

/* ═══════════════════════════════════════════════════════════════
   SECTION-MODELS PAGE — toggle which models are active per app section
   ═══════════════════════════════════════════════════════════════ */

/* "این بخش رایگان است" toggle row */
.section-free-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: #fafafe;
    border: 1px dashed var(--c-border);
    border-radius: 12px;
    margin-bottom: 14px;
    transition: background 0.18s, border-color 0.18s;
}
.section-free-row.is-on {
    background: #DCFCE7;
    border-color: #22C55E;
    border-style: solid;
}
.section-free-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--c-primary-soft);
    color: var(--c-primary);
    display: grid;
    place-items: center;
    flex-shrink: 0;
}
.section-free-row.is-on .section-free-icon {
    background: #22C55E;
    color: #fff;
}
.section-free-icon svg { width: 18px; height: 18px; }
.section-free-text {
    flex: 1;
    min-width: 0;
}
.section-free-text strong {
    display: block;
    font-size: 13.5px;
    font-weight: 800;
    color: var(--c-text);
    margin-bottom: 2px;
}
.section-free-text p {
    font-size: 11.5px;
    font-weight: 500;
    color: var(--c-text-muted);
    line-height: 1.7;
}
.section-free-badge {
    display: inline-block;
    padding: 2px 8px;
    margin-right: 6px;
    background: linear-gradient(135deg, #22C55E, #15803D);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    border-radius: 999px;
    vertical-align: middle;
}
.section-models-card .card-header {
    align-items: center;
}
.section-models-count {
    margin-right: auto;
    font-size: 13px;
    font-weight: 800;
    color: var(--c-primary);
    background: var(--c-primary-soft);
    padding: 6px 12px;
    border-radius: 10px;
    flex-shrink: 0;
}
.section-models-count span {
    font-weight: 600;
    color: var(--c-text-muted);
    margin-right: 4px;
}

.section-model-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.section-model-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: 12px;
    transition: border-color 0.15s, background 0.15s;
}
.section-model-row.is-off {
    background: #fafafe;
    opacity: 0.85;
}
.section-model-info {
    flex: 1;
    min-width: 0;
}
.section-model-name {
    font-size: 14px;
    font-weight: 800;
    color: var(--c-text);
    margin-bottom: 2px;
}
.section-model-id {
    font-size: 11.5px;
    color: var(--c-text-muted);
    font-weight: 600;
    margin-bottom: 4px;
}
.section-model-desc {
    font-size: 12px;
    color: var(--c-text-muted);
    line-height: 1.7;
    font-weight: 500;
}

.section-model-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
}
.section-model-toggle-track {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    border-radius: 999px;
    background: #D1D5DB;
    transition: background 0.18s;
    flex-shrink: 0;
}
.section-model-toggle-track.on {
    background: linear-gradient(135deg, #22C55E, #15803D);
}
.section-model-toggle-knob {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.20);
    transition: transform 0.18s;
}
.section-model-toggle-track.on .section-model-toggle-knob {
    transform: translateX(-20px);
}
.section-model-toggle-label {
    font-size: 12px;
    font-weight: 800;
    min-width: 44px;
    text-align: right;
    color: var(--c-text-muted);
}
.section-model-row:not(.is-off) .section-model-toggle-label { color: #15803D; }

@media (max-width: 540px) {
    .section-model-row { flex-wrap: wrap; gap: 10px; }
    .section-model-info { flex: 1 1 100%; }
}

/* Admin actions on user detail (credit adjust + plan change) */
.admin-actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.admin-action-box {
    background: #fafafe;
    border: 1px solid var(--c-border);
    border-radius: 14px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.admin-action-box h3 {
    font-size: 14px;
    font-weight: 800;
    color: var(--c-text);
}
.admin-action-hint {
    font-size: 12px;
    color: var(--c-text-muted);
    line-height: 1.7;
    font-weight: 600;
}
.admin-action-hint strong {
    color: var(--c-text);
    font-weight: 900;
}
.admin-quick-buttons {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}
.admin-quick-label {
    font-size: 11.5px;
    color: var(--c-text-muted);
    font-weight: 700;
    margin-left: 4px;
}
.quick-credit-btn {
    background: var(--c-primary-soft);
    color: var(--c-primary);
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 800;
    transition: background 0.15s, border-color 0.15s;
}
.quick-credit-btn:hover {
    background: #fff;
    border-color: var(--c-primary);
}
.admin-action-box .btn { align-self: flex-start; }

@media (max-width: 720px) {
    .admin-actions-grid { grid-template-columns: 1fr; }
}

/* Payments table */
.payments-table-wrap {
    overflow-x: auto;
    margin: 0 -22px;
    padding: 0 22px;
}
.payments-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 580px;
}
.payments-table th,
.payments-table td {
    padding: 12px 14px;
    text-align: right;
    border-bottom: 1px solid var(--c-border);
    font-size: 13px;
}
.payments-table th {
    font-weight: 800;
    color: var(--c-text-muted);
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: #fafafe;
}
.payments-table tbody tr:hover { background: #fafafe; }
.badge-danger { background: #FFE4E4; color: #991B1B; }

/* Responsive tweaks */
@media (max-width: 640px) {
    .users-search-form { flex-direction: column; }
    .users-search-form .btn { width: 100%; justify-content: center; }
    .user-profile-body {
        flex-direction: column;
        align-items: center;
        text-align: center;
        margin-top: -56px;
    }
    .user-profile-avatar { width: 110px; height: 110px; }
    .user-profile-info h2 { font-size: 18px; }
    .user-stat-grid { grid-template-columns: 1fr; }
}
@media (min-width: 480px) and (max-width: 900px) {
    .user-stat-grid { grid-template-columns: 1fr 1fr; }
}

/* Breadcrumb shown above sub-pages of "App Pages" */
.breadcrumb-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    font-size: 13px;
    color: var(--c-text-muted);
    font-weight: 600;
}
.breadcrumb-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--c-primary);
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 8px;
    transition: background 0.15s;
}
.breadcrumb-link:hover { background: var(--c-primary-soft); }
.breadcrumb-link svg { width: 16px; height: 16px; }
.breadcrumb-sep { color: var(--c-text-muted); }
.breadcrumb-current { color: var(--c-text); font-weight: 800; }

/* App Pages hub — clickable cards leading to each page's settings */
.app-pages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 14px;
    margin-top: 8px;
}
.app-page-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    border-radius: var(--r-lg);
    border: 1px solid var(--c-border);
    background: #fff;
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.app-page-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 30px rgba(91, 63, 191, 0.12);
    border-color: var(--c-primary);
}
.app-page-card-placeholder {
    border-style: dashed;
    cursor: default;
}
.app-page-card-placeholder:hover {
    transform: none;
    box-shadow: none;
    border-color: var(--c-border);
}
.app-page-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 8px 18px rgba(91, 63, 191, 0.15);
}
.app-page-icon svg { width: 28px; height: 28px; }
.app-page-info {
    flex: 1;
    min-width: 0;
}
.app-page-info h3 {
    font-size: 15px;
    font-weight: 800;
    color: var(--c-text);
    margin-bottom: 4px;
}
.app-page-info p {
    font-size: 12.5px;
    color: var(--c-text-muted);
    line-height: 1.7;
    font-weight: 500;
}
.app-page-arrow {
    color: var(--c-text-muted);
    flex-shrink: 0;
    transition: transform 0.15s, color 0.15s;
}
.app-page-card:hover .app-page-arrow {
    color: var(--c-primary);
    transform: translateX(-4px);
}
.app-page-arrow svg { width: 20px; height: 20px; }

/* Sample image preview on the anime-photo settings page */
.sample-preview-frame {
    width: 200px;
    aspect-ratio: 4 / 5;
    border-radius: var(--r-lg);
    overflow: hidden;
    background: #f3f0fb;
    border: 1px solid var(--c-border);
    display: grid;
    place-items: center;
    color: var(--c-text-muted);
}
.sample-preview-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.sample-preview-row {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

/* Icon-type tabs (image / svg toggle on tool forms) */
.icon-type-tabs {
    display: flex;
    gap: 8px;
    background: #f3f0fb;
    padding: 4px;
    border-radius: 12px;
    width: fit-content;
}
.icon-type-tab {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--c-text-muted);
    transition: background 0.15s, color 0.15s;
}
.icon-type-tab input[type="radio"] {
    display: none;
}
.icon-type-tab:has(input[type="radio"]:checked) {
    background: #fff;
    color: var(--c-primary);
    box-shadow: 0 2px 8px rgba(91, 63, 191, 0.12);
}
.svg-preview {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}
.svg-preview svg {
    max-width: 48px;
    max-height: 48px;
    color: var(--c-primary);
}
.item-image-square .svg-preview {
    background: #f7f4ff;
}
.item-image-square .svg-preview svg {
    max-width: 64px;
    max-height: 64px;
}

/* AI Pages — admin models row */
.aip-model-row {
    background: #fafafe;
    border: 1px solid #ece8f7;
    border-radius: var(--r-md);
    padding: 14px;
    margin-bottom: 10px;
    position: relative;
}
.aip-model-row-grid {
    display: grid;
    grid-template-columns: 2fr 1.4fr 1.4fr 1fr;
    gap: 10px;
}
.aip-model-row .aip-remove-model {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 4px 10px;
    font-size: 11.5px;
}
@media (max-width: 720px) {
    .aip-model-row-grid { grid-template-columns: 1fr 1fr; }
}

/* Plan → chat models picker (multi-select) */
.model-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 8px;
    max-height: 280px;
    overflow-y: auto;
    padding: 8px;
    background: #fafafe;
    border: 1px solid #ece8f7;
    border-radius: var(--r-md);
}
.model-pick-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    background: #fff;
    border: 1px solid #ede8f7;
    transition: background 0.15s, border-color 0.15s;
}
.model-pick-row:hover { background: #f7f4ff; border-color: #d6cdf2; }
.model-pick-main {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
    cursor: pointer;
}
.model-pick-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--c-primary);
    flex-shrink: 0;
}
.model-pick-row.is-disabled { opacity: 0.55; }
.model-pick-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.model-pick-name {
    font-weight: 700;
    color: var(--c-text);
    font-size: 13px;
}
.model-pick-meta {
    font-size: 11.5px;
    color: var(--c-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.model-pick-limit {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.model-pick-limit input[type="number"] {
    width: 62px;
    padding: 5px 6px;
    font-size: 12px;
    border: 1px solid var(--c-border);
    border-radius: 6px;
    text-align: center;
    font-family: inherit;
    background: #fff;
}
.model-pick-limit input[type="number"]:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 2px var(--c-primary-soft);
}
.model-pick-limit-suffix {
    font-size: 11px;
    color: var(--c-text-muted);
    white-space: nowrap;
}

.file-input-wrap {
    border: 1.5px dashed var(--c-primary);
    border-radius: var(--r-md);
    padding: 18px;
    background: var(--c-primary-soft);
    transition: background 0.18s;
}
.file-input-wrap:hover { background: #E0D6F8; }
.file-input-wrap input[type="file"] {
    width: 100%;
    cursor: pointer;
    font-family: inherit;
    color: var(--c-text-soft);
}

.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
    margin-top: 16px;
}

.item-card {
    background: #FFF;
    border: 1px solid var(--c-border);
    border-radius: var(--r-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.15s, box-shadow 0.18s;
}
.item-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.item-disabled { opacity: 0.55; }

.item-image {
    background: #F0EAFD;
    aspect-ratio: 16 / 9;
    overflow: hidden;
}
.item-image-square {
    aspect-ratio: 1 / 1;
}
.item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.item-card-tool {
    flex-direction: column;
}

.tool-icon-display {
    background: var(--c-primary-soft);
    height: 80px;
    display: grid;
    place-items: center;
    font-size: 36px;
}

.item-body {
    padding: 12px 14px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.item-title {
    font-weight: 800;
    font-size: 14px;
    color: var(--c-text);
}

.item-meta {
    font-size: 12px;
    color: var(--c-text-soft);
    font-weight: 600;
    line-height: 1.6;
    word-break: break-all;
}

.item-meta-row {
    display: flex;
    justify-content: space-between;
    font-size: 11.5px;
    color: var(--c-text-muted);
    font-weight: 600;
}

.badge {
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 10.5px;
    font-weight: 800;
}
.badge-success { background: #DCFCE7; color: #166534; }
.badge-muted   { background: #F1F1F1; color: #6B7280; }

.item-actions {
    display: flex;
    gap: 6px;
    padding: 10px 14px;
    border-top: 1px solid var(--c-border);
    background: #FAFAFA;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: #FFF;
    border: 1px solid var(--c-border);
    color: var(--c-text-soft);
    display: grid;
    place-items: center;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover {
    background: var(--c-primary-soft);
    color: var(--c-primary);
    border-color: var(--c-primary);
}
.icon-btn-danger:hover {
    background: #FEE2E2;
    color: var(--c-red);
    border-color: var(--c-red);
}

.logo-preview {
    background: linear-gradient(135deg, #EDE7FB, #D8C9FF);
    border-radius: var(--r-md);
    padding: 24px;
    text-align: center;
    border: 1px solid var(--c-border);
}
.logo-preview img {
    max-width: 100%;
    max-height: 80px;
    object-fit: contain;
}

/* ───── Provider tabs (AI Models page) ───── */

.provider-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 18px;
    background: #FFF;
    padding: 6px;
    border-radius: var(--r-md);
    border: 1px solid var(--c-border);
    flex-wrap: wrap;
    box-shadow: 0 2px 6px rgba(91, 63, 191, 0.04);
}

.provider-tab {
    padding: 10px 16px;
    border-radius: 10px;
    color: var(--c-text-muted);
    font-weight: 700;
    font-size: 13px;
    text-decoration: none;
    transition: background 0.18s, color 0.18s, box-shadow 0.18s;
    white-space: nowrap;
    flex: 1 1 110px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 0;
}
.provider-tab:hover {
    background: var(--c-primary-soft);
    color: var(--c-primary);
}
.provider-tab.active {
    background: linear-gradient(135deg, var(--c-primary-2), var(--c-primary));
    color: #FFF;
    box-shadow: 0 6px 14px rgba(91, 63, 191, 0.30);
}

.provider-tab-label {
    overflow: hidden;
    text-overflow: ellipsis;
}

.provider-tab-count {
    background: rgba(255, 255, 255, 0.30);
    color: inherit;
    font-size: 11px;
    font-weight: 800;
    padding: 1px 8px;
    border-radius: 999px;
    min-width: 22px;
    text-align: center;
    line-height: 1.6;
}
.provider-tab:not(.active) .provider-tab-count {
    background: var(--c-primary-soft);
    color: var(--c-primary);
}

@media (max-width: 600px) {
    .provider-tab { padding: 9px 12px; font-size: 12.5px; }
}

/* ───── AI model rows ───── */

.model-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.model-row {
    background: #FFF;
    border: 1px solid var(--c-border);
    border-radius: var(--r-lg);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: box-shadow 0.18s, border-color 0.18s;
}
.model-row:hover {
    box-shadow: 0 6px 16px rgba(91, 63, 191, 0.08);
    border-color: rgba(91, 63, 191, 0.18);
}

.model-info { flex: 1; min-width: 0; }

.model-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.model-display-name {
    font-size: 14.5px;
    font-weight: 800;
    color: var(--c-text);
}

.model-id {
    font-size: 11.5px;
    color: var(--c-primary);
    font-family: 'Menlo', 'Consolas', monospace;
    background: var(--c-primary-soft);
    padding: 3px 10px;
    border-radius: 6px;
    display: inline-block;
    margin-bottom: 0;
    direction: ltr;
    word-break: break-all;
    line-height: 1.5;
}

.model-desc {
    color: var(--c-text-soft);
    font-size: 12.5px;
    line-height: 1.7;
    margin-top: 8px;
}

.model-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    align-items: center;
}

textarea {
    padding: 12px 14px;
    border: 1.5px solid var(--c-border);
    border-radius: var(--r-md);
    font-size: 14px;
    color: var(--c-text);
    background: #fff;
    width: 100%;
    transition: border-color 0.18s, box-shadow 0.18s;
    font-family: inherit;
    resize: vertical;
    line-height: 1.7;
}
textarea:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 4px rgba(91, 63, 191, 0.10);
}

@media (max-width: 600px) {
    .model-row {
        flex-direction: column;
    }
    .model-actions {
        width: 100%;
        justify-content: flex-start;
    }
}

/* ───── Plans page (panel) ───── */

.btn-sm { padding: 8px 14px; font-size: 12.5px; }

.plan-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.plan-row {
    background: #FFF;
    border: 1px solid var(--c-border);
    border-radius: var(--r-lg);
    padding: 16px 18px;
    border-right: 4px solid var(--c-primary);
    transition: box-shadow 0.18s, transform 0.15s;
}
.plan-row:hover {
    box-shadow: 0 6px 16px rgba(91, 63, 191, 0.08);
}

.plan-row-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.plan-row-name {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 16px;
}
.plan-row-name strong { color: var(--c-text); }

.plan-row-price {
    color: var(--c-primary);
    font-weight: 800;
    font-size: 14px;
    background: var(--c-primary-soft);
    padding: 4px 10px;
    border-radius: 8px;
}

.plan-row-tagline {
    color: var(--c-text-soft);
    font-size: 13px;
    margin-bottom: 10px;
}

.plan-row-stats {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--c-text-muted);
    margin-bottom: 12px;
}
.plan-stat {
    background: #F8F5FE;
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 700;
}

.plan-row-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    padding-top: 10px;
    border-top: 1px dashed var(--c-border);
}

.badge-recommended {
    background: linear-gradient(135deg, #FFD700, #FF9C2A);
    color: #5C2C00;
    padding: 3px 9px;
    border-radius: 8px;
    font-size: 10.5px;
    font-weight: 800;
}

/* Plan color variants (left border accent) */
.plan-color-gray   { border-right-color: #94A3B8; }
.plan-color-blue   { border-right-color: #3B82F6; }
.plan-color-purple { border-right-color: var(--c-primary); }
.plan-color-pink   { border-right-color: #EC4899; }
.plan-color-gold   { border-right-color: #F59E0B; }
.plan-color-teal   { border-right-color: #14B8A6; }

/* ───── Credit packages grid (panel) ───── */

.credit-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.credit-card {
    background: linear-gradient(135deg, #F8F5FE, #FFF);
    border: 1px solid var(--c-border);
    border-radius: var(--r-lg);
    padding: 16px;
    text-align: center;
    transition: box-shadow 0.18s, transform 0.15s;
}
.credit-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.credit-amount {
    font-size: 18px;
    font-weight: 800;
    color: var(--c-primary);
    margin-bottom: 6px;
}
.credit-price {
    font-size: 14px;
    font-weight: 700;
    color: var(--c-text);
    margin-bottom: 8px;
}
.credit-meta {
    font-size: 11.5px;
    color: var(--c-text-muted);
    margin-bottom: 10px;
}
.credit-actions {
    display: flex;
    gap: 6px;
    justify-content: center;
    padding-top: 8px;
    border-top: 1px dashed var(--c-border);
}

/* Wider modal for plans (more form fields) */
.modal-card-wide { width: min(680px, calc(100vw - 32px)); }

.card-header h2 {
    font-size: 16px;
    font-weight: 800;
    color: var(--c-text);
    margin-bottom: 3px;
}
.card-header p {
    font-size: 12.5px;
    color: var(--c-text-muted);
    font-weight: 500;
}

.card-body { padding: 22px; display: flex; flex-direction: column; gap: 18px; }

.card-footer {
    padding: 16px 22px;
    background: #FAFAFA;
    border-top: 1px solid var(--c-border);
    display: flex;
    justify-content: flex-end;
}

.input-secret { position: relative; }
.input-secret input { padding-left: 46px; }
.input-secret .reveal-btn {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    color: var(--c-text-muted);
    display: grid;
    place-items: center;
}
.input-secret .reveal-btn:hover { background: var(--c-primary-soft); color: var(--c-primary); }
.input-secret .reveal-btn svg { width: 16px; height: 16px; }

/* ───── Responsive ───── */

@media (max-width: 1024px) {
    :root { --sidebar-w: 240px; }
}

@media (max-width: 860px) {
    .layout { grid-template-columns: 1fr; }

    .sidebar {
        position: fixed;
        top: 0;
        right: -100%;
        width: min(280px, 84vw);
        /* Use dynamic viewport height so mobile browser UI bars don't clip
           the bottom items. Falls back to 100vh on older browsers. */
        height: 100vh;
        height: 100dvh;
        z-index: 100;
        transition: right 0.28s cubic-bezier(0.32, 0.72, 0, 1);
        padding-top: max(20px, env(safe-area-inset-top));
        padding-bottom: max(16px, env(safe-area-inset-bottom));
        overflow: hidden;     /* nav inside scrolls; outer doesn't */
    }

    .sidebar.open { right: 0; }

    .menu-toggle { display: flex; }

    .topbar { padding: 14px 16px; }
    .content { padding: 18px; }

    .welcome-card {
        flex-direction: column;
        align-items: flex-start;
        text-align: right;
        padding: 22px;
    }
    .welcome-mark { width: 64px; height: 64px; align-self: flex-end; }
    .welcome-text h2 { font-size: 20px; }

    .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .auth-card { padding: 24px 18px; }
    .auth-header h1 { font-size: 19px; }
    .step-line { width: 36px; }
    .step-label { display: none; }
    .stats-grid { grid-template-columns: 1fr; }
    .card-header { flex-wrap: wrap; padding: 18px; }
    .card-body { padding: 18px; }
}
