/* ============================================================
   매출관리 v2 디자인 시스템
   Stripe 베이스 + 인디고 가족 (cool indigo family)
   ============================================================ */

:root {
  /* 메인 (인디고 가족) */
  --primary: #4f46e5;             /* indigo-600 — CTA 버튼 */
  --primary-hover: #4338ca;       /* indigo-700 — 호버 */
  --primary-soft: #e0e7ff;        /* indigo-100 — 합계 컬럼 */
  --primary-tint: rgba(79,70,229,0.06);
  --primary-border: #c7d2fe;      /* indigo-200 */
  --primary-deep: #3730a3;        /* indigo-800 */

  /* 텍스트 / 배경 */
  --bg: #ffffff;
  --bg-alt: #f8fafc;              /* slate-50 */
  --bg-dark: #1e1b4b;             /* indigo-950 — 합계 행 다크 */
  --heading: #1e1b4b;
  --label: #334155;               /* slate-700 */
  --body: #475569;                /* slate-600 */
  --body-light: #64748b;          /* slate-500 */
  --muted: #94a3b8;               /* slate-400 */
  --border: #e2e8f0;              /* slate-200 */
  --border-soft: #eef2f7;

  /* 상태 (모두 600 레벨, 채도 매칭) */
  --success: #059669;             /* emerald-600 */
  --success-bg: rgba(5,150,105,0.10);
  --success-border: rgba(5,150,105,0.28);
  --warn: #d97706;                /* amber-600 */
  --warn-bg: rgba(217,119,6,0.08);
  --danger: #dc2626;              /* red-600 */
  --danger-bg: rgba(220,38,38,0.08);

  /* 그림자 (Stripe 시그니처) */
  --shadow-amb: rgba(23,23,23,0.06) 0px 3px 6px;
  --shadow-card: rgba(23,23,23,0.08) 0px 15px 35px 0px;
  --shadow-elev: rgba(50,50,93,0.25) 0px 30px 45px -30px,
                 rgba(0,0,0,0.1) 0px 18px 36px -18px;
}

/* === Reset === */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  font-family: 'Pretendard', 'Apple SD Gothic Neo', -apple-system, system-ui, 'SF Pro Display', sans-serif;
  background: var(--bg);
  color: var(--heading);
  font-size: 14px;
  font-feature-settings: "ss01";
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* === Navigation === */
.nav {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  display: flex;
  align-items: center;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}
.nav-brand {
  font-size: 17px;
  font-weight: 400;
  color: var(--heading);
  margin-right: 36px;
  letter-spacing: -0.2px;
}
.nav-brand .accent { color: var(--primary); margin-right: 4px; }
.nav-links { display: flex; gap: 4px; flex: 1; }
.nav-link {
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 400;
  color: var(--heading);
  background: none;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-feature-settings: "ss01";
  transition: background 0.15s;
  font-family: inherit;
}
.nav-link:hover { background: var(--primary-tint); color: var(--primary); }
.nav-link.active { color: var(--primary); background: var(--primary-tint); }
.nav-user {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--body);
  font-size: 13px;
}
.nav-user strong { color: var(--heading); font-weight: 400; }

/* === Buttons === */
.btn {
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
  font-family: inherit;
  font-feature-settings: "ss01";
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-ghost {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary-border);
}
.btn-ghost:hover { background: var(--primary-tint); }
.btn-neutral {
  background: transparent;
  color: var(--body-light);
  border-color: var(--border);
  font-size: 13px;
  padding: 6px 12px;
}
.btn-neutral:hover { background: var(--bg-alt); }
.btn-success {
  background: var(--success);
  color: white;
}
.btn-success:hover { background: #047857; }
.btn-sm { font-size: 12px; padding: 6px 12px; }

/* === Layout === */
.content { max-width: 1600px; margin: 0 auto; padding: 28px; }
.page { display: none; }
.page.active { display: block; }

/* === Cards === */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-amb);
}
.card-title {
  font-size: 22px;
  font-weight: 300;
  color: var(--heading);
  margin-bottom: 16px;
  letter-spacing: -0.22px;
  line-height: 1.10;
}

/* === Form === */
.form-row { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 12px; }
.form-col { display: flex; flex-direction: column; gap: 6px; }
.form-col label {
  font-size: 14px;
  font-weight: 400;
  color: var(--label);
}
select, .input-field {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 14px;
  outline: none;
  background: var(--bg);
  min-width: 200px;
  color: var(--heading);
  font-family: inherit;
  font-feature-settings: "ss01";
  font-weight: 300;
}
select:focus, .input-field:focus { border-color: var(--primary); }
.info-msg {
  font-size: 13px;
  color: var(--body);
  margin-top: 10px;
  font-weight: 300;
}

/* === Stat Cards === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 22px;
  box-shadow: var(--shadow-elev);
}
.stat-label { font-size: 13px; color: var(--body); margin-bottom: 8px; font-feature-settings: "ss01"; }
.stat-value {
  font-size: 32px;
  font-weight: 300;
  color: var(--heading);
  letter-spacing: -0.64px;
  line-height: 1.10;
  font-feature-settings: "tnum";
}
.stat-sub { font-size: 12px; color: var(--body); margin-top: 4px; font-feature-settings: "tnum"; }

/* === Department Cards === */
.dept-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 22px 26px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-card);
}
.dept-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.dept-name {
  font-size: 22px;
  font-weight: 300;
  color: var(--heading);
  letter-spacing: -0.22px;
  line-height: 1.10;
}

/* === Data Tables === */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
  font-feature-settings: "tnum";
}
table.data th {
  text-align: right;
  padding: 10px 6px;
  border-bottom: 1px solid var(--border);
  color: var(--body);
  font-weight: 400;
  font-size: 12px;
}
table.data th:first-child { text-align: left; padding-left: 10px; color: var(--label); }
table.data td {
  text-align: right;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
  color: var(--heading);
  font-weight: 300;
}
table.data td:first-child { text-align: left; padding-left: 10px; color: var(--label); font-weight: 400; }
table.data tr:hover td { background: var(--bg-alt); }
table.data .label-bold { color: var(--heading); font-weight: 400; }
table.data .label-indent { color: var(--body); padding-left: 26px !important; font-weight: 300; }
table.data .total-col { background: var(--primary-soft); color: var(--primary); font-weight: 400; }
table.data .subtotal-row td { background: var(--bg-alt); color: var(--body); font-size: 12px; }
table.data .subtotal-row td:first-child { color: var(--body); }
table.data .total-row td {
  background: var(--bg-dark);
  color: white;
  font-weight: 400;
  font-size: 14px;
  padding: 12px 6px;
}
table.data .total-row td:first-child { color: white; }
table.data .total-row.r-success td { background: #064e3b; }
table.data .total-row.r-warn td { background: #78350f; }
table.data .total-row.r-danger td { background: #7f1d1d; }

/* === Badges === */
.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 400;
}
.badge-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-border);
}
.badge-warn {
  background: var(--warn-bg);
  color: var(--warn);
}
.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

/* === Rate text colors === */
.rate-good { color: var(--success); font-weight: 400; }
.rate-warn { color: var(--warn); font-weight: 400; }
.rate-bad { color: var(--danger); font-weight: 400; }

/* === Delta (증감 표시) === */
.delta-up {
  font-size: 10px;
  color: var(--success);
  margin-top: 2px;
  line-height: 1.1;
  font-feature-settings: "tnum";
}
.delta-down {
  font-size: 10px;
  color: var(--danger);
  margin-top: 2px;
  line-height: 1.1;
  font-feature-settings: "tnum";
}

/* === Edit Cell === */
.edit-cell {
  width: 100%;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 12px;
  text-align: right;
  outline: none;
  box-sizing: border-box;
  font-family: inherit;
  font-feature-settings: "tnum";
  background: var(--bg);
}
.edit-cell:focus { border-color: var(--primary); }

/* === Toast === */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 400;
  color: white;
  z-index: 1000;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s;
  box-shadow: var(--shadow-elev);
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--primary); }

/* === Loading Overlay === */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.7);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  font-size: 15px;
  color: var(--body);
  font-weight: 300;
}
.loading-overlay.show { display: flex; }
.loading-overlay-content { text-align: center; }
.loading-overlay-content .spinner { font-size: 24px; margin-bottom: 8px; }

/* === Login Page === */
.login-bg {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-alt);
  padding: 24px;
}
.login-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-elev);
}
.login-header { text-align: center; margin-bottom: 36px; }
.login-header h1 {
  font-size: 24px;
  font-weight: 300;
  color: var(--heading);
  margin-bottom: 8px;
  letter-spacing: -0.3px;
}
.login-header p { font-size: 14px; color: var(--body); font-weight: 300; }
.login-google-btn {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg);
  color: var(--heading);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 15px;
  font-weight: 400;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-family: inherit;
  transition: all 0.15s;
}
.login-google-btn:hover {
  background: var(--bg-alt);
  border-color: var(--primary-border);
}
.login-google-btn img { width: 20px; height: 20px; }
.login-divider {
  display: flex;
  align-items: center;
  margin: 24px 0;
  color: var(--muted);
  font-size: 12px;
}
.login-divider::before, .login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.login-divider span { padding: 0 12px; }
.error-msg {
  color: var(--danger);
  font-size: 13px;
  text-align: center;
  margin-top: 16px;
  padding: 10px;
  background: var(--danger-bg);
  border-radius: 4px;
  display: none;
}
.error-msg.show { display: block; }
