/* 활동 기록 · AI 사용량·예산 · 백업 내려받기/복원 (기획 15번) — window.renderAuditLog(), window.renderAiUsage() */

/* ── 공통 ───────────────────────────────────────────────────── */
.ad-note { font-size: 12.5px; color: var(--text-muted); line-height: 1.7; margin: -10px 0 16px; }
.ad-note strong { color: var(--text); font-weight: 600; }
.ad-btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ad-btn-link { display: inline-block; text-decoration: none; line-height: 1.4; }
.ad-sm { padding: 5px 12px; font-size: 12px; white-space: nowrap; }
.ad-num { font-variant-numeric: tabular-nums; }
.ad-nowrap { white-space: nowrap; }
.ad-muted { color: var(--text-muted); font-size: 11.5px; }
.ad-h2 { font-size: 15px; font-weight: 700; margin: 24px 0 10px; color: var(--text); }
.ad-error { color: var(--red); font-size: 13px; padding: 12px 0; }

/* ── 활동 기록 ───────────────────────────────────────────────── */
.ad-filters { display: flex; flex-wrap: wrap; gap: 12px 14px; align-items: flex-end; padding: 16px 20px; }
.ad-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ad-field label, .ad-field > .ad-label { font-size: 11.5px; font-weight: 600; color: var(--text-muted); text-transform: none; letter-spacing: 0; }
.ad-field input, .ad-field select { width: 100%; min-height: 36px; }
.ad-field-range { flex-direction: row; align-items: flex-end; gap: 6px; }
.ad-field-range > div { display: flex; flex-direction: column; gap: 4px; }
.ad-field-range input { width: 136px; }
.ad-range-sep { padding-bottom: 8px; color: var(--text-muted); }
.ad-field-select { width: 128px; }
.ad-field-search { flex: 1 1 150px; min-width: 140px; }
.ad-filter-actions { display: flex; gap: 8px; }

.ad-audit-table td { vertical-align: top; }
.ad-cell { min-width: 0; }
.ad-table .ad-keys { display: block; margin-top: 2px; color: var(--text-muted); font-size: 11.5px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ad-user { font-weight: 600; }
.ad-user small { display: block; font-weight: 400; color: var(--text-muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.ad-target { font-variant-numeric: tabular-nums; }

.ad-badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--bg-hover); color: var(--text); }
.ad-act-add  { background: rgba(16,185,129,.14); color: #0b7a56; }
.ad-act-edit { background: rgba(59,130,246,.13); color: #1d56b8; }
.ad-act-del  { background: rgba(224,73,94,.13);  color: #b3263b; }
.ad-act-warn { background: rgba(240,180,41,.20); color: #8a5a00; }
.ad-res-ok   { background: rgba(16,185,129,.14); color: #0b7a56; }
.ad-res-warn { background: rgba(240,180,41,.20); color: #8a5a00; }
.ad-res-bad  { background: rgba(224,73,94,.13);  color: #b3263b; }
:root[data-theme="dark"] .ad-act-add,  :root[data-theme="dark"] .ad-res-ok   { color: #6ee7b7; }
:root[data-theme="dark"] .ad-act-edit { color: #93c5fd; }
:root[data-theme="dark"] .ad-act-del,  :root[data-theme="dark"] .ad-res-bad  { color: #fda4af; }
:root[data-theme="dark"] .ad-act-warn, :root[data-theme="dark"] .ad-res-warn { color: #fcd34d; }

.ad-pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 16px 0 4px; font-size: 13px; color: var(--text-muted); flex-wrap: wrap; }
.ad-pager button:disabled { opacity: .45; cursor: default; }

/* ── AI 사용량 ───────────────────────────────────────────────── */
.ad-month-nav { display: flex; align-items: center; gap: 6px; }
.ad-month-nav .ad-month-label { min-width: 104px; text-align: center; font-weight: 700; font-size: 15px; }
.ad-month-nav button { background: var(--surface); border: 1px solid var(--border); color: var(--text); border-radius: 7px; width: 32px; height: 32px; cursor: pointer; font-size: 14px; }
.ad-month-nav button:hover:not(:disabled) { border-color: var(--accent); }
.ad-month-nav button:disabled { opacity: .4; cursor: default; }

.ad-alert { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--border); border-left-width: 4px; border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; font-size: 13px; line-height: 1.65; color: var(--text); }
.ad-alert-icon { flex: none; font-size: 16px; line-height: 1.5; }
.ad-alert-warn { border-color: var(--yellow); background: rgba(240,180,41,.13); }
.ad-alert-bad  { border-color: var(--red); background: rgba(224,73,94,.10); }

.ad-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.ad-tile { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px 20px; min-width: 0; }
.ad-tile-label { font-size: 12.5px; color: var(--text-muted); font-weight: 600; }
.ad-tile-value { font-size: 28px; font-weight: 700; line-height: 1.25; margin-top: 4px; color: var(--text); overflow-wrap: anywhere; }
.ad-tile-sub { font-size: 12px; color: var(--text-muted); margin-top: 6px; line-height: 1.55; }
.ad-meter { height: 8px; border-radius: 4px; background: var(--bg-hover); overflow: hidden; margin-top: 10px; }
.ad-meter-fill { display: block; height: 100%; border-radius: 4px; background: var(--accent); min-width: 2px; }
.ad-meter-fill.ad-lv-warn { background: var(--yellow); }
.ad-meter-fill.ad-lv-bad { background: var(--red); }

.ad-chart-card { padding: 18px 20px 14px; }
.ad-chart-title { font-size: 14px; font-weight: 700; color: var(--text); }
.ad-chart-sub { font-size: 12px; color: var(--text-muted); margin: 2px 0 12px; }
.ad-chart { display: flex; gap: 8px; align-items: stretch; }
.ad-chart-y { position: relative; height: 160px; width: 38px; flex: none; font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; line-height: 1; }
.ad-chart-y span { position: absolute; right: 0; transform: translateY(-50%); white-space: nowrap; }
.ad-chart-plot { position: relative; flex: 1; min-width: 0; }
.ad-grid { position: absolute; left: 0; right: 0; top: 0; height: 160px; pointer-events: none; }
.ad-grid i { position: absolute; left: 0; right: 0; height: 1px; background: var(--border); }
.ad-bars { position: relative; display: flex; height: 160px; align-items: stretch; }
.ad-slot { flex: 1 1 0; min-width: 0; padding: 0; margin: 0; border: 0; background: transparent; display: flex; justify-content: center; align-items: flex-end; cursor: default; border-radius: 4px; }
.ad-slot:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ad-bar { display: block; width: min(24px, calc(100% - 4px)); background: var(--accent); border-radius: 4px 4px 0 0; transition: filter .12s; }
.ad-bar.ad-bar-zero { background: var(--border); }
.ad-slot:hover .ad-bar, .ad-slot:focus-visible .ad-bar, .ad-slot.is-hot .ad-bar { filter: brightness(1.12); }
.ad-slot:hover, .ad-slot.is-hot { background: var(--bg-hover); }
.ad-xaxis { display: flex; margin-top: 6px; }
.ad-xaxis span { flex: 1 1 0; min-width: 0; text-align: center; font-size: 10.5px; color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ad-xaxis span.is-today { color: var(--text); font-weight: 700; }
.ad-tip { position: absolute; z-index: 5; pointer-events: none; background: var(--navy); color: #fff; border-radius: 8px; padding: 6px 10px; font-size: 12px; line-height: 1.45; white-space: nowrap; box-shadow: var(--shadow); transform: translate(-50%, -100%); }
:root[data-theme="dark"] .ad-tip { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.ad-tip strong { display: block; font-size: 13px; }
.ad-tip span { opacity: .8; }
.ad-details { margin-top: 12px; font-size: 13px; }
.ad-details summary { cursor: pointer; color: var(--text-muted); font-size: 12.5px; padding: 4px 0; }
.ad-details summary:hover { color: var(--text); }
.ad-details .table-wrap { margin-top: 8px; box-shadow: none; }

.ad-table th.ad-r, .ad-table td.ad-r { text-align: right; }
.ad-empty-row td { text-align: center; color: var(--text-muted); padding: 22px; }

/* 설정 폼 */
.ad-set-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; max-width: 680px; }
.ad-field .ad-hint { font-size: 11.5px; color: var(--text-muted); line-height: 1.5; }
.ad-price-table input { min-width: 0; padding: 6px 8px; font-size: 12.5px; text-align: right; font-variant-numeric: tabular-nums; }
.ad-price-table input.ad-model-in { text-align: left; }
.ad-price-table select { padding: 6px 8px; font-size: 12.5px; }
.ad-price-table td { vertical-align: middle; }
.ad-price-table td:first-child { white-space: nowrap; }
.ad-price-table .ad-na { color: var(--text-muted); text-align: center; }
.ad-save-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 16px; }

/* ── 백업 화면 보강 ─────────────────────────────────────────── */
.ad-backup-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.ad-backup-actions a, .ad-backup-actions button { text-decoration: none; }
.ad-restore-list { margin: 10px 0 14px; padding-left: 18px; font-size: 13px; line-height: 1.75; color: var(--text); }
.ad-restore-list li { margin-bottom: 4px; }
.ad-restore-file { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; font-size: 13px; margin-bottom: 8px; word-break: break-all; }
.ad-confirm-label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; }
.ad-confirm-err { color: var(--red); font-size: 12.5px; min-height: 18px; margin-top: 6px; }
.ad-file-input { width: 100%; font-size: 13px; color: var(--text); }

/* ── 좁은 화면 ──────────────────────────────────────────────── */
@media (max-width: 900px) {
  .ad-tiles { grid-template-columns: 1fr 1fr; }
  .ad-tiles .ad-tile:first-child { grid-column: 1 / -1; }
  .ad-field-select { width: calc(50% - 7px); }
}
@media (max-width: 640px) {
  .ad-filters { padding: 14px; }
  .ad-field-range { width: 100%; }
  .ad-field-range > div { flex: 1; }
  .ad-field-range input { width: 100%; }
  .ad-field-search { flex-basis: 100%; }
  .ad-filter-actions { width: 100%; }
  .ad-filter-actions button { flex: 1; }
  .ad-tiles { grid-template-columns: 1fr; }
  .ad-tile-value { font-size: 24px; }
  .ad-set-grid { grid-template-columns: 1fr; }
  .ad-chart-y { width: 30px; }

  .ad-table thead { display: none; }
  .ad-table, .ad-table tbody, .ad-table tr, .ad-table td { display: block; width: 100%; }
  .ad-table tr { padding: 10px 14px; border-bottom: 1px solid var(--border); }
  .ad-table tr:last-child { border-bottom: 0; }
  .ad-table td { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; padding: 3px 0; border: 0; text-align: right; }
  .ad-table td::before { content: attr(data-label); color: var(--text-muted); font-size: 12px; font-weight: 600; flex: none; text-align: left; }
  .ad-table .ad-keys { max-width: 190px; margin-left: auto; }
  .ad-table td.ad-r { text-align: right; }
  .ad-table td { overflow-wrap: anywhere; }
  .ad-table td .ad-cell, .ad-table td > span { text-align: right; min-width: 0; }
  .ad-table td.ad-dash { display: none; }
  .ad-price-table td:first-child { white-space: normal; }
  .ad-price-table td.ad-na { display: none; }
  .ad-table td:empty { display: none; }
  .ad-price-table td input { max-width: 150px; }
  .ad-backup-actions { justify-content: flex-start; }
}
