:root {
    --bg: #f3f4f8;
    --surface: #ffffff;
    --text: #111827;
    --muted: #6b7280;
    --line: #ececf3;
    --primary: #e11d2e;
    --primary-soft: #fff1f2;
    --primary-dark: #be123c;
    --success: #059669;
    --success-soft: #ecfdf5;
    --warning: #d97706;
    --warning-soft: #fffbeb;
    --info: #2563eb;
    --info-soft: #eff6ff;
    --shadow: 0 10px 30px rgba(17, 24, 39, 0.06);
    --radius: 18px;
    --sidebar-width: 280px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: "Vazirmatn", Tahoma, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
}

.login-card {
    width: min(420px, calc(100vw - 32px));
    background: var(--surface);
    border-radius: 24px;
    box-shadow: var(--shadow);
    padding: 32px;
}

.login-brand, .brand {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
}

.login-logo, .brand-logo { width: 52px; height: 52px; }
.login-brand-text, .brand-text { display: flex; flex-direction: column; gap: 2px; }
.login-brand-text strong, .brand-text strong { font-size: 18px; letter-spacing: .04em; }
.login-brand-text span, .brand-text span { color: var(--muted); font-size: 11px; letter-spacing: .18em; }
.login-subtitle { text-align: center; color: var(--muted); margin: 18px 0 0; }
.login-card hr { border: none; border-top: 1px solid var(--line); margin: 18px 0; }
.login-card h1 { text-align: center; font-size: 22px; margin: 0 0 24px; }
.login-form label { display: block; margin-bottom: 16px; }
.login-form span { display: block; margin-bottom: 8px; color: var(--muted); font-size: 14px; }
.login-form input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px 14px;
    background: #fff;
}
.form-error { color: var(--primary); font-size: 14px; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    border-left: 1px solid var(--line);
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar-user {
    margin: 22px 0;
    background: #f8fafc;
    border-radius: 16px;
    padding: 14px;
}
.sidebar-user-name { font-weight: 700; }
.sidebar-user-id { color: var(--muted); font-size: 13px; margin-top: 4px; }
.bot-switcher { margin-bottom: 18px; }
.bot-switcher label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.nav-group-label {
    color: var(--muted);
    font-size: 12px;
    margin: 14px 8px 6px;
}
.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 14px;
    color: #374151;
}
.nav-link.active {
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-weight: 700;
}
.logout-btn {
    margin-top: 16px;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 14px;
    padding: 12px;
    cursor: pointer;
    color: var(--primary);
}

.main { flex: 1; min-width: 0; }
.topbar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 18px 28px;
    gap: 16px;
}
.topbar-left { display: flex; align-items: center; gap: 12px; justify-self: start; }
.page-title { margin: 0; text-align: center; font-size: 28px; font-weight: 800; }
.content { padding: 0 28px 32px; }

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 8px 12px;
    min-width: 240px;
}
.search-box input {
    border: none;
    outline: none;
    background: transparent;
    width: 100%;
}
.kbd {
    font-size: 11px;
    color: var(--muted);
    background: #f3f4f6;
    border-radius: 8px;
    padding: 2px 6px;
}
.icon-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: #fff;
    cursor: pointer;
}

.input, .textarea {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 10px 12px;
    background: #fff;
}
.textarea { width: 100%; min-height: 180px; resize: vertical; }

.btn {
    border: none;
    border-radius: 14px;
    padding: 11px 18px;
    cursor: pointer;
    font-weight: 700;
}
.btn-primary {
    background: linear-gradient(180deg, #ef233c 0%, #d90429 100%);
    color: #fff;
    box-shadow: 0 8px 20px rgba(225, 29, 46, 0.25);
}
.btn-light { background: #fff; border: 1px solid var(--line); color: #111; }
.btn-block { width: 100%; }

.panel, .toolbar-card, .table-card, .hero-card, .stat-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.panel-header {
    padding: 16px 18px;
    font-weight: 700;
    border-bottom: 1px solid var(--line);
}
.panel-body { padding: 16px 18px; }

.hero-card {
    display: grid;
    grid-template-columns: minmax(300px, 360px) 1fr;
    gap: 24px;
    padding: 24px;
    margin-bottom: 20px;
    align-items: center;
}
.hero-visual {
    display: flex;
    justify-content: center;
    overflow: hidden;
    min-height: 320px;
}
.hero-content h2 { margin: 0 0 8px; font-size: 28px; }
.hero-content p { color: var(--muted); line-height: 1.8; }
.hero-actions { display: flex; gap: 12px; margin-top: 18px; }

.ib-orbit {
    position: relative;
    width: 300px;
    height: 300px;
    margin: 0 auto;
    flex-shrink: 0;
}
.ib-orbit-ring {
    position: absolute;
    inset: 0;
    border: 1px dashed rgba(225, 29, 46, 0.16);
    border-radius: 50%;
    animation: ring-spin 60s linear infinite;
}
.ring-2 {
    inset: 28px;
    animation-duration: 80s;
    animation-direction: reverse;
}
.ring-3 {
    inset: 56px;
    animation-duration: 100s;
}
.ib-orbit-core {
    position: absolute;
    inset: 96px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #fff, #ecfdf5 60%, #d1fae5);
    display: grid;
    place-items: center;
    text-align: center;
    border: 2px solid #86efac;
    z-index: 2;
    padding: 8px;
}
.ib-orbit-core span {
    color: var(--success);
    font-weight: 800;
    font-size: 17px;
    line-height: 1.3;
}
.ib-orbit-core small {
    color: var(--muted);
    font-size: 11px;
    margin-top: 4px;
    display: block;
}
.orbit-dots {
    position: absolute;
    inset: 0;
    pointer-events: none;
}
.orbit-empty {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    text-align: center;
    color: var(--muted);
    font-size: 12px;
    padding: 0 24px;
}
.orbit-dot {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 34px;
    height: 34px;
    margin: -17px;
    background: #fff;
    border: 2px solid var(--primary);
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(225, 29, 46, 0.12);
    animation: orbit-spin linear infinite;
    z-index: 3;
    display: grid;
    place-items: center;
    font-size: 11px;
    font-weight: 700;
    color: var(--primary-dark);
    cursor: default;
    pointer-events: auto;
}
.orbit-dot:hover {
    z-index: 4;
}
.orbit-dot-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) scale(0.95);
    opacity: 0;
    pointer-events: none;
    font-size: 10px;
    font-weight: 600;
    white-space: nowrap;
    color: #374151;
    background: #fff;
    border: 1px solid #fecdd3;
    border-radius: 999px;
    padding: 4px 10px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
    transition: opacity 0.15s ease, transform 0.15s ease;
}
.orbit-dot:hover .orbit-dot-tooltip {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

@keyframes ring-spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes orbit-spin {
    from {
        transform: rotate(0deg) translateX(var(--radius)) rotate(0deg);
    }
    to {
        transform: rotate(360deg) translateX(var(--radius)) rotate(-360deg);
    }
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.stat-card { padding: 18px; }
.stat-label { color: var(--muted); font-size: 14px; margin-bottom: 10px; }
.stat-value { font-size: 34px; font-weight: 800; }

.dashboard-columns {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}
.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}
.list-item:last-child { border-bottom: none; }
.list-item-main { display: flex; align-items: center; gap: 10px; }
.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #f3f4f6;
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 700;
}
.meta { color: var(--muted); font-size: 12px; }

.health-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.neutral { background: #f3f4f6; color: #4b5563; }

.toolbar-card, .table-card { padding: 16px; margin-bottom: 16px; }
.toolbar-row { display: flex; gap: 12px; flex-wrap: wrap; }
.table-wrap { overflow: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--line);
    text-align: right;
    white-space: nowrap;
}
.data-table thead th {
    background: #fff5f5;
    color: #9f1239;
    font-size: 13px;
}
.empty-cell { text-align: center !important; color: var(--muted); padding: 28px !important; }
.table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 14px;
    color: var(--muted);
    font-size: 13px;
}
.pagination { display: flex; gap: 8px; }
.pagination button {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 10px;
    padding: 8px 12px;
    cursor: pointer;
}

.support-layout {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 16px;
}
.support-list .tabs {
    display: flex;
    gap: 8px;
    padding: 14px;
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
}
.tab {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 999px;
    padding: 8px 14px;
    cursor: pointer;
}
.tab.active { background: var(--primary-soft); border-color: #fecdd3; color: var(--primary-dark); font-weight: 700; }
.support-items { max-height: 70vh; overflow: auto; padding: 10px; }
.support-card {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 14px;
    margin-bottom: 10px;
    cursor: pointer;
    background: #fff;
}
.support-card.active { border-color: #fb7185; background: #fff7f8; }
.support-card-head { display: flex; justify-content: space-between; gap: 10px; }
.support-detail .detail-header {
    background: linear-gradient(135deg, #ffe4e6, #fff1f2);
    border-radius: 16px;
    padding: 18px;
    margin-bottom: 16px;
}
.alert-success-box {
    background: var(--success-soft);
    border: 1px solid #a7f3d0;
    border-radius: 16px;
    padding: 14px;
    margin-bottom: 16px;
    color: #065f46;
}
.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.detail-field {
    background: #f9fafb;
    border-radius: 12px;
    padding: 12px;
}
.detail-field span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.timeline { border-right: 2px solid #fecaca; padding-right: 16px; }
.timeline-item { position: relative; margin-bottom: 16px; padding-right: 8px; }
.timeline-item::before {
    content: "";
    position: absolute;
    right: -23px;
    top: 4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
}

.settings-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 16px;
    margin-bottom: 80px;
}
.settings-nav { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.settings-tab {
    text-align: right;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 16px;
    padding: 14px;
    cursor: pointer;
    line-height: 1.5;
}
.settings-tab.active { background: var(--primary-soft); border-color: #fecdd3; color: var(--primary-dark); font-weight: 700; }
.settings-tab small { color: var(--muted); font-weight: 400; }
.settings-content { padding: 20px; min-height: 520px; }
.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}
.field label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 14px; }
.summary-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}
.summary-card {
    background: #f9fafb;
    border-radius: 16px;
    padding: 16px;
}
.summary-card strong { display: block; font-size: 28px; margin: 8px 0; }
.info-box {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 14px;
    padding: 14px;
    margin-top: 16px;
    color: #92400e;
    line-height: 1.8;
}
.save-settings-btn {
    position: fixed;
    left: 28px;
    bottom: 24px;
    z-index: 20;
    min-width: 180px;
}
.empty-state { text-align: center; color: var(--muted); padding: 40px 20px; }
.empty-state h3 { color: var(--text); }

.message-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 16px;
}

.message-list button {
    width: 100%;
    text-align: right;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 8px;
    cursor: pointer;
}

.message-list button.active {
    background: var(--primary-soft);
    border-color: #fecdd3;
}

@media (max-width: 1200px) {
    .hero-card,
    .dashboard-columns,
    .stats-grid,
    .support-layout,
    .settings-layout,
    .settings-grid,
    .summary-cards {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
        width: 100%;
        border-left: none;
        border-bottom: 1px solid var(--line);
    }

    .app-shell {
        flex-direction: column;
    }
}
