:root {
  --surface-1: #fcfcfb;
  --page-plane: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --baseline-line: #c3c2b7;
  --border: rgba(11,11,11,0.10);
  --accent: #2a78d6;
  --accent-track: #e1e0d9;
  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;
  --success-text: #006300;
  --chip-bg: #f0efec;
}
@media (prefers-color-scheme: dark) {
  :root {
    --surface-1: #1a1a19;
    --page-plane: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --gridline: #2c2c2a;
    --baseline-line: #383835;
    --border: rgba(255,255,255,0.10);
    --accent: #3987e5;
    --accent-track: #2c2c2a;
    --status-good: #0ca30c;
    --status-warning: #fab219;
    --status-serious: #ec835a;
    --status-critical: #d03b3b;
    --success-text: #0ca30c;
    --chip-bg: #262625;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page-plane);
  color: var(--text-primary);
  padding: 24px;
}
.wrap { max-width: 1180px; margin: 0 auto; }

header.page-header { margin-bottom: 24px; display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
header.page-header h1 { font-size: 20px; margin: 0 0 4px; }
header.page-header .meta { color: var(--text-secondary); font-size: 13px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn.primary { background: var(--accent); color: #fff; border-color: transparent; }
.btn.setup-needed {
  background: var(--status-warning);
  color: #1a1a19;
  border-color: transparent;
  animation: blink-attention 1.4s ease-in-out infinite;
}
@keyframes blink-attention {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(250,178,25,0.6); }
  50% { opacity: 0.75; box-shadow: 0 0 0 6px rgba(250,178,25,0); }
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.stat-tile .label { font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; }
.stat-tile .value { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-tile .value.good { color: var(--success-text); }

section.panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}
section.panel h2 { font-size: 14px; margin: 0 0 10px; color: var(--text-secondary); font-weight: 600; }
.empty-note { color: var(--text-muted); font-size: 13px; }

.action-item, .flag-item, .setup-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--gridline);
  font-size: 13px;
  flex-wrap: wrap;
}
.action-item:last-child, .flag-item:last-child, .setup-item:last-child { border-bottom: none; }
.action-item .credit { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.setup-item .meta { color: var(--text-muted); font-size: 12px; }
.setup-item .btn.setup-needed { margin-left: auto; }
.setup-item .pill.done { margin-left: auto; }

.controls { margin-bottom: 12px; }
.controls input[type="search"] {
  width: 100%;
  max-width: 320px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-primary);
  font-size: 13px;
}

.table-scroll { overflow-x: auto; }
table.tracking {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 820px;
}
table.tracking th, table.tracking td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--gridline);
  vertical-align: top;
}
table.tracking th {
  color: var(--text-secondary);
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
table.tracking th .arrow { font-size: 10px; margin-left: 4px; color: var(--text-muted); }
table.tracking td.name { font-weight: 600; }
table.tracking td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

.month-list { display: flex; flex-direction: column; gap: 6px; }
.month-row { display: flex; flex-direction: column; gap: 1px; white-space: nowrap; padding-bottom: 4px; border-bottom: 1px dashed var(--gridline); }
.month-row:last-child { border-bottom: none; padding-bottom: 0; }
.month-row .m { color: var(--text-muted); font-size: 11px; }
.month-row .usage-line { display: flex; gap: 6px; align-items: center; }
.month-row .amt { font-variant-numeric: tabular-nums; }
.month-row .amt.neg { color: var(--status-critical); }
.month-row .usage { color: var(--text-secondary); font-variant-numeric: tabular-nums; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--chip-bg);
  color: var(--text-secondary);
  white-space: nowrap;
}
.pill.final { color: var(--text-secondary); }
.pill.provisional { color: var(--status-warning); }
.pill.paid { color: var(--success-text); }
.pill.pending { color: var(--text-muted); }
.pill.done { color: var(--success-text); }

.progress-cell { min-width: 190px; }
.progress-value { font-variant-numeric: tabular-nums; font-weight: 600; margin-bottom: 4px; }
.progress-value .preview-note { font-weight: 400; color: var(--text-muted); font-size: 11px; margin-left: 6px; }
.progress-track {
  position: relative;
  height: 8px;
  border-radius: 4px;
  background: var(--accent-track);
  margin-bottom: 4px;
}
.progress-fill {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  border-radius: 4px;
  background: var(--accent);
}
.progress-tick {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 1px;
  background: var(--baseline-line);
}
.progress-labels { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-muted); }

.tier-cell { font-variant-numeric: tabular-nums; font-weight: 700; }
.tier-cell.paid { color: var(--success-text); }
.tier-cell.unpaid { color: var(--status-critical); }
.tier-cell .date { display: block; font-weight: 400; font-size: 11px; color: var(--text-muted); }

.flags-cell { max-width: 220px; color: var(--text-secondary); font-size: 12px; }

footer.note {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 16px;
  text-align: center;
}

/* 신청 폼 (apply.html) */
form.apply-form { display: flex; flex-direction: column; gap: 14px; max-width: 480px; }
form.apply-form label { font-size: 13px; font-weight: 600; margin-bottom: 4px; display: block; }
form.apply-form .field-hint { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
form.apply-form input, form.apply-form select, form.apply-form textarea {
  width: 100%;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--page-plane);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
}
form.apply-form textarea { min-height: 90px; resize: vertical; }
.form-message { padding: 10px 12px; border-radius: 8px; font-size: 13px; display: none; }
.form-message.success { display: block; background: rgba(12,163,12,0.12); color: var(--success-text); }
.form-message.error { display: block; background: rgba(208,59,59,0.12); color: var(--status-critical); }

/* 모달 (세팅 완료 처리 시 CloudCheckr 계정명 입력) */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal-box {
  background: var(--surface-1); border-radius: 12px; padding: 20px;
  width: 100%; max-width: 360px; border: 1px solid var(--border);
}
.modal-box h3 { margin: 0 0 12px; font-size: 15px; }
.modal-box .actions { display: flex; gap: 8px; margin-top: 14px; justify-content: flex-end; }
