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

:root {
  --bg: #0a0a0a;
  --bg-card: #141414;
  --bg-hover: #1a1a1a;
  --border: #262626;
  --text: #fafafa;
  --text-muted: #a1a1aa;
  --primary: #8b5cf6;
  --primary-hover: #7c3aed;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* Layout */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 32px;
  padding: 0 8px;
}

.sidebar-logo span { color: var(--text); }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  font-size: 14px;
  margin-bottom: 4px;
}

.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--primary); color: white; }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.main {
  flex: 1;
  margin-left: 240px;
  padding: 32px;
}

/* Header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}

.page-title { font-size: 24px; font-weight: 700; }
.page-desc { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.stat-label { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; }
.stat-change { font-size: 12px; color: var(--success); margin-top: 4px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg-hover); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { opacity: 0.9; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-success { background: var(--success); color: white; }

/* Table */
.table-wrap { overflow-x: auto; }

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

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

th { color: var(--text-muted); font-weight: 500; font-size: 13px; }
tr:hover td { background: var(--bg-hover); }

/* Badge */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.badge-draft { background: #27272a; color: var(--text-muted); }
.badge-scheduled { background: #422006; color: var(--warning); }
.badge-published { background: #052e16; color: var(--success); }
.badge-failed { background: #450a0a; color: var(--danger); }
.badge-active { background: #052e16; color: var(--success); }

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

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
}

.form-textarea { resize: vertical; min-height: 120px; font-family: inherit; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay.active { display: flex; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 90%;
  max-width: 520px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 24px; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px; }

/* Post preview */
.post-preview {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  white-space: pre-wrap;
  line-height: 1.6;
  font-size: 14px;
  max-height: 300px;
  overflow-y: auto;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.tab {
  padding: 10px 16px;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}

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

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state svg { width: 48px; height: 48px; margin-bottom: 16px; opacity: 0.5; }
.empty-state p { font-size: 14px; }

/* Toast */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 20px;
  font-size: 14px;
  animation: slideIn 0.3s ease;
  min-width: 280px;
}

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

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

/* Loading */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

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

/* Section */
.section { display: none; }
.section.active { display: block; }

/* Mobile Header */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  height: 56px;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

.mobile-header-logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}

.mobile-header-logo span { color: var(--text); }

.hamburger-btn {
  padding: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
}

.hamburger-btn:hover { color: var(--text); }
.hamburger-btn svg { width: 24px; height: 24px; }

/* Sidebar overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0,0,0,0.5);
}

.sidebar-overlay.active { display: block; }

/* Sidebar transition */
.sidebar {
  transition: transform 0.2s ease;
}

/* Responsive */
@media (max-width: 768px) {
  .mobile-header { display: flex; }

  .sidebar {
    transform: translateX(-100%);
    z-index: 50;
  }

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

  .main {
    margin-left: 0;
    padding: 12px;
    padding-top: 68px;
  }

  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 22px; }

  .page-header { flex-direction: column; gap: 12px; align-items: flex-start; }
  .page-title { font-size: 20px; }

  /* 모바일 테이블 → 카드형 */
  .table-wrap { overflow: visible; }

  table, thead, tbody, th, tr { display: block; }
  thead { display: none; }

  tr {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 10px;
    display: block;
  }

  tr:hover td { background: none; }

  td {
    display: inline;
    border: none;
    padding: 0;
    font-size: 13px;
  }

  td:first-child {
    display: block;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 8px;
    line-height: 1.4;
  }

  td:last-child {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 10px;
  }

  td .badge { font-size: 11px; margin-right: 4px; }

  td .btn { padding: 5px 10px; font-size: 12px; }

  /* 페이지 헤더 버튼 우측 */
  .page-header { position: relative; }
  .page-header .btn { align-self: flex-end; }

  /* 설정 카드 내 버튼 우측 */
  .card > .btn { display: block; margin-left: auto; }

  /* 모달 */
  .modal { width: 95%; padding: 16px; max-height: 85vh; }
  .modal-title { font-size: 16px; margin-bottom: 16px; }
  .form-textarea { min-height: 80px; }

  /* 탭 */
  .tabs { gap: 0; overflow-x: auto; }
  .tab { padding: 8px 12px; font-size: 13px; white-space: nowrap; }

  /* 버튼 */
  .btn { padding: 8px 14px; font-size: 13px; }
  .btn-sm { padding: 5px 10px; font-size: 12px; }

  /* 토스트 */
  .toast-container { top: 64px; right: 12px; left: 12px; }
  .toast { min-width: auto; font-size: 13px; padding: 10px 14px; }

  /* 카드 */
  .card { padding: 16px; }

  /* 플랜 카드 1열 */
  .plan-grid { grid-template-columns: 1fr !important; }
}
