:root {
    --bg: #09090b; --bg-alt: #18181b; --surface: #1f1f23; --surface-hover: #27272a;
    --text: #fafafa; --text-muted: #a1a1aa; --text-dim: #71717a;
    --primary: #3b82f6; --primary-hover: #2563eb; --primary-soft: rgba(59,130,246,0.15);
    --accent: #10b981; --accent-hover: #059669; --accent-soft: rgba(16,185,129,0.15);
    --border: #27272a; --border-light: #3f3f46;
    --warning: #f59e0b; --purple: #8b5cf6; --red: #ef4444;
    --radius: 8px; --radius-lg: 12px; --radius-xl: 16px;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.3), 0 2px 4px -2px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4), 0 4px 6px -4px rgba(0,0,0,0.4);
    --transition: 0.2s ease;
    --sidebar-w: 240px;
    --sidebar-collapsed-w: 64px;
    --topbar-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; overflow: hidden; height: 100%; }
body { font-family: 'Inter', -apple-system, sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; height: 100%; overflow: hidden; }
h1, h2, h3, h4 { font-family: 'Space Grotesk', sans-serif; font-weight: 600; line-height: 1.3; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }
button, input, select, textarea { font: inherit; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(12px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes dotPulse { 0%, 100% { box-shadow: 0 0 0 0 currentColor; opacity: 1; } 50% { box-shadow: 0 0 0 4px transparent; opacity: 0.7; } }
@keyframes countUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes shake { 0%,100%{transform:translateX(0)} 20%,60%{transform:translateX(-4px)} 40%,80%{transform:translateX(4px)} }

.view { display: none; height: 100%; overflow-y: auto; }
.view.active { display: block; animation: fadeIn 0.25s ease; }

#loginPage { display: none; position: fixed; inset: 0; background: radial-gradient(ellipse at 30% 20%, rgba(59,130,246,0.12) 0%, transparent 50%), radial-gradient(ellipse at 70% 80%, rgba(139,92,246,0.08) 0%, transparent 50%), var(--bg); align-items: center; justify-content: center; z-index: 9999; }
#loginPage.active { display: flex; }

.login-card {
    background: rgba(31,31,35,0.9);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 20px;
    padding: 40px 36px 32px;
    width: 100%;
    max-width: 400px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 24px 80px rgba(0,0,0,0.6), 0 0 0 1px rgba(59,130,246,0.08);
    animation: modalIn 0.35s cubic-bezier(0.34,1.4,0.64,1);
    position: relative;
    overflow: hidden;
}
.login-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary), var(--purple), transparent);
    opacity: 0.7;
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.login-brand-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--primary-soft); border: 1px solid rgba(59,130,246,0.25); display: flex; align-items: center; justify-content: center; font-size: 1.3rem; flex-shrink: 0; }
.login-brand-name { font-family: 'Space Grotesk', sans-serif; font-size: 1.1rem; font-weight: 700; color: var(--text); letter-spacing: -0.02em; }
.login-brand-sub { font-size: 0.7rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.login-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 6px; }
.login-subtitle { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 28px; }
.form-field { margin-bottom: 14px; }
.form-field label { display: block; font-size: 0.8rem; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; letter-spacing: 0.2px; }
.form-field input {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 9px;
    background: rgba(255,255,255,0.03);
    color: var(--text);
    font-size: 0.875rem;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    outline: none;
}
.form-field input::placeholder { color: rgba(255,255,255,0.2); }
.form-field input:focus { border-color: rgba(59,130,246,0.5); background: rgba(59,130,246,0.04); box-shadow: 0 0 0 3px rgba(59,130,246,0.08); }
.login-error { font-size: 0.8rem; color: #ef4444; background: rgba(239,68,68,0.08); border: 1px solid rgba(239,68,68,0.15); border-radius: var(--radius); padding: 8px 12px; margin-bottom: 14px; display: none; }
.login-error.visible { display: block; }
.btn-login {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--primary) 0%, #2563eb 100%);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: transform 0.15s, box-shadow 0.2s, opacity 0.2s;
    letter-spacing: 0.2px;
    margin-top: 4px;
}
.btn-login::after { content: ''; position: absolute; top: 0; left: -100%; width: 55%; height: 100%; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.12), transparent); transform: skewX(-20deg); transition: left 0.55s ease; }
.btn-login:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(59,130,246,0.4); }
.btn-login:hover::after { left: 160%; }
.btn-login:active { transform: translateY(0); }
.btn-login:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-login .btn-spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite; display: none; margin: 0 auto; }
.btn-login.loading .btn-spinner { display: block; }
.btn-login.loading .btn-label { display: none; }
.code-sent-msg { font-size: 0.85rem; color: var(--accent); margin-bottom: 16px; text-align: center; }
.btn-back { background: none; border: none; color: var(--text-muted); font-size: 0.8rem; cursor: pointer; margin-top: 12px; width: 100%; text-align: center; padding: 8px; transition: color 0.2s ease; }
.btn-back:hover { color: var(--text); }

#app { display: none; height: 100vh; overflow: hidden; }
#app.active { display: flex; }

.sidebar {
    width: var(--sidebar-w);
    height: 100vh;
    background: rgba(15,15,18,0.95);
    border-right: 1px solid var(--border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.3s cubic-bezier(0.4,0,0.2,1);
    overflow: hidden;
    z-index: 50;
    position: relative;
}
.sidebar.collapsed { width: var(--sidebar-collapsed-w); }
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    height: var(--topbar-h);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    overflow: hidden;
}
.sidebar-brand-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--primary-soft); border: 1px solid rgba(59,130,246,0.25); display: flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0; }
.sidebar-brand-text { white-space: nowrap; overflow: hidden; transition: opacity 0.2s; }
.sidebar-brand-name { font-family: 'Space Grotesk', sans-serif; font-size: 0.95rem; font-weight: 700; color: var(--text); }
.sidebar-brand-sub { font-size: 0.65rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.sidebar.collapsed .sidebar-brand-text { opacity: 0; pointer-events: none; }
.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; overflow-x: hidden; }
.sidebar-nav::-webkit-scrollbar { width: 0; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition);
    white-space: nowrap;
    overflow: hidden;
    position: relative;
    margin-bottom: 2px;
    border: 1px solid transparent;
}
.nav-item:hover { color: var(--text); background: rgba(255,255,255,0.04); border-color: transparent; }
.nav-item.active { color: var(--text); background: var(--primary-soft); border-color: rgba(59,130,246,0.2); }
.nav-item.active::before { content: ''; position: absolute; left: 0; top: 25%; bottom: 25%; width: 3px; border-radius: 0 3px 3px 0; background: var(--primary); }
.nav-item-icon { font-size: 1.1rem; flex-shrink: 0; width: 20px; text-align: center; }
.nav-item-label { flex: 1; transition: opacity 0.2s; }
.sidebar.collapsed .nav-item-label { opacity: 0; pointer-events: none; }
.nav-divider { height: 1px; background: var(--border); margin: 8px 4px; }
.nav-section-label { font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-dim); padding: 8px 12px 4px; white-space: nowrap; overflow: hidden; transition: opacity 0.2s; }
.sidebar.collapsed .nav-section-label { opacity: 0; }
.sidebar-footer { padding: 8px 8px 12px; border-top: 1px solid var(--border); flex-shrink: 0; }
.nav-item-new-post { background: linear-gradient(135deg, var(--primary) 0%, #2563eb 100%); color: #fff; border: none; }
.nav-item-new-post:hover { background: linear-gradient(135deg, var(--primary-hover) 0%, #1d4ed8 100%); color: #fff; transform: translateY(-1px); box-shadow: 0 4px 16px rgba(59,130,246,0.4); }
.nav-item-new-post.active { background: linear-gradient(135deg, var(--primary) 0%, #2563eb 100%); color: #fff; }
.nav-item-new-post.active::before { display: none; }
.sidebar-toggle-btn { background: none; border: 1px solid var(--border); border-radius: var(--radius); padding: 6px; cursor: pointer; color: var(--text-dim); display: flex; align-items: center; justify-content: center; transition: all var(--transition); width: 100%; margin-bottom: 6px; }
.sidebar-toggle-btn:hover { color: var(--text); background: var(--surface-hover); border-color: var(--border-light); }

.main-wrap { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

.topbar {
    height: var(--topbar-h);
    background: rgba(9,9,11,0.8);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    flex-shrink: 0;
    z-index: 40;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-title { font-family: 'Space Grotesk', sans-serif; font-size: 1.1rem; font-weight: 600; color: var(--text); }
.topbar-breadcrumb { font-size: 0.8rem; color: var(--text-dim); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-user { display: flex; align-items: center; gap: 10px; padding: 6px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; transition: all var(--transition); }
.topbar-user:hover { background: var(--surface-hover); border-color: var(--border-light); }
.topbar-avatar { width: 28px; height: 28px; background: linear-gradient(135deg, var(--primary) 0%, var(--purple) 100%); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 0.75rem; flex-shrink: 0; }
.topbar-user-name { font-size: 0.8rem; font-weight: 500; color: var(--text); }
.topbar-logout-btn { background: none; border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 12px; color: var(--text-dim); font-size: 0.8rem; cursor: pointer; transition: all var(--transition); }
.topbar-logout-btn:hover { color: #ef4444; border-color: rgba(239,68,68,0.3); background: rgba(239,68,68,0.06); }
.topbar-refresh-btn { background: none; border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 10px; color: var(--text-dim); font-size: 0.85rem; cursor: pointer; transition: all var(--transition); display: flex; align-items: center; justify-content: center; }
.topbar-refresh-btn:hover { color: var(--text); background: var(--surface-hover); }
.topbar-refresh-btn.spinning { animation: spin 0.8s linear infinite; }

.main-content { flex: 1; overflow-y: auto; padding: 24px; }
.main-content::-webkit-scrollbar { width: 6px; }
.main-content::-webkit-scrollbar-track { background: transparent; }
.main-content::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }

.page-view { display: none; animation: fadeInUp 0.25s ease; }
.page-view.active { display: block; }

.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 20px 22px;
    cursor: default;
    transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
}
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; bottom: 0; width: 3px; border-radius: 0; }
.stat-card::after { content: ''; position: absolute; top: -120%; left: -10%; right: -10%; height: 60%; background: linear-gradient(to bottom, transparent, rgba(255,255,255,0.02), transparent); transform: skewY(-4deg); transition: top 0.55s ease; pointer-events: none; }
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.stat-card:hover::after { top: 160%; }
.stat-card.blue::before { background: var(--primary); box-shadow: 0 0 12px rgba(59,130,246,0.5); }
.stat-card.blue { border-color: rgba(59,130,246,0.15); }
.stat-card.blue:hover { border-color: rgba(59,130,246,0.3); box-shadow: 0 12px 32px rgba(59,130,246,0.1); }
.stat-card.green::before { background: var(--accent); box-shadow: 0 0 12px rgba(16,185,129,0.5); }
.stat-card.green { border-color: rgba(16,185,129,0.15); }
.stat-card.green:hover { border-color: rgba(16,185,129,0.3); box-shadow: 0 12px 32px rgba(16,185,129,0.1); }
.stat-card.purple::before { background: var(--purple); box-shadow: 0 0 12px rgba(139,92,246,0.5); }
.stat-card.purple { border-color: rgba(139,92,246,0.15); }
.stat-card.purple:hover { border-color: rgba(139,92,246,0.3); box-shadow: 0 12px 32px rgba(139,92,246,0.1); }
.stat-card.red::before { background: var(--red); box-shadow: 0 0 12px rgba(239,68,68,0.5); }
.stat-card.red { border-color: rgba(239,68,68,0.15); }
.stat-card.red:hover { border-color: rgba(239,68,68,0.3); box-shadow: 0 12px 32px rgba(239,68,68,0.1); }
.stat-icon { font-size: 1.3rem; margin-bottom: 12px; display: inline-block; }
.stat-value { font-family: 'Space Grotesk', sans-serif; font-size: 2.2rem; font-weight: 700; margin-bottom: 4px; animation: countUp 0.4s ease; }
.stat-card.blue .stat-value { color: var(--primary); }
.stat-card.green .stat-value { color: var(--accent); }
.stat-card.purple .stat-value { color: var(--purple); }
.stat-card.red .stat-value { color: var(--red); }
.stat-label { font-size: 0.8rem; color: var(--text-muted); letter-spacing: 0.2px; }
.stat-card.loading .stat-value { background: linear-gradient(90deg, var(--surface) 25%, var(--bg-alt) 37%, var(--surface-hover) 50%, var(--bg-alt) 63%, var(--surface) 75%); background-size: 400% 100%; animation: shimmer 1.8s ease infinite; border-radius: 6px; color: transparent; width: 70px; height: 36px; display: block; }
.stat-card.loading .stat-label { background: linear-gradient(90deg, var(--surface) 25%, var(--bg-alt) 37%, var(--surface-hover) 50%, var(--bg-alt) 63%, var(--surface) 75%); background-size: 400% 100%; animation: shimmer 1.8s ease infinite; border-radius: 4px; color: transparent; width: 110px; height: 14px; display: block; }

.dashboard-grid { display: grid; grid-template-columns: 1fr 320px; gap: 20px; margin-bottom: 24px; }
.section-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 20px; }
.section-card-title { font-family: 'Space Grotesk', sans-serif; font-size: 0.95rem; font-weight: 600; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; color: var(--text); }
.section-card-title .card-action { font-size: 0.75rem; color: var(--primary); cursor: pointer; font-weight: 500; background: none; border: none; transition: color var(--transition); }
.section-card-title .card-action:hover { color: var(--primary-hover); }

.calendar-wrap { position: relative; }
.calendar-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.calendar-nav-btn { background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 12px; cursor: pointer; color: var(--text-muted); font-size: 0.85rem; transition: all var(--transition); }
.calendar-nav-btn:hover { color: var(--text); background: var(--surface-hover); border-color: var(--border-light); }
.calendar-month-label { font-family: 'Space Grotesk', sans-serif; font-size: 1rem; font-weight: 600; color: var(--text); }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.calendar-day-header { text-align: center; font-size: 0.7rem; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; padding: 6px 0; }
.calendar-cell {
    aspect-ratio: 1;
    border-radius: 8px;
    padding: 4px;
    cursor: pointer;
    transition: background var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    min-height: 44px;
}
.calendar-cell:hover { background: rgba(255,255,255,0.04); }
.calendar-cell.empty { cursor: default; }
.calendar-cell.empty:hover { background: transparent; }
.calendar-cell.today { border: 1px solid rgba(59,130,246,0.4); background: rgba(59,130,246,0.06); }
.calendar-cell.today .day-num { color: var(--primary); font-weight: 700; }
.day-num { font-size: 0.75rem; font-weight: 500; color: var(--text-muted); margin-bottom: 2px; }
.day-dots { display: flex; flex-wrap: wrap; gap: 2px; justify-content: center; padding: 0 2px; }
.day-dot { width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }
.day-dot.published { background: var(--accent); }
.day-dot.scheduled { background: var(--primary); }
.day-dot.notified { background: var(--warning); }
.day-dot.failed { background: var(--red); }
.day-dot.cancelled { background: var(--text-dim); }

.timeline-wrap { display: flex; flex-direction: column; gap: 0; max-height: 380px; overflow-y: auto; }
.timeline-wrap::-webkit-scrollbar { width: 4px; }
.timeline-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.timeline-item { display: flex; gap: 12px; padding: 10px 0; position: relative; }
.timeline-item:not(:last-child)::after { content: ''; position: absolute; left: 15px; top: 36px; bottom: 0; width: 1px; background: var(--border); }
.timeline-dot { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 0.75rem; }
.timeline-dot.scheduled { background: var(--primary-soft); border: 1px solid rgba(59,130,246,0.3); }
.timeline-dot.published { background: var(--accent-soft); border: 1px solid rgba(16,185,129,0.3); }
.timeline-dot.failed { background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.25); }
.timeline-dot.notified { background: rgba(245,158,11,0.12); border: 1px solid rgba(245,158,11,0.25); }
.timeline-content { flex: 1; min-width: 0; }
.timeline-time { font-size: 0.7rem; color: var(--text-dim); margin-bottom: 2px; }
.timeline-title { font-size: 0.825rem; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 3px; }
.timeline-platforms { display: flex; gap: 4px; }
.platform-icon { font-size: 0.65rem; padding: 1px 5px; border-radius: 4px; background: rgba(255,255,255,0.06); color: var(--text-dim); }

.history-table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); overflow: hidden; }
.history-table-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.history-table-title { font-family: 'Space Grotesk', sans-serif; font-size: 0.95rem; font-weight: 600; }
.history-filters { display: flex; gap: 8px; align-items: center; }
.filter-select { background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 10px; color: var(--text-muted); font-size: 0.8rem; cursor: pointer; outline: none; transition: border-color var(--transition); }
.filter-select:focus { border-color: rgba(59,130,246,0.4); color: var(--text); }
.filter-select option { background: var(--surface); }
table { width: 100%; border-collapse: collapse; }
thead th { padding: 12px 16px; text-align: left; font-size: 0.75rem; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border); background: rgba(0,0,0,0.2); }
tbody tr { border-bottom: 1px solid var(--border); transition: background var(--transition); cursor: pointer; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.025); }
tbody tr:nth-child(even) { background: rgba(0,0,0,0.12); }
tbody tr:nth-child(even):hover { background: rgba(255,255,255,0.025); }
tbody td { padding: 12px 16px; font-size: 0.85rem; color: var(--text-muted); vertical-align: middle; }
tbody td:first-child { color: var(--text); font-weight: 500; }
.td-caption { max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.td-platforms { display: flex; gap: 4px; flex-wrap: wrap; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: capitalize;
    white-space: nowrap;
}
.badge-scheduled { background: rgba(59,130,246,0.15); color: var(--primary); border: 1px solid rgba(59,130,246,0.25); }
.badge-scheduled::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--primary); animation: dotPulse 1.5s ease infinite; display: inline-block; }
.badge-notified { background: rgba(245,158,11,0.15); color: var(--warning); border: 1px solid rgba(245,158,11,0.25); }
.badge-publishing { background: rgba(139,92,246,0.15); color: var(--purple); border: 1px solid rgba(139,92,246,0.25); }
.badge-publishing::before { content: '⟳'; font-size: 0.8rem; display: inline-block; animation: spin 1s linear infinite; }
.badge-published { background: rgba(16,185,129,0.15); color: var(--accent); border: 1px solid rgba(16,185,129,0.25); }
.badge-failed { background: rgba(239,68,68,0.15); color: var(--red); border: 1px solid rgba(239,68,68,0.25); }
.badge-cancelled { background: rgba(113,113,122,0.15); color: var(--text-dim); border: 1px solid rgba(113,113,122,0.2); }

.pagination { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; border-top: 1px solid var(--border); }
.pagination-info { font-size: 0.8rem; color: var(--text-dim); }
.pagination-btns { display: flex; gap: 4px; }
.page-btn { padding: 5px 10px; border: 1px solid var(--border); border-radius: 6px; background: transparent; color: var(--text-muted); font-size: 0.8rem; cursor: pointer; transition: all var(--transition); }
.page-btn:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border-light); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.empty-state { text-align: center; padding: 48px 24px; color: var(--text-dim); }
.empty-state-icon { font-size: 2.5rem; margin-bottom: 12px; opacity: 0.5; }
.empty-state-title { font-size: 1rem; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.empty-state-desc { font-size: 0.85rem; }

.skeleton { background: linear-gradient(90deg, var(--surface) 25%, var(--bg-alt) 37%, var(--surface-hover) 50%, var(--bg-alt) 63%, var(--surface) 75%); background-size: 400% 100%; animation: shimmer 1.8s ease infinite; border-radius: var(--radius); }

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--surface);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 20px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.28s cubic-bezier(0.34,1.4,0.64,1);
    position: relative;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.modal::-webkit-scrollbar { width: 4px; }
.modal::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.modal::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary), var(--purple));
    border-radius: 20px 20px 0 0;
}
.modal-header { padding: 20px 24px 0; display: flex; align-items: center; justify-content: space-between; }
.modal-header-title { font-family: 'Space Grotesk', sans-serif; font-size: 1.15rem; font-weight: 700; }
.modal-close-btn { background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08); border-radius: 8px; color: var(--text-dim); cursor: pointer; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; transition: all var(--transition); line-height: 1; }
.modal-close-btn:hover { background: rgba(255,255,255,0.08); color: var(--text); }
.modal-body { padding: 20px 24px 24px; }
.modal-section-label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-dim); margin-bottom: 10px; }

.upload-zone {
    border: 2px dashed var(--border-light);
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: rgba(255,255,255,0.01);
    margin-bottom: 16px;
}
.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--primary);
    background: rgba(59,130,246,0.04);
}
.upload-zone.drag-over { border-color: var(--accent); background: rgba(16,185,129,0.04); }
.upload-zone-icon { font-size: 2rem; margin-bottom: 8px; opacity: 0.6; }
.upload-zone-text { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 4px; }
.upload-zone-text strong { color: var(--primary); }
.upload-zone-sub { font-size: 0.75rem; color: var(--text-dim); }
.upload-zone input[type=file] { display: none; }
.media-preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; margin-bottom: 16px; }
.media-thumb {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    aspect-ratio: 1;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    cursor: default;
}
.media-thumb img, .media-thumb video { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s ease; }
.media-thumb:hover img, .media-thumb:hover video { transform: scale(1.05); }
.media-thumb-remove { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,0.7); border: none; border-radius: 50%; width: 20px; height: 20px; color: #fff; cursor: pointer; font-size: 0.7rem; display: flex; align-items: center; justify-content: center; transition: background var(--transition); }
.media-thumb-remove:hover { background: var(--red); }

.form-field-modal { margin-bottom: 14px; }
.form-field-modal label { display: block; font-size: 0.8rem; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; }
.form-field-modal textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 9px;
    background: rgba(255,255,255,0.03);
    color: var(--text);
    font-size: 0.875rem;
    resize: vertical;
    min-height: 80px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    line-height: 1.5;
}
.form-field-modal textarea[dir=rtl] { text-align: right; font-size: 0.9rem; }
.form-field-modal textarea::placeholder { color: rgba(255,255,255,0.2); }
.form-field-modal textarea:focus { border-color: rgba(59,130,246,0.5); background: rgba(59,130,246,0.04); box-shadow: 0 0 0 3px rgba(59,130,246,0.08); }
.form-field-modal input[type=datetime-local] {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 9px;
    background: rgba(255,255,255,0.03);
    color: var(--text);
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    color-scheme: dark;
}
.form-field-modal input[type=datetime-local]:focus { border-color: rgba(59,130,246,0.5); box-shadow: 0 0 0 3px rgba(59,130,246,0.08); }

.platform-toggles { display: flex; gap: 8px; flex-wrap: wrap; }
.platform-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 50px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    user-select: none;
}
.platform-pill:hover { border-color: var(--border-light); color: var(--text); background: rgba(255,255,255,0.03); }
.platform-pill.active { border-color: rgba(59,130,246,0.4); background: var(--primary-soft); color: var(--primary); }
.platform-pill.active.instagram { border-color: rgba(225,48,108,0.4); background: rgba(225,48,108,0.12); color: #e1306c; }
.platform-pill.active.tiktok { border-color: rgba(105,201,208,0.4); background: rgba(105,201,208,0.12); color: #69c9d0; }
.platform-pill-icon { font-size: 1rem; }

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 18px; border-radius: var(--radius); font-weight: 500; font-size: 0.875rem; cursor: pointer; transition: all var(--transition); border: none; }
.btn-primary { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%); color: white; position: relative; overflow: hidden; }
.btn-primary::after { content: ''; position: absolute; top: 0; left: -100%; width: 55%; height: 100%; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.12), transparent); transform: skewX(-20deg); transition: left 0.5s ease; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(59,130,246,0.4); }
.btn-primary:hover::after { left: 160%; }
.btn-secondary { background: var(--bg-alt); color: var(--text-muted); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--border-light); color: var(--text); }
.btn-danger { background: rgba(239,68,68,0.1); color: var(--red); border: 1px solid rgba(239,68,68,0.2); }
.btn-danger:hover { background: rgba(239,68,68,0.18); border-color: rgba(239,68,68,0.35); transform: translateY(-1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-spinner { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite; }

.post-detail-meta { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.post-detail-meta-item { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--text-muted); }
.post-detail-meta-item strong { color: var(--text); }
.post-detail-media { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; margin-bottom: 16px; }
.post-detail-img { border-radius: var(--radius); overflow: hidden; aspect-ratio: 1; background: var(--bg-alt); border: 1px solid var(--border); }
.post-detail-img img, .post-detail-img video { width: 100%; height: 100%; object-fit: cover; cursor: pointer; transition: transform 0.2s ease, opacity 0.2s ease; }
.post-detail-img img:hover, .post-detail-img video:hover { opacity: 0.8; transform: scale(1.03); }
.lightbox-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.92); backdrop-filter: blur(8px); z-index: 12000; display: none; align-items: center; justify-content: center; flex-direction: column; }
.lightbox-overlay.active { display: flex; animation: fadeIn 0.2s ease; }
.lightbox-content { max-width: 90vw; max-height: 80vh; border-radius: var(--radius-lg); overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,0.6); }
.lightbox-content img { max-width: 90vw; max-height: 80vh; object-fit: contain; display: block; }
.lightbox-content video { max-width: 90vw; max-height: 80vh; object-fit: contain; display: block; }
.lightbox-close { position: absolute; top: 20px; right: 24px; width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.15); color: #fff; font-size: 1.2rem; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background 0.2s ease; }
.lightbox-close:hover { background: rgba(255,255,255,0.2); }
.lightbox-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.12); color: #fff; font-size: 1.3rem; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background 0.2s ease; }
.lightbox-nav:hover { background: rgba(255,255,255,0.18); }
.lightbox-nav.prev { left: 20px; }
.lightbox-nav.next { right: 20px; }
.lightbox-counter { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); color: rgba(255,255,255,0.6); font-size: 0.8rem; font-family: var(--font-heading, 'Space Grotesk', sans-serif); }
.btn-cancel-sm { background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.25); color: #ef4444; font-size: 0.7rem; width: 22px; height: 22px; border-radius: 50%; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: all 0.2s ease; margin-left: auto; flex-shrink: 0; }
.btn-cancel-sm:hover { background: rgba(239,68,68,0.25); color: #fff; }
.btn-danger-sm { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.2); color: #ef4444; font-size: 0.7rem; padding: 3px 8px; border-radius: var(--radius); cursor: pointer; transition: all 0.2s ease; }
.btn-danger-sm:hover { background: rgba(239,68,68,0.25); color: #fff; }
.timeline-time { display: flex; align-items: center; gap: 6px; }
.timeline-item { cursor: pointer; transition: background 0.15s ease; border-radius: var(--radius); }
.timeline-item:hover { background: rgba(255,255,255,0.03); }
.post-detail-caption { background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; font-size: 0.875rem; color: var(--text-muted); line-height: 1.6; margin-bottom: 10px; }
.post-detail-caption.rtl { direction: rtl; text-align: right; }

.toast-wrap { position: fixed; bottom: 24px; right: 24px; z-index: 9000; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px 16px; display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow-lg); animation: fadeInUp 0.25s ease; font-size: 0.875rem; pointer-events: all; min-width: 260px; max-width: 360px; }
.toast-icon { font-size: 1.1rem; flex-shrink: 0; }
.toast-text { flex: 1; }
.toast-title { font-weight: 600; color: var(--text); font-size: 0.875rem; }
.toast-msg { font-size: 0.8rem; color: var(--text-muted); }
.toast.success { border-color: rgba(16,185,129,0.3); }
.toast.error { border-color: rgba(239,68,68,0.3); }
.toast.info { border-color: rgba(59,130,246,0.3); }
.toast-close { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 1rem; padding: 0 2px; transition: color var(--transition); line-height: 1; }
.toast-close:hover { color: var(--text); }

.full-calendar-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 20px; }
.full-calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.full-calendar-cell { border-radius: var(--radius); border: 1px solid transparent; padding: 6px; cursor: pointer; min-height: 80px; transition: all var(--transition); display: flex; flex-direction: column; }
.full-calendar-cell:hover { background: rgba(255,255,255,0.03); border-color: var(--border); }
.full-calendar-cell.empty { cursor: default; }
.full-calendar-cell.empty:hover { background: transparent; border-color: transparent; }
.full-calendar-cell.today { border-color: rgba(59,130,246,0.35); background: rgba(59,130,246,0.04); }
.full-day-num { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; }
.full-calendar-cell.today .full-day-num { color: var(--primary); }
.full-day-posts { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.full-day-post-item { font-size: 0.65rem; padding: 2px 5px; border-radius: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.full-day-post-item.published { background: var(--accent-soft); color: var(--accent); }
.full-day-post-item.scheduled { background: var(--primary-soft); color: var(--primary); }
.full-day-post-item.failed { background: rgba(239,68,68,0.12); color: var(--red); }
.full-day-post-item.notified { background: rgba(245,158,11,0.12); color: var(--warning); }
.full-day-post-item.cancelled { background: rgba(113,113,122,0.1); color: var(--text-dim); }
.more-label { font-size: 0.65rem; color: var(--text-dim); padding: 1px 4px; }

.confirm-modal-icon { font-size: 2.5rem; text-align: center; margin-bottom: 12px; }
.confirm-modal-title { font-size: 1.1rem; font-weight: 700; text-align: center; margin-bottom: 8px; }
.confirm-modal-desc { font-size: 0.875rem; color: var(--text-muted); text-align: center; margin-bottom: 20px; line-height: 1.5; }

@media (max-width: 1100px) {
    .stats-row { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    :root { --sidebar-w: 200px; }
    .main-content { padding: 16px; }
    .stats-row { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .stat-value { font-size: 1.6rem; }
    table thead { display: none; }
    tbody td { display: block; padding: 6px 16px; }
    tbody td::before { content: attr(data-label) ': '; font-size: 0.7rem; color: var(--text-dim); font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
    tbody tr { display: block; border-bottom: 1px solid var(--border); padding: 8px 0; }
    .modal { max-width: 100%; border-radius: var(--radius-xl); }
}
@media (max-width: 480px) {
    .stats-row { grid-template-columns: 1fr 1fr; gap: 10px; }
    .topbar { padding: 0 12px; }
    .topbar-user-name { display: none; }
    .sidebar { position: fixed; top: 0; left: 0; height: 100vh; z-index: 200; transform: translateX(-100%); transition: transform 0.3s ease, width 0.3s ease; }
    .sidebar.mobile-open { transform: translateX(0); }
    #app.active { padding-left: 0; }
    .main-wrap { width: 100%; }
}
