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

:root {
  --bg: #f5f5f5;
  --surface: #ffffff;
  --border: #e0e0e0;
  --text: #141414;
  --text-muted: #888;
  --accent: #141414;
  --green: #00b37e;
  --red: #e53e3e;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
}

body { font-family: 'Pretendard', -apple-system, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

.layout { max-width: 1100px; margin: 0 auto; padding: 24px 20px; }

/* Header */
header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
h1 { font-size: 20px; font-weight: 700; }
.updated-at { font-size: 12px; color: var(--text-muted); margin-left: 12px; }
.btn-refresh { background: var(--accent); color: #fff; border: none; border-radius: var(--radius); padding: 8px 16px; cursor: pointer; font-size: 13px; }
.btn-refresh:hover { opacity: .85; }
.btn-refresh.loading { opacity: .5; pointer-events: none; }

/* Connect Bar */
.connect-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.connect-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 7px 14px; border-radius: 20px; border: 1px solid var(--border); background: var(--surface); }
.connect-chip.connected { border-color: #a7f3d0; background: #f0fdf4; color: #065f46; }
.connect-chip.disconnected { border-color: var(--border); color: var(--text-muted); }
.btn-connect { background: var(--accent); color: #fff; padding: 3px 10px; border-radius: 12px; font-size: 12px; text-decoration: none; }
.btn-connect:hover { opacity: .85; }
.btn-disconnect { background: none; border: 1px solid #a7f3d0; color: #065f46; padding: 2px 8px; border-radius: 10px; font-size: 11px; cursor: pointer; }
.btn-disconnect:hover { background: #d1fae5; }
.token-warn { color: #b45309; font-size: 11px; }

/* Toast */
.toast { position: fixed; bottom: 24px; right: 24px; padding: 12px 20px; border-radius: var(--radius); font-size: 13px; font-weight: 500; box-shadow: 0 4px 12px rgba(0,0,0,.15); z-index: 999; animation: slideUp .25s ease; }
.toast--success { background: #065f46; color: #fff; }
.toast--error   { background: #991b1b; color: #fff; }
@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Tabs */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 2px solid var(--border); padding-bottom: 0; }
.tab { background: none; border: none; padding: 10px 20px; cursor: pointer; font-size: 14px; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -2px; font-weight: 500; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab:hover { color: var(--text); }

/* KPI Groups */
.kpi-grid { display: flex; gap: 10px; margin-bottom: 24px; flex-wrap: wrap; align-items: flex-start; }

.kpi-group { display: flex; flex-direction: column; gap: 6px; }
.kpi-group--highlight .kpi-group-label { color: var(--green); }
.kpi-group--highlight .kpi-group-cards { border: 1.5px solid #d1fae5; border-radius: var(--radius); }

.kpi-group-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; padding: 0 2px; }

.kpi-group-cards { display: flex; gap: 8px; }

.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; box-shadow: var(--shadow); min-width: 110px; }
.kpi-card--highlight { background: #f0fdf4; border-color: #a7f3d0; }

.kpi-label { font-size: 11px; color: var(--text-muted); margin-bottom: 6px; white-space: nowrap; }
.kpi-value { font-size: 24px; font-weight: 700; }
.kpi-card--highlight .kpi-value { color: var(--green); }

/* Setup notice */
.setup-notice { background: #fffbeb; border: 1px solid #f6e05e; border-radius: var(--radius); padding: 16px 20px; margin-bottom: 24px; }
.setup-notice strong { display: block; margin-bottom: 6px; }
.setup-notice p { color: #744210; font-size: 13px; margin-bottom: 8px; }
.setup-notice a { color: var(--accent); font-size: 13px; }

/* Table */
.table-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 24px; }
.table-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.section-title { font-weight: 600; font-size: 14px; }
.sort-label { font-size: 13px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
select { border: 1px solid var(--border); border-radius: 4px; padding: 4px 8px; font-size: 13px; background: var(--surface); }

table { width: 100%; border-collapse: collapse; }
thead th { text-align: left; padding: 10px 20px; font-size: 12px; color: var(--text-muted); font-weight: 500; border-bottom: 1px solid var(--border); background: #fafafa; }
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #fafafa; }
td { padding: 12px 20px; vertical-align: middle; }
.post-title { font-weight: 500; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.post-link { color: var(--text-muted); font-size: 11px; text-decoration: none; }
.post-link:hover { color: var(--accent); }
.metric { font-size: 15px; font-weight: 600; }
.metric-label { font-size: 11px; color: var(--text-muted); }
.badge-rate { background: #f0fdf4; color: var(--green); font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 20px; }
.date { font-size: 12px; color: var(--text-muted); }
.empty { padding: 40px 20px; text-align: center; color: var(--text-muted); }

/* CSV Upload */
.csv-upload { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.csv-upload p { margin-bottom: 8px; font-size: 13px; color: var(--text-muted); }
.hint { font-size: 12px; }
code { background: #f5f5f5; padding: 2px 6px; border-radius: 4px; font-size: 12px; }
.btn-upload { background: var(--accent); color: #fff; border: none; border-radius: var(--radius); padding: 8px 16px; cursor: pointer; font-size: 13px; margin-top: 10px; margin-right: 10px; }
#uploadResult { font-size: 13px; color: var(--green); }
