@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg-app: #f9f9fc;
  --bg-surface: #ffffff;
  --text-main: #111827;
  --text-muted: #6b7280;
  --primary: #4F46E5;
  --primary-hover: #4338ca;
  --border: #e5e7eb;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1);
  --font: 'Inter', sans-serif;
  --sidebar-width: 240px;
  --topbar-height: 64px;
  --radius: 12px;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --instagram: #8b5cf6;
  --youtube: #ef4444;
  --facebook: #3b82f6;
}

[data-theme='dark'] {
  --bg-app: #0f172a;
  --bg-surface: #1e293b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --border: #334155;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.4);
}

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

body {
  font-family: var(--font);
  background: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: var(--font);
  cursor: pointer;
  border: none;
  background: none;
}

input, select, textarea {
  font-family: var(--font);
}

#app {
  display: none;
}

#app.active {
  display: flex;
  min-height: 100vh;
}

#login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg-app);
  padding: 1rem;
  touch-action: manipulation;
}

#login-page.hidden {
  display: none;
}

.login-container {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.5px;
}

.login-logo p {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text-main);
}

.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-app);
  color: var(--text-main);
  font-size: 0.9375rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

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

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

.btn-secondary:hover {
  background: var(--border);
}

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

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

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

.btn-block {
  width: 100%;
}

.login-error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  padding: 0.75rem;
  border-radius: 8px;
  font-size: 0.875rem;
  margin-bottom: 1rem;
  display: none;
}

.login-error.visible {
  display: block;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  height: 100dvh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.sidebar-header {
  padding: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0;
}

.sidebar-section {
  margin-bottom: 0.5rem;
}

.sidebar-section-title {
  padding: 0.5rem 1.25rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  transition: all 0.15s;
  cursor: pointer;
}

.sidebar-link:hover {
  background: var(--bg-app);
  color: var(--text-main);
}

.sidebar-link.active {
  background: rgba(79, 70, 229, 0.08);
  color: var(--primary);
  font-weight: 500;
}

.sidebar-link i {
  font-size: 1.125rem;
  width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 0.875rem;
}

.user-info {
  flex: 1;
}

.user-name {
  font-size: 0.875rem;
  font-weight: 500;
}

.user-role {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-height);
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  z-index: 50;
}

[data-theme='dark'] .topbar {
  background: rgba(30, 41, 59, 0.8);
}

.topbar-title {
  font-size: 1.125rem;
  font-weight: 600;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.page-content {
  padding: 2rem;
  flex: 1;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.stat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.stat-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.stat-card-icon.purple {
  background: rgba(79, 70, 229, 0.1);
  color: var(--primary);
}

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

.stat-card-icon.blue {
  background: rgba(59, 130, 246, 0.1);
  color: var(--info);
}

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

.stat-card-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-card-value {
  font-size: 1.75rem;
  font-weight: 700;
  margin-top: 0.25rem;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.card-body {
  padding: 1.5rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

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

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

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 0.875rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-instagram {
  background: rgba(139, 92, 246, 0.1);
  color: var(--instagram);
}

.badge-youtube {
  background: rgba(239, 68, 68, 0.1);
  color: var(--youtube);
}

.badge-facebook {
  background: rgba(59, 130, 246, 0.1);
  color: var(--facebook);
}

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

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

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

.badge-admin {
  background: rgba(79, 70, 229, 0.1);
  color: var(--primary);
}

.badge-analyst {
  background: rgba(59, 130, 246, 0.1);
  color: var(--info);
}

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

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.profile-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.profile-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.profile-card-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.profile-edit-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all 0.15s;
  flex-shrink: 0;
}

.profile-edit-btn:hover {
  background: var(--bg-app);
  color: var(--primary);
}

.profile-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-app);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-avatar i {
  font-size: 1.5rem;
  color: var(--text-muted);
}

.profile-name {
  font-weight: 600;
  font-size: 0.9375rem;
}

.profile-handle {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.profile-stats {
  display: flex;
  gap: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

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

.profile-stat-value {
  font-weight: 600;
  font-size: 1rem;
}

.profile-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}

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

.modal {
  background: var(--bg-surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
  transform: scale(0.95);
  transition: transform 0.2s;
}

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

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all 0.15s;
}

.modal-close:hover {
  background: var(--bg-app);
  color: var(--text-main);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.875rem 1.25rem;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  animation: slideIn 0.3s ease;
  min-width: 280px;
}

.toast.success {
  border-left: 3px solid var(--success);
}

.toast.error {
  border-left: 3px solid var(--danger);
}

.toast.info {
  border-left: 3px solid var(--info);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideUpToast {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-app) 25%, var(--border) 50%, var(--bg-app) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text {
  height: 1rem;
  margin-bottom: 0.5rem;
}

.skeleton-title {
  height: 1.5rem;
  width: 60%;
  margin-bottom: 1rem;
}

.skeleton-card {
  height: 120px;
  border-radius: var(--radius);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner-dark {
  border-color: var(--border);
  border-top-color: var(--primary);
}

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

.loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: var(--primary);
  z-index: 9999;
  transition: width 0.3s ease;
  width: 0;
}

.loading-bar.active {
  width: 60%;
  animation: loadingBar 2s ease-in-out infinite;
}

@keyframes loadingBar {
  0% { width: 0; }
  50% { width: 70%; }
  100% { width: 100%; }
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background: rgba(79, 70, 229, 0.05);
}

.dropzone i {
  font-size: 2.5rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.dropzone p {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.dropzone .highlight {
  color: var(--primary);
  font-weight: 500;
}

.preview-container {
  width: 200px;
  aspect-ratio: 9/16;
  background: var(--bg-app);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.preview-container img, .preview-container video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.tab {
  padding: 0.75rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  cursor: pointer;
}

.tab:hover {
  color: var(--text-main);
}

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.activity-item {
  display: flex;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

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

.activity-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-app);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  flex-shrink: 0;
}

.activity-content {
  flex: 1;
}

.activity-text {
  font-size: 0.875rem;
}

.activity-text strong {
  font-weight: 600;
}

.activity-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state p {
  font-size: 0.9375rem;
}

.filter-bar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.filter-bar select, .filter-bar input {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 0.875rem;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

.pagination button {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 0.875rem;
}

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

.pagination button.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.settings-section {
  margin-bottom: 2rem;
}

.settings-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 0;
}

.setting-label {
  font-size: 0.875rem;
}

.setting-label small {
  display: block;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 8px;
  transition: background 0.15s;
}

.theme-toggle:hover {
  background: var(--bg-app);
}

.profile-detail-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.profile-detail-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--bg-app);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.profile-detail-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-detail-avatar i {
  font-size: 2rem;
  color: var(--text-muted);
}

.profile-detail-info h2 {
  font-size: 1.5rem;
  font-weight: 700;
}

.profile-detail-info p {
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.profile-detail-stats {
  display: flex;
  gap: 2rem;
  margin-top: 0.75rem;
}

.profile-detail-stat {
  text-align: center;
}

.profile-detail-stat-value {
  font-size: 1.25rem;
  font-weight: 700;
}

.profile-detail-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.story-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}

.story-item {
  position: relative;
  aspect-ratio: 9/16;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.story-item img, .story-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.story-item .story-status {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
}

.story-item .story-date {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.5rem;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  color: white;
  font-size: 0.75rem;
}

.mobile-menu-btn {
  display: none;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  color: var(--text-main);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  font-size: 1.375rem;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: all 0.15s;
}

.mobile-menu-btn:hover {
  background: var(--bg-app);
}

.mobile-menu-btn:active {
  transform: scale(0.92);
  background: var(--border);
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

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

  .topbar {
    padding: 0 1rem;
  }

  .page-content {
    padding: 1.25rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .stat-card {
    padding: 1.25rem;
  }

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

  .card-body {
    padding: 1.25rem;
  }

  .profile-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
}

@media (max-width: 768px) {
  #app.active {
    overflow-x: hidden;
  }

  .publish-layout {
    grid-template-columns: 1fr;
  }

  .publish-preview {
    position: static;
    order: -1;
  }

  .phone-frame {
    width: 100%;
    max-width: 280px;
    height: auto;
    aspect-ratio: 9/16;
    max-height: 500px;
    border-radius: 24px;
    padding: 6px;
  }

  body {
    overflow-x: hidden;
  }

  #app.active {
    overflow-x: hidden;
  }

  .sidebar {
    overflow-x: hidden;
    transform: translateX(-100%);
    box-shadow: none;
    width: 100%;
    max-width: 320px;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 40px rgba(0,0,0,0.2);
  }

  .sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
  }

  .main-content {
    margin-left: 0;
    width: 100%;
    min-height: 100dvh;
  }

  .mobile-menu-btn {
    display: flex;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    font-size: 1.5rem;
  }

  .topbar {
    padding: 0 0.75rem;
    padding-top: env(safe-area-inset-top, 0px);
    height: calc(52px + env(safe-area-inset-top, 0px));
  }

  .topbar-title {
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .topbar-actions {
    gap: 0.375rem;
    flex-shrink: 0;
  }

  .page-content {
    padding: 1rem 0.75rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.25rem;
  }

  .stat-card {
    padding: 1rem;
    border-radius: 10px;
  }

  .stat-card:active {
    transform: scale(0.97);
    transition: transform 0.1s;
  }

  .stat-card-icon {
    width: 36px;
    height: 36px;
    font-size: 1.125rem;
  }

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

  .stat-card-value {
    font-size: 1.25rem;
    margin-top: 0.125rem;
  }

  .card {
    border-radius: 10px;
  }

  .card-header {
    padding: 1rem 1.25rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .card-body {
    padding: 1rem;
  }

  .profile-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .profile-card {
    padding: 1rem;
    border-radius: 10px;
  }

  .profile-card:active {
    transform: scale(0.98);
    transition: transform 0.1s;
  }

  .profile-avatar {
    width: 40px;
    height: 40px;
  }

  .profile-stats {
    gap: 1rem;
  }

  .filter-bar {
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
  }

  .filter-bar select,
  .filter-bar input {
    width: 100%;
  }

  .profile-detail-header {
    flex-direction: column;
    text-align: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.25rem;
  }

  .profile-detail-avatar {
    width: 64px;
    height: 64px;
  }

  .profile-detail-info h2 {
    font-size: 1.25rem;
  }

  .profile-detail-stats {
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
  }

  .story-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .story-item {
    border-radius: 10px;
  }

  .modal {
    max-width: calc(100% - 2rem);
    margin: 1rem;
    border-radius: 14px;
  }

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

  .modal-header {
    padding: 1rem 1.25rem;
  }

  .modal-body {
    padding: 1.25rem;
  }

  .modal-footer {
    padding: 0.875rem 1.25rem;
    padding-bottom: calc(0.875rem + env(safe-area-inset-bottom, 0px));
    flex-direction: column-reverse;
  }

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

  .modal-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-app);
  }

  .toast-container {
    top: auto;
    bottom: 1rem;
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    right: 0.75rem;
    left: 0.75rem;
  }

  .toast {
    min-width: auto;
    width: 100%;
    border-radius: 12px;
    animation: slideUpToast 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  }

  th, td {
    padding: 0.75rem 0.75rem;
    font-size: 0.8125rem;
  }

  th {
    font-size: 0.6875rem;
  }

  .btn-sm {
    padding: 0.375rem 0.5rem;
    font-size: 0.75rem;
  }

  .btn {
    border-radius: 10px;
  }

  .btn:active {
    transform: scale(0.97);
  }

  .login-container {
    padding: 1.5rem;
    margin: 1rem;
    border-radius: 14px;
  }

  .login-logo {
    margin-bottom: 1.5rem;
  }

  .login-logo h1 {
    font-size: 1.5rem;
  }

  .form-group {
    margin-bottom: 1rem;
  }

  .form-input {
    padding: 0.75rem 0.875rem;
    font-size: 1rem;
    border-radius: 10px;
  }

  .btn {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
  }

  .dropzone {
    padding: 2rem 1rem;
    border-radius: 10px;
  }

  .dropzone i {
    font-size: 2rem;
  }

  .preview-container {
    width: 160px;
  }

  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
    scrollbar-width: none;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .tab {
    white-space: nowrap;
    padding: 0.75rem 1rem;
    font-size: 0.8125rem;
  }

  .activity-item {
    gap: 0.75rem;
    padding: 0.875rem 0;
  }

  .activity-item:active {
    background: var(--bg-app);
    margin: 0 -1rem;
    padding-left: 1rem;
    padding-right: 1rem;
    border-radius: 10px;
  }

  .activity-icon {
    width: 36px;
    height: 36px;
    font-size: 0.875rem;
  }

  .empty-state {
    padding: 2rem 1rem;
  }

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

  .settings-section {
    margin-bottom: 1.5rem;
  }

  .settings-section h3 {
    font-size: 0.9375rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.375rem;
  }

  .setting-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 0;
  }

  .setting-item .btn {
    width: 100%;
  }

  .user-menu {
    gap: 0.5rem;
  }

  .user-avatar {
    width: 32px;
    height: 32px;
    font-size: 0.75rem;
  }

  .user-name {
    font-size: 0.8125rem;
  }

  .user-role {
    font-size: 0.6875rem;
  }

  .sidebar-footer {
    padding: 0.875rem 1rem;
    padding-bottom: calc(0.875rem + env(safe-area-inset-bottom, 0px));
  }

  .sidebar-link {
    padding: 0.75rem 1.25rem;
    border-radius: 0;
    margin: 0;
  }

  .sidebar-link:active {
    background: var(--bg-app);
  }

  .sidebar-section-title {
    padding: 0.5rem 1.25rem;
  }

  .sidebar-header {
    padding-top: calc(1.25rem + env(safe-area-inset-top, 0px));
  }

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

  .pagination {
    gap: 0.375rem;
    margin-top: 1rem;
  }

  .pagination button {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    border-radius: 8px;
  }

  .perm-toggle {
    width: 40px;
    height: 22px;
  }

  .perm-slider::before {
    width: 16px;
    height: 16px;
  }

  .perm-toggle input:checked + .perm-slider::before {
    transform: translateX(18px);
  }

  .chart-container {
    height: 220px;
  }

  .grid-2 {
    gap: 0.75rem;
  }
}

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

  .stat-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1rem;
  }

  .stat-card-header {
    margin-bottom: 0;
  }

  .stat-card-value {
    font-size: 1.25rem;
  }

  .story-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

  .preview-container {
    width: 140px;
  }

  .profile-detail-info h2 {
    font-size: 1.125rem;
  }

  .profile-detail-stat-value {
    font-size: 1.125rem;
  }

  .modal {
    max-width: 100%;
    margin: 0;
    border-radius: 16px 16px 0 0;
    max-height: 90vh;
    align-self: flex-end;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  }

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

  .modal-overlay {
    align-items: flex-end;
  }

  .topbar-actions {
    gap: 0.375rem;
  }

  .page-content {
    padding: 0.75rem;
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 360px) {
  .stats-grid {
    gap: 0.5rem;
  }

  .stat-card {
    padding: 0.75rem;
  }

  .stat-card-value {
    font-size: 1.125rem;
  }

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

  .page-content {
    padding: 0.625rem;
  }
}

.perm-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  cursor: pointer;
}

.perm-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.perm-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 24px;
  transition: 0.2s;
}

.perm-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.2s;
}

.perm-toggle input:checked + .perm-slider {
  background: var(--primary);
}

.perm-toggle input:checked + .perm-slider::before {
  transform: translateX(20px);
}

.publish-layout {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 2rem;
  align-items: start;
}

.publish-preview {
  position: sticky;
  top: calc(var(--topbar-height) + 2rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.phone-frame {
  width: 300px;
  height: 580px;
  background: var(--bg-surface);
  border: 3px solid var(--border);
  border-radius: 36px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  padding: 10px;
}

.phone-screen {
  width: 100%;
  height: 100%;
  border-radius: 24px;
  background: #000;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

.phone-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: #fff;
  border-bottom: 1px solid #eee;
  z-index: 2;
}

[data-theme='dark'] .phone-header {
  background: #1e293b;
  border-bottom-color: #334155;
}

.phone-header-text {
  font-size: 0.875rem;
  font-weight: 600;
}

.phone-header-action {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 1rem;
}

.phone-media {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  position: relative;
}

.phone-media img, .phone-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.phone-media-empty {
  text-align: center;
  color: rgba(255,255,255,0.5);
}

.phone-media-empty i {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.phone-media-empty p {
  font-size: 0.8125rem;
}

.phone-caption {
  background: #fff;
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  border-top: 1px solid #eee;
  z-index: 2;
  max-height: 40px;
  overflow: hidden;
}

[data-theme='dark'] .phone-caption {
  background: #1e293b;
  border-top-color: #334155;
}

.phone-caption-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.phone-indicator {
  display: flex;
  gap: 4px;
  justify-content: center;
  padding: 0.5rem;
  background: rgba(0,0,0,0.5);
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 3;
}

.phone-dot {
  width: 6px;
  height: 6px;
  border-radius: 3px;
  background: rgba(255,255,255,0.4);
  transition: all 0.2s;
}

.phone-dot.active {
  width: 18px;
  background: #fff;
}

.phone-thumbs {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.phone-thumb {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  opacity: 0.6;
  transition: all 0.15s;
}

.phone-thumb.active {
  border-color: var(--primary);
  opacity: 1;
}

.phone-thumb img, .phone-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.publish-form .card {
  margin-bottom: 0;
}

.publish-dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.publish-dropzone:hover {
  border-color: var(--primary);
  background: rgba(79,70,229,0.05);
}

.publish-dropzone i {
  font-size: 2rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.publish-dropzone p {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.publish-thumbnails {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.publish-thumb {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
}

.publish-thumb.active {
  border-color: var(--primary);
}

.publish-thumb img, .publish-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.publish-thumb-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  opacity: 0;
  transition: opacity 0.15s;
}

.publish-thumb:hover .publish-thumb-remove {
  opacity: 1;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  cursor: pointer;
}

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

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

  .publish-preview {
    position: static;
  }

  .phone-frame {
    width: 240px;
    height: 460px;
  }
}

.cropper-container {
  position: relative;
  width: 100%;
  max-width: 360px;
  aspect-ratio: 9/16;
  margin: 0 auto;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

.cropper-image {
  position: absolute;
  top: 0;
  left: 0;
  max-width: none;
  max-height: none;
  width: auto;
  height: auto;
  min-width: 100%;
  min-height: 100%;
  user-select: none;
  -webkit-user-drag: none;
}

.cropper-frame {
  position: absolute;
  inset: 0;
  border: 2px solid rgba(255,255,255,0.6);
  border-radius: 12px;
  pointer-events: none;
  z-index: 2;
  box-shadow: 0 0 0 999px rgba(0,0,0,0.3);
}

.cropper-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  pointer-events: none;
  z-index: 3;
}

.cropper-grid div {
  border: 0.5px solid rgba(255,255,255,0.15);
}

.cropper-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 0 0;
}

.cropper-zoom-level {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 48px;
  text-align: center;
}
