:root {
    /* Professional SaaS Color Palette */
    --primary-600: #4F46E5;
    --primary-700: #4338CA;
    --primary-50: #EEF2FF;
    --primary-100: #E0E7FF;

    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;

    --success-600: #059669;
    --success-50: #ECFDF5;
    --danger-600: #DC2626;
    --danger-50: #FEF2F2;
    --warning-600: #D97706;
    --warning-50: #FFFBEB;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.5;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    max-width: 100%;
    overflow-x: hidden;
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
    background: var(--gray-50);
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: white;
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    z-index: 40;
}

.sidebar-header {
    padding: 1.5rem 1.25rem;
    border-bottom: 1px solid var(--gray-200);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-900);
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1rem;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 1.5rem;
}

.nav-section-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    padding: 0 0.75rem;
    margin-bottom: 0.5rem;
}

.nav-menu {
    list-style: none;
}

.nav-item {
    margin-bottom: 0.125rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    color: var(--gray-700);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.15s ease;
}

.nav-link:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.nav-link.active {
    background: var(--primary-50);
    color: var(--primary-700);
}

.nav-link svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--gray-200);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s ease;
}

.user-menu:hover {
    background: var(--gray-100);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--gray-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-email {
    font-size: 0.75rem;
    color: var(--gray-500);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Main Content */
.main-content {
    flex: 1;
    min-width: 0;
    margin-left: 280px;
    min-height: 100vh;
}
.admin-badge { display:inline-flex; margin-left:.35rem; padding:.1rem .35rem; color:#6d28d9; background:#f3e8ff; border-radius:999px; font-size:.58rem; font-weight:700; vertical-align:middle; }

.top-bar {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 30;
}

/* Mobile Menu Button & Overlay */
.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    color: var(--gray-600);
    cursor: pointer;
    padding: 0.5rem;
    margin-right: 0.5rem;
    border-radius: var(--radius-sm);
    transition: background 0.15s ease, color 0.15s ease;
}

.mobile-menu-btn:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.mobile-menu-btn svg {
    width: 24px;
    height: 24px;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(17, 24, 39, 0.4);
    backdrop-filter: blur(4px);
    z-index: 35;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.open {
    display: block;
    opacity: 1;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.content-wrapper {
    padding: 2.5rem;
    width: 100%;
}

/* Page Header */
.page-header {
    margin-bottom: 2.5rem;
}

.page-title {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 0.5rem;
    letter-spacing: -0.025em;
    line-height: 1.2;
}

.page-subtitle {
    color: var(--gray-600);
    font-size: 0.9375rem;
    line-height: 1.5;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: all 0.2s ease;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--gray-300);
}

.stat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.stat-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-600);
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon svg {
    width: 22px;
    height: 22px;
}

.stat-icon.primary {
    background: var(--primary-50);
    color: var(--primary-600);
}

.stat-icon.success {
    background: var(--success-50);
    color: var(--success-600);
}

.stat-icon.danger {
    background: var(--danger-50);
    color: var(--danger-600);
}

.stat-icon.warning {
    background: var(--warning-50);
    color: var(--warning-600);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1;
}

.stat-change {
    font-size: 0.75rem;
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.stat-change.positive {
    color: var(--success-600);
}

.stat-change.negative {
    color: var(--danger-600);
}

/* Cards */
.card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-900);
}

.card-body {
    padding: 1.5rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary-600);
    color: white;
    border-color: var(--primary-600);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-700);
    border-color: var(--primary-700);
}

.btn-secondary {
    background: white;
    color: var(--gray-700);
    border-color: var(--gray-300);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

.btn-success {
    background: var(--success-600);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #047857;
}

.btn-danger {
    background: var(--danger-600);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #B91C1C;
}

.btn-sm {
    padding: 0.4375rem 0.875rem;
    font-size: 0.8125rem;
    line-height: 1.25rem;
}

.btn-sm svg {
    width: 14px;
    height: 14px;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.375rem;
}

.form-input,
.form-textarea,
.form-select {
    display: block;
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--gray-900);
    background: white;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary-600);
    box-shadow: 0 0 0 3px var(--primary-100);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--gray-400);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 0.375rem;
}

.form-error {
    font-size: 0.75rem;
    color: var(--danger-600);
    margin-top: 0.375rem;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: var(--radius);
    border: 1px solid;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.alert-success {
    background: var(--success-50);
    border-color: #A7F3D0;
    color: #065F46;
}

.alert-error {
    background: var(--danger-50);
    border-color: #FECACA;
    color: #991B1B;
}

.alert-warning {
    background: var(--warning-50);
    border-color: #FDE68A;
    color: #92400E;
}

.alert-info {
    background: var(--primary-50);
    border-color: #C7D2FE;
    color: #3730A3;
}

/* Tables - Minimalist Design */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    width: 100%;
}

.table-container table {
    min-width: 100%;
    table-layout: fixed;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: transparent;
    border-bottom: 2px solid var(--gray-200);
}

th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: normal;
    color: var(--gray-500);
    border-bottom: none;
}

td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.875rem;
    color: var(--gray-900);
    vertical-align: middle;
}

/* Compact Avatars for Tables */
td img,
td .user-avatar {
    width: 32px !important;
    height: 32px !important;
    font-size: 0.75rem !important;
}

tr:last-child td {
    border-bottom: none;
}

tbody tr {
    transition: all 0.15s ease;
    cursor: default;
}

tbody tr:hover {
    background: var(--gray-50);
    box-shadow: inset 0 0 0 1px var(--gray-200);
}

tbody tr:hover .btn {
    opacity: 1;
}

/* Table action buttons - subtle by default */
tbody tr .btn {
    opacity: 0.7;
    transition: opacity 0.15s ease;
}

tbody tr .btn:hover {
    opacity: 1;
}

/* Social Icons */
.social-icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    flex-shrink: 0;
}

.social-icon.vk {
    background: #0077FF;
    color: white;
}

.social-icon.max {
    background: #FF3347;
    color: white;
}

.social-icon svg {
    width: 12px;
    height: 12px;
}

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
}

.badge-primary {
    background: var(--primary-100);
    color: var(--primary-700);
}

.badge-success {
    background: var(--success-50);
    color: var(--success-600);
}

.badge-danger {
    background: var(--danger-50);
    color: var(--danger-600);
}

.badge-gray {
    background: var(--gray-100);
    color: var(--gray-700);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    background: var(--gray-100);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-400);
}

.empty-state-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 0.5rem;
}

.empty-state-description {
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-bottom: 1.5rem;
}

/* Loading */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--gray-500);
}

/* Wide table on dashboard */
.card-body:has(.table-container) {
    padding: 0;
}

.table-container {
    width: 100%;
    margin: 0;
    border-radius: 0;
}

.table-container table {
    width: 100% !important;
    min-width: 800px;
    table-layout: fixed;
    border-collapse: collapse;
}

.table-container th:first-child,
.table-container td:first-child {
    padding-left: 1.5rem;
}

.table-container th:last-child,
.table-container td:last-child {
    padding-right: 1.5rem;
}

/* Responsive */
@media (max-width: 1024px) {
    .mobile-menu-btn {
        display: block;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: none;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-xl);
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .content-wrapper {
        padding: 1.5rem;
    }
}

@media (max-width: 640px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .top-bar {
        padding: 1rem;
    }

    .content-wrapper {
        padding: 1rem;
    }

    .page-title {
        font-size: 1.5rem;
    }
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(17, 24, 39, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-900);
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
}

.modal-close:hover {
    color: var(--gray-600);
    background: var(--gray-100);
}

.modal-body {
    padding: 1.5rem;
    max-height: 70vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Links List */
.links-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.link-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1rem;
    background: var(--gray-50);
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    transition: all 0.15s;
}

.link-item:hover {
    border-color: var(--primary-300);
    background: var(--primary-50);
}

.link-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.link-community {
    font-weight: 500;
    color: var(--gray-900);
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.link-url {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--primary-600);
    text-decoration: none;
}

.link-url:hover {
    text-decoration: underline;
}

.platform-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.pi-vk {
    background: #0077FF;
}

.pi-max {
    background: #FF3347;
}

/* Animations */
.fade-in {
    animation: fadeIn 0.15s ease-out;
}

.scale-in {
    animation: scaleIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}
.form-input.token-detected { border-color:#22c55e; box-shadow:0 0 0 3px #dcfce7; }
.token-status { display:flex; align-items:flex-start; gap:.45rem; margin-top:.55rem; padding:.65rem .75rem; border-radius:var(--radius-sm); font-size:.78rem; line-height:1.4; }
.token-status.success { color:#166534; background:#f0fdf4; border:1px solid #bbf7d0; }
.token-status.error { color:#991b1b; background:#fef2f2; border:1px solid #fecaca; }
.nav-live-dot { width:7px; height:7px; margin-left:auto; border-radius:50%; background:#22c55e; box-shadow:0 0 0 3px #dcfce7; }

:focus-visible {
    outline: 3px solid rgba(79, 70, 229, .28);
    outline-offset: 2px;
}

.friendly-notice {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    margin: 0 0 1.25rem;
    padding: .9rem 1rem;
    color: #1e3a8a;
    background: linear-gradient(135deg, #eff6ff, #eef2ff);
    border: 1px solid #c7d2fe;
    border-radius: var(--radius-lg);
}
.friendly-notice-icon {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    color: white;
    background: var(--primary-600);
    border-radius: 50%;
    font-weight: 700;
}
.friendly-notice span { color: #475569; font-size: .875rem; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
