:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --navy: #0f172a;
  --navy-2: #1e293b;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --accent: #ef4444;
  --accent-hover: #dc2626;
  --amber: #f59e0b;
  --green: #10b981;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}

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

/* 헤더 */
.site-header {
  background: var(--navy);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.header-inner {
  max-width: 1420px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-badge {
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 999px;
  letter-spacing: 0.05em;
}

.brand-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* 버튼 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-accent {
  background: var(--accent);
  color: #fff;
}
.btn-accent:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: #e2e8f0;
  color: var(--text);
}
.btn-secondary:hover {
  background: #cbd5e1;
}

.btn-outline-light {
  background: transparent;
  color: #e2e8f0;
  border-color: rgba(255, 255, 255, 0.25);
}
.btn-outline-light:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-ghost-light {
  background: transparent;
  color: #94a3b8;
}
.btn-ghost-light:hover {
  color: #fff;
}

/* 히어로 스트립 */
.hero-strip {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 65%, #334155 100%);
  color: #fff;
  padding: 26px 20px;
}

.hero-inner {
  max-width: 1420px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.hero-copy h1 {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.hero-copy .highlight {
  color: #fca5a5;
}

.hero-copy p {
  margin: 0;
  color: #cbd5e1;
  font-size: 14px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(110px, 1fr));
  gap: 10px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 10px 14px;
  text-align: center;
}

.stat-card.stat-alert {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(248, 113, 113, 0.4);
}

.stat-label {
  font-size: 11px;
  color: #cbd5e1;
}

.stat-value {
  font-size: 22px;
  font-weight: 800;
  margin-top: 2px;
}

.stat-time {
  font-size: 14px;
  margin-top: 7px;
}

/* 3단 레이아웃 */
.page-layout {
  max-width: 1420px;
  margin: 22px auto 48px;
  padding: 0 16px;
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr) 210px;
  gap: 20px;
  align-items: start;
}

/* 양옆 광고 배너 레일 */
.ad-rail-sticky {
  position: sticky;
  top: 76px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ad-rail-header {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-align: center;
}

.ad-card {
  display: block;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.ad-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.12);
}

.ad-card-img-wrap img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
}

.ad-card-caption {
  padding: 10px 12px;
}

.ad-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.ad-card-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}

.ad-card-sponsor {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 6px;
}

.ad-card-text {
  padding: 18px 14px;
  color: #fff;
  min-height: 210px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.ad-pill {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.2);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
}

.ad-text-title {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.35;
  margin: 12px 0 6px;
  word-break: keep-all;
}

.ad-text-sub {
  font-size: 12px;
  opacity: 0.88;
  line-height: 1.45;
  word-break: keep-all;
}

.ad-text-cta {
  margin-top: 14px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.16);
  padding: 6px 10px;
  border-radius: 6px;
  text-align: center;
}

.ad-text-sponsor {
  margin-top: 10px;
  font-size: 11px;
  opacity: 0.72;
}

.ad-cta-slot {
  width: 100%;
  background: var(--surface);
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius);
  padding: 18px 14px;
  text-align: center;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
}

.ad-cta-slot:hover {
  border-color: var(--accent);
  background: #fef2f2;
}

.ad-cta-icon {
  font-size: 24px;
  margin-bottom: 6px;
}

.ad-cta-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.ad-cta-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin: 6px 0 12px;
  word-break: keep-all;
}

.ad-cta-btn {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: var(--navy-2);
  padding: 6px 12px;
  border-radius: 6px;
}

.ad-cta-slot:hover .ad-cta-btn {
  background: var(--accent);
}

/* 중앙 검색 & 뉴스 피드 */
.search-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.search-bar {
  display: flex;
  gap: 8px;
}

.search-bar input {
  flex: 1;
  padding: 11px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
}

.search-bar input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.category-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.cat-tab {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
}

.cat-tab:hover {
  border-color: #94a3b8;
  color: var(--text);
}

.cat-tab.active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

.list-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 13px;
}

.result-count {
  font-weight: 700;
  color: var(--text);
}

.toolbar-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.news-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.news-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.news-card:hover {
  border-color: #94a3b8;
  transform: translateY(-1px);
}

.news-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  font-size: 12px;
}

.cat-badge {
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
}

.severity-badge {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
}

.news-source {
  font-weight: 600;
  color: #334155;
}

.news-date {
  color: var(--text-muted);
  margin-left: auto;
}

.news-title {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.4;
}

.news-title a:hover {
  color: var(--primary);
  text-decoration: underline;
}

.news-summary {
  margin: 0;
  font-size: 13.5px;
  color: #475569;
  line-height: 1.55;
}

.empty-state {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 20px;
  text-align: center;
  color: var(--text-muted);
}

/* 페이지네이션 */
.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 22px;
  flex-wrap: wrap;
}

.page-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}

.page-btn:hover:not(:disabled) {
  border-color: var(--navy);
}

.page-btn.active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

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

/* 모달 */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 16px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-dialog {
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  max-width: 780px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

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

.modal-header h2 {
  margin: 0;
  font-size: 18px;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
}

.modal-body {
  padding: 20px 22px;
}

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 22px;
  align-items: start;
}

.ad-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-row label {
  font-size: 12.5px;
  font-weight: 700;
  color: #334155;
}

.form-row input[type="text"],
.form-row input[type="url"],
.form-row input[type="password"],
.form-row input[type="file"],
.form-row select {
  padding: 9px 11px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
}

.form-row input[type="color"] {
  height: 38px;
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 2px;
  background: #fff;
}

.form-help {
  font-size: 11.5px;
  color: var(--text-muted);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}

.form-message {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
}
.form-message.success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}
.form-message.error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}
.form-message.info {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

.ad-preview-pane {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

.preview-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 10px;
  text-align: center;
}

.preview-note {
  font-size: 11.5px;
  color: var(--text-muted);
  margin: 10px 0 0;
  line-height: 1.45;
}

/* 푸터 */
.site-footer {
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 24px 20px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-muted);
}

.site-footer p {
  margin: 4px 0;
}

.site-footer a {
  color: var(--primary);
  font-weight: 600;
}

/* 토스트 */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--navy);
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  z-index: 1200;
}

/* 관리자 페이지 */
.admin-login-wrap {
  min-height: calc(100vh - 70px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.admin-login-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}

.admin-login-card h1 {
  margin: 0 0 6px;
  font-size: 20px;
}

.admin-login-card p {
  margin: 0 0 18px;
  font-size: 13px;
  color: var(--text-muted);
}

.admin-container {
  max-width: 1220px;
  margin: 24px auto 60px;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.admin-stat-box {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-stat-box span {
  font-size: 12px;
  color: var(--text-muted);
}

.admin-stat-box strong {
  font-size: 26px;
}

.admin-stat-box.highlight-amber strong {
  color: #d97706;
}
.admin-stat-box.highlight-green strong {
  color: #059669;
}

.admin-panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.admin-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-panel-head h2 {
  margin: 0;
  font-size: 17px;
}

.collect-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.custom-kw-box {
  display: flex;
  gap: 6px;
  flex: 1;
  min-width: 260px;
}

.custom-kw-box input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
}

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

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-table th,
.admin-table td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.admin-table th {
  background: #f8fafc;
  font-weight: 700;
  color: #475569;
  white-space: nowrap;
}

.empty-td {
  text-align: center !important;
  color: var(--text-muted);
  padding: 28px !important;
}

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.status-pending {
  background: #fef3c7;
  color: #92400e;
}
.status-approved {
  background: #d1fae5;
  color: #065f46;
}
.status-paused {
  background: #e2e8f0;
  color: #475569;
}
.status-rejected {
  background: #fee2e2;
  color: #991b1b;
}

.action-cell {
  white-space: nowrap;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.btn-xs {
  padding: 4px 8px;
  font-size: 11.5px;
  font-weight: 700;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
}
.btn-approve { background: #10b981; color: #fff; }
.btn-pause { background: #64748b; color: #fff; }
.btn-reject { background: #f59e0b; color: #fff; }
.btn-del { background: #ef4444; color: #fff; }

.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.small-link { font-size: 11.5px; color: var(--primary); word-break: break-all; }
.article-admin-link { font-weight: 600; color: var(--text); }
.article-admin-link:hover { color: var(--primary); text-decoration: underline; }
.row-hidden { opacity: 0.5; background: #f8fafc; }

/* 반응형 */
@media (max-width: 1160px) {
  .page-layout {
    grid-template-columns: 1fr;
  }
  .ad-rail-sticky {
    position: static;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }
  .ad-rail-header {
    grid-column: 1 / -1;
  }
  .ad-rail-left {
    order: 2;
  }
  .main-content {
    order: 1;
  }
  .ad-rail-right {
    order: 3;
  }
}

@media (max-width: 720px) {
  .stats-grid,
  .admin-stats {
    grid-template-columns: repeat(2, 1fr);
    width: 100%;
  }
  .modal-grid {
    grid-template-columns: 1fr;
  }
  .form-row-2 {
    grid-template-columns: 1fr;
  }
  .list-toolbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
}
