/* Social Orchestrator - Admin Panel Styles */
/* SaaS Moderno Design System */

:root {
    /* Colors - Rose/Red Palette (Instance 2) */
    --primary: #ec4899;
    --primary-dark: #be185d;
    --primary-light: #f472b6;
    --secondary: #f43f5e;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;

    /* Neutrals */
    --sidebar-bg: #831843;
    --page-bg: #fdf2f8;
    --card-bg: #ffffff;
    --text-primary: #500724;
    --text-muted: #9f1239;
    --border: #fbcfe8;

    /* Structure */
    --sidebar-width: 260px;
    --header-height: 64px;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg: 0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
}

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

html, body {
    height: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--page-bg);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 14px;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ===== LAYOUT ===== */

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #ffffff;
    z-index: 1000;
    overflow-y: auto;
    transition: transform 0.3s ease;
    box-shadow: 2px 0 8px rgba(0,0,0,0.08);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1rem;
    font-weight: 700;
    color: #ffffff;
    text-decoration: none;
    line-height: 1.2;
}

.sidebar-brand .logo {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.sidebar-nav {
    padding: 12px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
    font-size: 0.95rem;
    position: relative;
}

.nav-item:hover {
    color: #ffffff;
    background: rgba(99, 102, 241, 0.15);
}

.nav-item.active {
    color: #ffffff;
    background: rgba(99, 102, 241, 0.2);
    border-left: 3px solid var(--primary);
    padding-left: 13px;
}

.nav-item .icon {
    width: 20px;
    text-align: center;
    font-size: 1rem;
    flex-shrink: 0;
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.3s ease;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    height: var(--header-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.page-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.api-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--page-bg);
    border-radius: var(--radius);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Content Area */
.content {
    padding: 24px;
    flex: 1;
}

/* ===== LOGIN ===== */

.login-overlay {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, var(--page-bg) 0%, #e8ecf1 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.login-overlay.hidden {
    display: none;
}

.login-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 40px;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
}

.login-logo {
    font-size: 3rem;
    text-align: center;
    margin-bottom: 20px;
}

.login-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 8px;
}

.login-subtitle {
    font-size: 0.95rem;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 32px;
}

.login-form {
    margin-bottom: 20px;
}

.login-error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    padding: 12px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    margin-top: 12px;
    border-left: 4px solid var(--danger);
}

/* ===== BUTTONS ===== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 1px 3px rgba(99, 102, 241, 0.2);
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-secondary {
    background: var(--page-bg);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: #f8fafc;
}

.btn-success {
    background: var(--success);
    color: #ffffff;
}

.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: var(--danger);
    color: #ffffff;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-warning {
    background: var(--warning);
    color: #ffffff;
}

.btn-warning:hover {
    background: #d97706;
}

.btn-ghost {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--page-bg);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    padding: 8px;
    width: 36px;
    height: 36px;
    justify-content: center;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== FORMS ===== */

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.form-input,
.form-select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    background: var(--card-bg);
    color: var(--text-primary);
    transition: all 0.2s;
    font-family: inherit;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

/* ===== BADGES ===== */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 99px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.badge.success {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
}

.badge.warning {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
}

.badge.danger {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

.badge.primary {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

.badge.gray {
    background: rgba(100, 116, 139, 0.1);
    color: var(--text-muted);
}

.badge.info {
    background: rgba(14, 165, 233, 0.1);
    color: var(--secondary);
}

/* OAuth badges */
.badge.reauth {
    background: rgba(239, 68, 68, 0.15);
    color: #7f1d1d;
}

.badge.quarantine {
    background: rgba(245, 158, 11, 0.15);
    color: #78350f;
}

.badge.monitor {
    background: rgba(251, 191, 36, 0.15);
    color: #713f12;
}

.badge.ok {
    background: rgba(34, 197, 94, 0.15);
    color: #14532d;
}

/* ===== CARDS ===== */

.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    overflow: hidden;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fafbfc;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body {
    padding: 24px;
}

details.card {
    overflow: hidden;
}

details.card > summary.card-header {
    list-style: none;
    cursor: pointer;
    user-select: none;
}

details.card > summary.card-header::-webkit-details-marker {
    display: none;
}

details.card[open] > summary.card-header {
    border-bottom: 1px solid var(--border);
}

details.card > summary.card-header:hover {
    background: rgba(236, 72, 153, 0.04);
}

details.card > summary.card-header .card-title::after {
    content: "▾";
    margin-left: 8px;
    font-size: 0.85em;
    color: var(--text-muted);
}

details.card[open] > summary.card-header .card-title::after {
    content: "▴";
}

.card-body-tight {
    padding: 16px 24px;
}

.card.bordered-left {
    border-left: 4px solid var(--primary);
}

.card.bordered-left.danger {
    border-left-color: var(--danger);
}

.card.bordered-left.warning {
    border-left-color: var(--warning);
}

.card.bordered-left.success {
    border-left-color: var(--success);
}

/* ===== STAT CARDS ===== */

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

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.stat-icon.primary {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

.stat-icon.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.stat-icon.warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.stat-icon.danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.stat-icon.secondary {
    background: rgba(14, 165, 233, 0.1);
    color: var(--secondary);
}

.stat-content {
    flex: 1;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 8px;
    font-weight: 500;
}

.stat-value {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 4px;
}

.stat-trend {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.stat-trend.up {
    color: var(--success);
}

.stat-trend.down {
    color: var(--danger);
}

/* ===== TABLES ===== */

.table-container {
    overflow-x: auto;
    position: relative;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th {
    padding: 12px 16px;
    text-align: left;
    background: #f8f9fb;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.data-table tbody tr:hover {
    background: #f9fafb;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr.row-error {
    background: rgba(239, 68, 68, 0.06);
}

.data-table tr.row-warning {
    background: rgba(245, 158, 11, 0.06);
}

.data-table tr.row-success {
    background: rgba(16, 185, 129, 0.06);
}

.data-table code {
    background: var(--page-bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.85rem;
    color: #5b21b6;
}

/* ===== MODALES ===== */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    padding: 20px;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(-20px) scale(0.95);
    transition: all 0.3s;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
}

.modal-overlay.active .modal {
    transform: translateY(0) scale(1);
}

.modal.modal-lg {
    max-width: 700px;
}

.modal.modal-xl {
    max-width: 900px;
}

/* CSV Editor inline inputs */
.csv-input {
    border: 1px solid transparent !important;
    background: transparent !important;
    padding: 4px 6px !important;
    font-size: 13px !important;
    transition: border-color 0.15s, background 0.15s !important;
}

.csv-input:hover {
    border-color: var(--border) !important;
    background: #fafbfc !important;
}

.csv-input:focus {
    border-color: var(--primary) !important;
    background: #fff !important;
    box-shadow: 0 0 0 2px rgba(236, 72, 153, 0.1) !important;
    outline: none !important;
}

#csv-editor-table td {
    padding: 4px 6px !important;
    vertical-align: middle;
}

#csv-editor-table tr:hover {
    background: #fdf2f8;
}

.modal.modal-sm {
    max-width: 400px;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fafbfc;
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: #fafbfc;
}

.modal-body .form-group:last-child {
    margin-bottom: 0;
}

/* ===== ALERTS ===== */

.alert {
    padding: 14px 18px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    border-left: 4px solid;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
    border-left-color: var(--success);
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    border-left-color: var(--danger);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
    border-left-color: var(--warning);
}

.alert-info {
    background: rgba(14, 165, 233, 0.1);
    color: #0369a1;
    border-left-color: var(--secondary);
}

.alert-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
    margin-top: 2px;
}

/* ===== ACCORDIONS ===== */

.accordion {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 24px;
}

.accordion-item {
    border-bottom: 1px solid var(--border);
}

.accordion-item:last-child {
    border-bottom: none;
}

.accordion-header {
    padding: 16px 20px;
    background: #fafbfc;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s;
    font-weight: 500;
    color: var(--text-primary);
    user-select: none;
}

.accordion-header:hover {
    background: #f1f5f9;
}

.accordion-header.active {
    background: rgba(99, 102, 241, 0.05);
    border-bottom-color: var(--primary);
}

.accordion-toggle {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    font-size: 0.9rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.accordion-item.active .accordion-toggle {
    transform: rotate(180deg);
}

.accordion-body {
    padding: 20px;
    display: none;
    background: #fafbfc;
}

.accordion-item.active .accordion-body {
    display: block;
}

/* ===== GROUPS ===== */

.groups-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.group-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    transition: all 0.2s;
}

.group-card:hover {
    box-shadow: var(--shadow-lg);
}

.group-header {
    margin-bottom: 12px;
}

.group-name {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.group-description {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 12px;
    line-height: 1.4;
}

.group-stats {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.group-stat {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
}

.group-stat-value {
    font-weight: 600;
    color: var(--text-primary);
}

.group-stat-label {
    color: var(--text-muted);
}

.group-actions {
    display: flex;
    gap: 8px;
}

.group-actions .btn {
    flex: 1;
    justify-content: center;
}

.page-item {
    padding: 12px;
    background: var(--page-bg);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.page-item-name {
    color: var(--text-primary);
    font-weight: 500;
}

.pages-list {
    margin-bottom: 0;
}

/* ===== FILTERS ===== */

.filters-bar {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
}

.filter-group .form-input,
.filter-group .form-select {
    width: auto;
    min-width: 120px;
    padding: 6px 10px;
    font-size: 0.85rem;
}

.toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    font-size: 0.9rem;
}

.toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
}

/* ===== EMPTY STATES ===== */

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state-text {
    font-size: 0.95rem;
    margin-bottom: 20px;
}

.empty-state .btn {
    margin-top: 12px;
}

/* ===== LOADING ===== */

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

.btn.loading,
.btn:disabled.loading {
    opacity: 0.7;
    cursor: not-allowed;
    pointer-events: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--page-bg);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== CHARTS ===== */

.chart-container {
    position: relative;
    height: 300px;
    margin-bottom: 20px;
}

.chart-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
}

/* ===== UTILITIES ===== */

.flex-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-muted);
}

.text-primary {
    color: var(--primary);
}

.text-danger {
    color: var(--danger);
}

.text-success {
    color: var(--success);
}

.text-warning {
    color: var(--warning);
}

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }

.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.gap-3 { gap: 24px; }

.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

/* ===== RESPONSIVE ===== */

@media (max-width: 768px) {
    .sidebar {
        width: min(86vw, 320px);
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .menu-toggle {
        display: block;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .stat-card {
        padding: 18px;
        align-items: flex-start;
    }

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

    .filters-bar {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

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

    .table-container {
        margin: 0 -16px;
        padding: 0 16px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .data-table {
        min-width: 760px;
        font-size: 0.8rem;
    }

    .data-table th,
    .data-table td {
        padding: 8px 10px;
    }

    .actions-cell,
    .group-actions,
    .flex.gap-2 {
        flex-direction: column;
        align-items: stretch;
    }

    .actions-cell .btn,
    .group-actions .btn,
    .flex.gap-2 .btn {
        width: 100%;
    }

    .modal {
        max-width: calc(100% - 24px);
        max-height: calc(100vh - 24px);
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 16px;
    }

    .modal-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .modal-footer .btn {
        width: 100%;
    }

    .data-table {
        font-size: 0.8rem;
    }

    .data-table th,
    .data-table td {
        padding: 8px 12px;
    }

    .card {
        margin-bottom: 16px;
    }

    .card-body,
    .card-header {
        padding: 16px;
    }

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

    .group-card {
        padding: 16px;
    }

    .group-stats {
        flex-wrap: wrap;
        gap: 8px;
    }

    .login-card {
        padding: 30px 24px;
        max-width: calc(100% - 40px);
    }
}

@media (max-width: 480px) {
    :root {
        --sidebar-width: 0;
        --header-height: 56px;
    }

    body {
        font-size: 13px;
    }

    .sidebar {
        width: 92vw;
        max-width: 300px;
    }

    .sidebar-nav {
        padding: 8px 0;
    }

    .nav-item {
        padding: 10px 12px;
        font-size: 0.85rem;
        gap: 10px;
    }

    .nav-item span {
        display: none;
    }

    .nav-item.active {
        padding-left: 12px;
        border-left: 3px solid var(--primary);
    }

    .header {
        padding: 0 12px;
        gap: 8px;
    }

    .header-right {
        display: none;
    }

    .api-status {
        display: none;
    }

    .content {
        padding: 12px;
    }

    .card-header,
    .card-body {
        padding: 14px;
    }

    .card-title {
        font-size: 1rem;
    }

    .page-title {
        font-size: 1rem;
    }

    .stat-card {
        flex-direction: column;
        text-align: center;
        padding: 14px;
    }

    .stat-icon {
        width: 48px;
        height: 48px;
        font-size: 1.2rem;
        margin: 0 auto 8px;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .stat-label {
        font-size: 0.75rem;
    }

    .stats-grid {
        gap: 12px;
    }

    .filters-bar {
        grid-template-columns: 1fr;
    }

    .btn {
        width: 100%;
        padding: 10px 16px;
        font-size: 0.9rem;
    }

    .btn-sm {
        padding: 6px 12px;
    }

    .btn-icon {
        width: 32px;
        height: 32px;
    }

    .table-container {
        margin: 0 -12px;
        padding: 0 12px;
    }

    .data-table {
        min-width: 680px;
        font-size: 0.75rem;
    }

    .data-table th,
    .data-table td {
        padding: 7px 8px;
    }

    .actions-cell .btn,
    .group-actions .btn,
    .flex.gap-2 .btn {
        font-size: 0.85rem;
        padding: 9px 12px;
    }

    .modal {
        max-width: calc(100% - 12px);
        margin: 6px;
        border-radius: 14px;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 16px;
    }

    .modal-footer {
        flex-direction: column;
        gap: 8px;
    }

    .modal-footer .btn {
        width: 100%;
        margin: 0;
    }

    .oauth-group-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .oauth-group-right {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .oauth-error-codes {
        gap: 6px;
    }

    .accordion-header,
    .accordion-body {
        padding: 14px;
    }

    .login-card {
        padding: 24px 16px;
        max-width: calc(100% - 32px);
    }

    .login-title {
        font-size: 1.5rem;
    }

    .login-logo {
        font-size: 2.5rem;
    }

    .form-group {
        margin-bottom: 16px;
    }

    .form-label {
        font-size: 0.85rem;
        margin-bottom: 6px;
    }

    .form-input,
    .form-select {
        padding: 10px 12px;
        font-size: 0.9rem;
    }

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

    .card {
        margin-bottom: 12px;
        border-radius: 8px;
    }

    .card-header {
        padding: 14px;
    }

    .card-body {
        padding: 16px;
    }

    .card-body-tight {
        padding: 12px 16px;
    }

    .card-title {
        font-size: 1rem;
    }

    .data-table {
        font-size: 0.75rem;
    }

    .data-table th,
    .data-table td {
        padding: 8px 10px;
    }

    .table-container {
        margin: 0 -16px;
    }

    .badge {
        font-size: 0.65rem;
        padding: 3px 8px;
    }

    .groups-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .group-card {
        padding: 16px;
    }

    .group-name {
        font-size: 1rem;
    }

    .group-description {
        font-size: 0.85rem;
    }

    .group-stat {
        font-size: 0.8rem;
    }

    .group-actions {
        gap: 6px;
    }

    .group-actions .btn {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    .filters-bar {
        flex-direction: column;
        align-items: stretch;
        padding: 12px;
        gap: 10px;
    }

    .filter-group {
        width: 100%;
        flex-direction: column;
        gap: 6px;
    }

    .filter-group label {
        font-size: 0.8rem;
    }

    .filter-group .form-input,
    .filter-group .form-select {
        width: 100%;
        min-width: auto;
        font-size: 0.9rem;
    }

    .toggle {
        font-size: 0.85rem;
    }

    .toggle input[type="checkbox"] {
        width: 16px;
        height: 16px;
    }

    .chart-container {
        height: 250px;
    }

    .empty-state {
        padding: 24px 16px;
    }

    .empty-state-icon {
        font-size: 2.5rem;
    }

    .empty-state-title {
        font-size: 1rem;
    }

    .empty-state-text {
        font-size: 0.9rem;
    }

    .alert {
        padding: 12px 14px;
        font-size: 0.9rem;
        gap: 10px;
    }

    .alert-icon {
        font-size: 1rem;
    }

    .page-item {
        padding: 10px;
        font-size: 0.85rem;
    }

    .sidebar-brand {
        gap: 8px;
    }

    .sidebar-brand .logo {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .sidebar-brand span {
        display: none;
    }
}

/* ===== APIFY URL MODAL ===== */

.apify-url-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.apify-url-row .form-input {
    flex: 1;
}

.apify-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    gap: 16px;
    color: var(--text-muted);
}

.apify-loading p {
    margin: 0;
    font-size: 14px;
}

.apify-status-pill {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
}

.apify-status-pill.ok {
    background: rgba(16, 185, 129, 0.12);
    color: #059669;
}

.apify-status-pill.warn {
    background: rgba(245, 158, 11, 0.12);
    color: #b45309;
}

.apify-status-pill.err {
    background: rgba(239, 68, 68, 0.12);
    color: #b91c1c;
}

.apify-source-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.apify-source-badge.apify {
    background: rgba(99, 102, 241, 0.12);
    color: #4f46e5;
}

.apify-source-badge.graph_api {
    background: rgba(14, 165, 233, 0.12);
    color: #0369a1;
}

.apify-source-badge.partial {
    background: rgba(245, 158, 11, 0.12);
    color: #b45309;
}

.apify-metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-top: 12px;
}

@media (max-width: 700px) {
    .apify-metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.apify-metric-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.apify-metric-card .apify-metric-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 500;
}

.apify-metric-card .apify-metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.apify-metric-card .apify-metric-sub {
    font-size: 11px;
    color: var(--text-muted);
}

.apify-metric-card.likes .apify-metric-value { color: #2563eb; }
.apify-metric-card.comments .apify-metric-value { color: #16a34a; }
.apify-metric-card.shares .apify-metric-value { color: #ea580c; }
.apify-metric-card.views .apify-metric-value { color: #9333ea; }

.apify-section {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.apify-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 10px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.apify-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.apify-reaction-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--bg-secondary, #f3f4f6);
    border: 1px solid var(--border);
    font-size: 13px;
}

.apify-reaction-pill .emoji {
    font-size: 15px;
}

.apify-reaction-pill .count {
    font-weight: 600;
    color: var(--text-primary);
}

.apify-reaction-pill.zero {
    opacity: 0.45;
}

.apify-content-preview {
    background: var(--bg-secondary, #f9fafb);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-primary);
    max-height: 140px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.apify-content-preview.empty {
    color: var(--text-muted);
    font-style: italic;
}

.apify-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.apify-meta-row strong {
    color: var(--text-primary);
    font-weight: 500;
}

.apify-meta-row code {
    background: var(--bg-secondary, #f3f4f6);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 11px;
}

.apify-task-creator {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-end;
}

.apify-task-creator .form-group {
    margin-bottom: 0;
    flex: 1;
    min-width: 120px;
}

.apify-task-creator .form-group.action {
    flex: 0 0 140px;
}

.apify-task-creator .form-group.num {
    flex: 0 0 90px;
}

.apify-task-creator .form-group.track {
    flex: 0 0 auto;
    margin-bottom: 8px;
}

.apify-task-creator .form-group label {
    font-size: 11px;
    margin-bottom: 4px;
}

.apify-task-creator .form-group input,
.apify-task-creator .form-group select {
    font-size: 13px;
    padding: 7px 10px;
}

.apify-warnings {
    margin-top: 12px;
}

.apify-warnings ul {
    margin: 4px 0 0 18px;
    padding: 0;
    font-size: 12px;
    color: var(--text-muted);
}

.apify-warnings li {
    margin: 2px 0;
}

.apify-thumb {
    max-width: 100%;
    max-height: 200px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: block;
    margin-bottom: 10px;
}

.apify-thumb-wrap {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 10px;
}

.apify-thumb-wrap .apify-meta {
    flex: 1;
}
