/* =============================================================================
 * LOWIDE 지출관리 — Design System
 * executive_dashboard_3 디자인 토큰·셸 재사용 (Apple 미니멀 + Bloomberg 데이터 밀도 + Porsche 메탈/블랙)
 * =========================================================================== */

/* ── 디자인 토큰 ──────────────────────────────────────────────────────────── */
:root {
  /* 베이스 */
  --bg-0: #000000;
  --bg-1: #05060A;
  --bg-2: #0A0A0F;
  --bg-3: #101019;

  /* 글래스 */
  --glass-bg: rgba(255, 255, 255, 0.04);
  --glass-bg-hover: rgba(255, 255, 255, 0.06);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-border-strong: rgba(255, 255, 255, 0.14);

  /* 포인트 컬러 */
  --blue: #0A84FF;
  --blue-2: #3B82F6;
  --cyan: #64D2FF;
  --up: #0A84FF;      /* 상승 = 블루 */
  --down: #FF453A;    /* 하락 = 레드 */
  --green: #30D158;
  --amber: #FF9F0A;
  --purple: #5E5CE6;

  /* 텍스트 */
  --text-0: #F5F7FA;
  --text-1: #C7CDD6;
  --text-2: #8A93A2;
  --text-3: #5B6270;

  /* 형태 */
  --radius: 18px;
  --radius-sm: 12px;
  --blur: 20px;
  --shadow-1: 0 8px 30px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 0 1px rgba(10, 132, 255, 0.0), 0 10px 40px rgba(10, 132, 255, 0.12);

  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter',
          'Pretendard', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ── 리셋 ─────────────────────────────────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  color: var(--text-0);
  background:
    radial-gradient(1200px 700px at 78% -8%, rgba(10, 132, 255, 0.10), transparent 60%),
    radial-gradient(900px 600px at 8% 110%, rgba(94, 92, 230, 0.08), transparent 55%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-0) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.tnum { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' 1; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
::selection { background: rgba(10, 132, 255, 0.35); }

/* ── 스크롤바 ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.16); }

/* ── 레이아웃 셸 ──────────────────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }

/* 사이드바 (데스크톱) */
.sidebar {
  width: 240px; flex-shrink: 0;
  padding: 22px 16px;
  border-right: 1px solid var(--glass-border);
  background: rgba(255,255,255,0.015);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 8px;
}
.brand { display: flex; flex-direction: column; gap: 5px; padding: 10px 12px 22px; }
.brand-wordmark {
  font-weight: 700; font-size: 23px; letter-spacing: 0.2em;
  color: #fff; line-height: 1; padding-left: 0.1em;
}
.brand-sub { font-size: 11px; color: var(--text-2); letter-spacing: 0.32em; padding-left: 0.15em; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 14px; font-weight: 500;
  transition: all 0.2s var(--ease); width: 100%; text-align: left;
}
.nav-item:hover { color: var(--text-0); background: var(--glass-bg); }
.nav-item.active {
  color: #fff; background: linear-gradient(135deg, rgba(10,132,255,0.22), rgba(94,92,230,0.14));
  box-shadow: inset 0 0 0 1px rgba(10,132,255,0.35);
}
.nav-item .ic { width: 18px; height: 18px; opacity: 0.9; }
.nav-spacer { flex: 1; }
.nav-foot { padding: 10px 12px; font-size: 11px; color: var(--text-3); border-top: 1px solid var(--glass-border); }

/* 메인 영역 */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ── 상단바 ───────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 16px 28px;
  background: linear-gradient(180deg, rgba(5,6,10,0.92), rgba(5,6,10,0.72));
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--glass-border);
}
.page-title { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }
.page-title small { display: block; font-size: 12px; color: var(--text-2); font-weight: 400; margin-top: 2px; }
.topbar-spacer { flex: 1; }

.filter-group { display: flex; align-items: center; gap: 8px; }
.filter-label { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 1px; margin-right: 2px; }

.chip {
  padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 500;
  color: var(--text-1); background: var(--glass-bg);
  border: 1px solid var(--glass-border); transition: all 0.18s var(--ease);
  white-space: nowrap;
}
.chip:hover { background: var(--glass-bg-hover); color: var(--text-0); }
.chip.active {
  color: #fff; background: rgba(10,132,255,0.18);
  border-color: rgba(10,132,255,0.5); box-shadow: 0 0 0 1px rgba(10,132,255,0.25);
}

.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--glass-bg); border: 1px solid var(--glass-border);
  color: var(--text-1); transition: all 0.2s var(--ease);
}
.icon-btn:hover { background: var(--glass-bg-hover); color: #fff; transform: translateY(-1px); }
.icon-btn.spin svg { animation: spin 0.7s var(--ease); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 콘텐츠 ───────────────────────────────────────────────────────────────── */
.content { padding: 24px 28px 96px; }
.section-title {
  font-size: 13px; font-weight: 600; color: var(--text-2);
  text-transform: uppercase; letter-spacing: 1.4px; margin: 8px 2px 14px;
}

/* ── 카드 (글래스모피즘) ──────────────────────────────────────────────────── */
.card {
  position: relative; border-radius: var(--radius);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(var(--blur)); -webkit-backdrop-filter: blur(var(--blur));
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
.card::before { /* inner-glow 상단 하이라이트 */
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,0.05), transparent 40%);
}

/* KPI 그리드 */
.kpi-grid {
  display: grid; gap: 14px; margin-bottom: 26px;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}
.kpi {
  padding: 18px 18px 16px; min-height: 118px;
  display: flex; flex-direction: column; justify-content: space-between;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.25s var(--ease);
  cursor: default;
}
.kpi:hover {
  transform: scale(1.02); border-color: var(--glass-border-strong);
  box-shadow: var(--shadow-1), var(--shadow-glow);
}
.kpi.hero { grid-column: span 1; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-label { font-size: 12.5px; color: var(--text-2); font-weight: 500; letter-spacing: 0.2px; }
.kpi-accent { width: 8px; height: 8px; border-radius: 3px; background: var(--blue); box-shadow: 0 0 10px var(--blue); }
.kpi-value {
  font-size: 27px; font-weight: 750; letter-spacing: -0.8px; line-height: 1.1; margin-top: 10px;
  color: var(--text-0);
}
.kpi.hero .kpi-value { font-size: 32px; }
.kpi-value .unit { font-size: 15px; color: var(--text-2); font-weight: 600; margin-left: 2px; }
.kpi-delta { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600; margin-top: 8px; }
.kpi-delta.up { color: var(--up); }
.kpi-delta.down { color: var(--down); }
.kpi-delta.flat { color: var(--text-3); }
.kpi-delta .arw { font-size: 11px; }
.kpi-delta .cmp { color: var(--text-3); font-weight: 400; margin-left: 3px; }

/* ── 차트 그리드 ──────────────────────────────────────────────────────────── */
.charts { display: grid; gap: 16px; grid-template-columns: repeat(12, 1fr); }
.chart-card { padding: 20px; display: flex; flex-direction: column; }
.col-4 { grid-column: span 4; }
.col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; }
.col-7 { grid-column: span 7; }
.col-8 { grid-column: span 8; }
.col-12 { grid-column: span 12; }

.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.chart-title { font-size: 15px; font-weight: 650; letter-spacing: -0.2px; }
.chart-sub { font-size: 12px; color: var(--text-3); }
.chart-body { position: relative; flex: 1; min-height: 0; }
.chart-body.h-sm { height: 220px; }
.chart-body.h-md { height: 280px; }
.chart-body.h-lg { height: 340px; }
canvas { max-width: 100%; }

/* ── 빈 상태 ──────────────────────────────────────────────────────────────── */
.empty {
  display: grid; place-items: center; text-align: center; padding: 60px 20px; color: var(--text-3);
}
.empty .em-ic { font-size: 34px; margin-bottom: 10px; opacity: 0.5; }
.empty h3 { font-size: 15px; color: var(--text-2); font-weight: 600; margin-bottom: 4px; }
.empty p { font-size: 13px; }
.empty-note { display: grid; place-content: center; height: 100%; text-align: center; font-size: 13.5px; color: var(--text-2); padding: 0 12px; }

/* ── 스켈레톤 로딩 (글래스 쉬머) ──────────────────────────────────────────── */
.skeleton { position: relative; overflow: hidden; background: rgba(255,255,255,0.03); border-radius: 8px; }
.skeleton::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.06), transparent);
  transform: translateX(-100%); animation: shimmer 1.4s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

/* ── 진입 애니메이션 ──────────────────────────────────────────────────────── */
.reveal { opacity: 0; transform: translateY(10px); animation: reveal 0.5s var(--ease) forwards; }
@keyframes reveal { to { opacity: 1; transform: none; } }

/* placeholder 탭 배지 */
.soon-badge {
  display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: 0.5px;
  color: var(--amber); background: rgba(255,159,10,0.12);
  border: 1px solid rgba(255,159,10,0.3); padding: 2px 7px; border-radius: 999px; margin-left: 8px;
}

/* ── 폼 (지출 등록/설정) ──────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--text-2); font-weight: 500; }
.input {
  background: rgba(255,255,255,0.04); border: 1px solid var(--glass-border); border-radius: 10px;
  padding: 10px 12px; color: var(--text-0); font-size: 13.5px; font-family: inherit; outline: none; width: 100%;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.input:focus { border-color: rgba(10,132,255,0.6); background: rgba(255,255,255,0.06); }
.input::placeholder { color: var(--text-3); }
.input::-webkit-calendar-picker-indicator { filter: invert(0.7); }
.period-date { width: 150px; padding: 8px 10px; font-size: 13px; }

.btn { padding: 10px 18px; border-radius: 10px; font-size: 13.5px; font-weight: 600; transition: all 0.18s var(--ease); }
.btn-primary { background: linear-gradient(135deg, var(--blue), var(--blue-2)); color: #fff; box-shadow: 0 6px 18px rgba(10,132,255,0.3); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(10,132,255,0.42); }
.btn-ghost { background: var(--glass-bg); border: 1px solid var(--glass-border); color: var(--text-1); }
.btn-ghost:hover { background: var(--glass-bg-hover); color: #fff; }

/* ── 일반 관리 테이블 (분류/태그 관리 등) ─────────────────────────────────── */
.adm-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.adm-table th { text-align: left; padding: 10px 12px; color: var(--text-3); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--glass-border); font-weight: 600; }
.adm-table td { text-align: left; padding: 12px; border-bottom: 1px solid rgba(255,255,255,0.04); color: var(--text-1); }
.adm-table th:last-child, .adm-table td:last-child { text-align: right; }
.adm-table tbody tr:hover { background: var(--glass-bg); }

.st { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; }
.st .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-ok { color: var(--green); background: rgba(48,209,88,0.12); }
.st-off { color: var(--text-3); background: rgba(255,255,255,0.05); }

.switch { position: relative; width: 42px; height: 24px; border-radius: 999px; background: rgba(255,255,255,0.12); cursor: pointer; transition: background 0.2s var(--ease); flex-shrink: 0; }
.switch.on { background: var(--blue); }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 0.2s var(--ease); }
.switch.on::after { transform: translateX(18px); }

/* 카테고리/태그 색상 점 */
.tag-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }

.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: rgba(10,10,15,0.96); border: 1px solid var(--glass-border-strong); color: var(--text-0);
  padding: 12px 20px; border-radius: 12px; font-size: 13.5px; z-index: 100; box-shadow: var(--shadow-1);
  transition: all 0.3s var(--ease); pointer-events: none; display: flex; align-items: center; gap: 8px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast .ok { color: var(--green); font-weight: 700; }

/* ── 모바일 하단 탭 ───────────────────────────────────────────────────────── */
.mobile-nav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(5,6,10,0.7), rgba(5,6,10,0.96));
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--glass-border);
  justify-content: space-around;
}
.mnav-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--text-3); font-size: 10px; font-weight: 500; flex: 1; padding: 4px 0;
  transition: color 0.2s var(--ease);
}
.mnav-item .ic { width: 22px; height: 22px; }
.mnav-item.active { color: var(--blue); }

/* ── 반응형 ───────────────────────────────────────────────────────────────── */
@media (max-width: 1439px) {
  .col-4 { grid-column: span 6; }
}
@media (max-width: 1023px) {
  .content { padding: 20px 18px 96px; }
  .charts { grid-template-columns: repeat(6, 1fr); }
  .col-4, .col-5, .col-6, .col-7, .col-8, .col-12 { grid-column: span 6; }
}
@media (max-width: 767px) {
  .sidebar { display: none; }
  .mobile-nav { display: flex; }
  .topbar { padding: 14px 16px; gap: 10px; }
  .page-title { font-size: 17px; }
  .charts { grid-template-columns: 1fr; }
  .col-4, .col-5, .col-6, .col-7, .col-8, .col-12 { grid-column: span 1; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi { padding: 14px; min-height: 100px; }
  .kpi-value { font-size: 22px; }
  .kpi.hero .kpi-value { font-size: 24px; }
  .filter-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .filter-scroll::-webkit-scrollbar { display: none; }
  .topbar-spacer { display: none; }
  .form-grid { grid-template-columns: 1fr 1fr; }
}
