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

/* ── Variables ─── */
:root {
  --brand: #6366F1;
  --brand-light: #818CF8;
  --brand-dark: #4F46E5;
  --accent: #22D3EE;
  --success: #10B981;
  --danger: #EF4444;
  --warning: #F59E0B;

  --bg-base: #F8FAFC;
  --bg-surface: #FFFFFF;
  --bg-overlay: #F1F5F9;
  --bg-hover: #F1F5F9;

  --border: #E2E8F0;
  --border-light: #CBD5E1;

  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-muted: #94A3B8;
  --text-inverse: #F8FAFC;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --transition: 0.18s ease;
  --shadow: 0 4px 24px rgba(0,0,0,0.08);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
}

/* ── Global Reset ─── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', 'Noto Sans KR', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── App Layout ─── (removed: replaced by .sr-app tabbar layout) */
/* .app-layout { display: flex; min-height: 100vh; } */

/* ── Sidebar ─── (removed: replaced by .sr-tabbar) */
/* .sidebar { ... } */
/* .sidebar-logo { ... } */
/* .sidebar-logo .logo-mark { ... } */
/* .sidebar-logo .logo-text { ... } */
/* .sidebar-logo .logo-sub { ... } */
/* .sidebar-nav { ... } */
/* .sidebar-section-label { ... } */
/* .nav-item { ... } */
/* .nav-item:hover { ... } */
/* .nav-item.active { ... } */
/* .nav-item.active i { ... } */
/* .nav-item i { ... } */
/* .nav-badge { ... } */
/* .sidebar-footer { ... } */
/* .main-wrapper { ... } */

/* ── Page Header ─── */
.page-header {
  padding: 20px 28px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.page-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ── Page Content ─── */
.page-content {
  padding: 20px 28px 40px;
  flex: 1;
}

/* ── KPI Cards ─── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition);
}

.kpi-card:hover {
  border-color: var(--brand);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand), var(--accent));
  opacity: 0;
  transition: opacity var(--transition);
}

.kpi-card:hover::before {
  opacity: 1;
}

.kpi-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 8px;
  letter-spacing: -0.5px;
}

.kpi-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.kpi-delta-up {
  color: var(--success);
}

.kpi-delta-down {
  color: var(--danger);
}

/* ── Filter Card ─── */
.filter-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-row + .filter-row {
  margin-top: 10px;
}

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

/* ── Form Controls ─── */
.sr-input {
  height: 34px;
  padding: 0 10px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
}

.sr-input:focus {
  border-color: var(--brand);
}

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

.sr-select {
  height: 34px;
  padding: 0 28px 0 10px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2394a3b8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  cursor: pointer;
}

.sr-select:focus {
  border-color: var(--brand);
}

.sr-textarea {
  padding: 8px 10px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  resize: vertical;
  min-height: 80px;
  transition: border-color var(--transition);
}

.sr-textarea:focus {
  border-color: var(--brand);
}

.range-input {
  display: flex;
  align-items: center;
  gap: 6px;
}

.range-input .sep {
  color: var(--text-muted);
  font-size: 12px;
}

.date-range {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  height: 34px;
}

.date-range i {
  color: var(--text-muted);
  font-size: 13px;
}

.date-range input[type="date"] {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  color-scheme: dark;
}

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

/* ── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
}

.btn-primary:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-light);
}

.btn-outline:hover {
  background: var(--bg-overlay);
  border-color: var(--text-muted);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--bg-overlay);
  color: var(--text-primary);
}

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

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

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

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  font-size: 13px;
}

.btn-icon:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
  background: var(--bg-overlay);
}

.btn-text-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--brand-light);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}

.btn-text-link:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

/* ── Action Bar ─── */
.action-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.action-bar .spacer {
  flex: 1;
}

/* ── Data Table ─── */
.sr-table-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

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

.sr-table thead tr {
  background: var(--bg-overlay);
  border-bottom: 1px solid var(--border);
}

.sr-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.sr-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}

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

.sr-table tbody tr:hover td {
  background: var(--bg-hover);
}

.sr-table th.center,
.sr-table td.center {
  text-align: center;
}

/* ── Badges ─── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.badge-active {
  background: rgba(16, 185, 129, 0.15);
  color: #34D399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-active .badge-dot {
  background: #34D399;
}

.badge-paused {
  background: rgba(100, 116, 139, 0.2);
  color: #94A3B8;
  border: 1px solid rgba(100, 116, 139, 0.3);
}

.badge-paused .badge-dot {
  background: #94A3B8;
}

.badge-error {
  background: rgba(239, 68, 68, 0.15);
  color: #FCA5A5;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-error .badge-dot {
  background: #FCA5A5;
}

.badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #FCD34D;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-warning .badge-dot {
  background: #FCD34D;
}

.badge-info {
  background: rgba(99, 102, 241, 0.15);
  color: #A5B4FC;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.badge-info .badge-dot {
  background: #A5B4FC;
}

/* ── Pagination ─── */
.pagination-wrap {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  background: var(--bg-surface);
}

.pagination-wrap .total {
  color: var(--text-secondary);
  margin-right: 8px;
}

.page-btn {
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  font-family: inherit;
}

.page-btn:hover:not(:disabled) {
  color: var(--text-primary);
  border-color: var(--brand);
  background: rgba(99, 102, 241, 0.1);
}

.page-btn.active {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

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

.page-size-select {
  height: 30px;
  padding: 0 24px 0 8px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12px;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2394a3b8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  cursor: pointer;
  outline: none;
}

.goto {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
}

.goto input {
  width: 44px;
  height: 30px;
  padding: 0 6px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  text-align: center;
  color: var(--text-primary);
  font-family: inherit;
  outline: none;
}

.goto input:focus {
  border-color: var(--brand);
}

/* ── Modal ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

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

.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  width: 480px;
  max-width: calc(100vw - 40px);
  overflow: hidden;
  animation: modalIn 0.18s ease;
}

.modal-box.wide {
  width: 680px;
}

.modal-box.chart-modal {
  width: 720px;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(-8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

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

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-title i {
  color: var(--brand);
  font-size: 15px;
}

.modal-close {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

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

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

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  background: var(--bg-base);
}

/* ── Form Fields ─── */
.form-group {
  margin-bottom: 16px;
}

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

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

.form-label .required {
  color: var(--danger);
  margin-left: 2px;
}

.form-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Upload Area ─── */
.upload-area {
  border: 2px dashed var(--border-light);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-muted);
}

.upload-area:hover {
  border-color: var(--brand);
  color: var(--text-secondary);
}

.upload-area i {
  font-size: 28px;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: block;
}

.upload-area p {
  font-size: 13px;
  margin: 4px 0 0;
}

/* ── Toast Notification ─── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-overlay);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 10px 16px;
  color: var(--text-primary);
  font-size: 13px;
  display: none;
  align-items: center;
  gap: 8px;
  z-index: 2000;
  box-shadow: var(--shadow);
  animation: slideUp 0.2s ease;
}

.toast.show {
  display: flex;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Sparkline ─── */
.sparkline {
  display: inline-block;
  vertical-align: middle;
}

/* ── Stat Summary Row ─── */
.stat-row {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.stat-card {
  flex: 1;
  min-width: 160px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
}

.stat-card .stat-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat-card .stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 6px;
}

.stat-card .stat-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ── Collapsible Section ─── */
.collapse-section {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 16px;
}

.collapse-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid transparent;
  transition: background var(--transition);
}

.collapse-header:hover {
  background: var(--bg-hover);
}

.collapse-header.open {
  border-bottom-color: var(--border);
}

.collapse-body {
  padding: 16px 20px;
  display: none;
}

.collapse-body.open {
  display: block;
}

/* ── Tooltip ─── */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-overlay);
  color: var(--text-primary);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
  border: 1px solid var(--border);
}

[data-tooltip]:hover::after {
  opacity: 1;
}

/* ── Scrollbar ─── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-base);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

/* ── Time Filter ─── */
.time-filter {
  display: flex;
  align-items: center;
  gap: 4px;
}

.time-btn {
  padding: 4px 10px;
  height: 28px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
}

.time-btn:hover {
  border-color: var(--brand);
  color: var(--brand-light);
}

.time-btn.active {
  background: rgba(99, 102, 241, 0.15);
  border-color: var(--brand);
  color: var(--brand-light);
}

/* ════════════════════════════════════════════
   SPA TAB LAYOUT (SellRadar 2.0)
   ════════════════════════════════════════════ */

/* ── SPA 전체 컨테이너 ── */
.sr-app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg-base);
}

/* ── 상단 탭바 ── */
.sr-tabbar {
  display: flex;
  align-items: center;
  height: 48px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  gap: 4px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.sr-logo {
  font-weight: 800;
  font-size: 16px;
  color: var(--brand);
  margin-right: 24px;
  letter-spacing: -0.5px;
  user-select: none;
}

.sr-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  height: 36px;
  border-radius: var(--radius-sm, 6px);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition, 0.15s ease);
  white-space: nowrap;
  border: 1px solid transparent;
  user-select: none;
}

.sr-tab:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.sr-tab.active {
  color: var(--brand-light, #818cf8);
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.3);
}

.sr-tab i {
  font-size: 12px;
  opacity: 0.85;
}

.sr-tabbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.sr-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  display: inline-block;
  transition: background 0.3s ease;
}

.sr-status-dot.online {
  background: var(--success, #10b981);
}

/* ── 탭 패널 ── */
.sr-panel {
  flex: 1;
  overflow: auto;
  padding: 24px 28px 40px;
}

.sr-panel.hidden {
  display: none;
}

/* ── 반응형 ── */
@media (max-width: 768px) {
  .sr-tabbar {
    padding: 0 12px;
    gap: 2px;
    overflow-x: auto;
  }
  .sr-tab {
    padding: 0 10px;
    font-size: 12px;
  }
  .sr-logo {
    font-size: 14px;
    margin-right: 12px;
  }
  .sr-panel {
    padding: 16px 16px 32px;
  }
}
