/* ===========================================================
   MOISĒ Dashboard — Apple-style + Soft Pastel
   - 흰 카드 + 미세 보더
   - 단일 액센트 (Sianna Rose)
   - Apple 시스템 컬러 (상태)
   - 차트: 파스텔 4종 (헬스앱 무드)
   - 10% 컴팩트 + 모바일 반응형
   =========================================================== */

:root {
  /* Background & neutrals (Apple) */
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-warm: #fafafa;
  --surface-deeper: #f0f0f2;
  --border: #d2d2d7;
  --border-strong: #b8b8be;

  --ink: #1d1d1f;
  --ink-soft: #424245;
  --ink-body: #515154;
  --ink-mute: #86868b;

  /* Brand accent — Sianna Rose */
  --purple: #c44774;
  --magenta: #ad3a64;
  --rose: #c44774;
  --rose-light: #fce8ef;
  --rose-deep: #ad3a64;

  /* Status — Apple system */
  --teal: #34c759;
  --green: #34c759;
  --amber: #ff9500;
  --red: #ff3b30;

  --purple-bg: #fce8ef;
  --magenta-bg: #fce8ef;
  --teal-bg: #e3f9e7;
  --green-bg: #e3f9e7;
  --amber-bg: #fff0db;
  --red-bg: #ffe5e3;

  /* Pastel chart palette */
  --c-pink: #f2a8c2;
  --c-yellow: #f4d466;
  --c-green: #b0ce74;
  --c-blue: #abc6e4;

  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --side-w: 220px;
  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 13px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }

/* ===== Sidebar ===== */
.sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--side-w); height: 100vh;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 100;
}
.sb-brand {
  height: 58px;
  padding: 0 22px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
}
.sb-brand img.logo { max-height: 20px; max-width: 100%; }
.sb-brand .mark {
  font-size: 14px; font-weight: 600;
  letter-spacing: 2.5px; color: var(--ink);
}
.sb-nav { padding: 14px 10px; flex: 1; overflow-y: auto; }
.sb-section {
  font-size: 10.5px; font-weight: 600;
  color: var(--ink-mute);
  letter-spacing: 0.4px;
  padding: 14px 14px 6px;
}
.sb-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  font-size: 13px; color: var(--ink-body);
  border-radius: 8px; margin: 1px 0;
  transition: background 0.15s;
}
.sb-link:hover { background: var(--surface-deeper); color: var(--ink); }
.sb-link.active {
  background: var(--purple-bg);
  color: var(--magenta);
  font-weight: 600;
}
.sb-link .ic { width: 16px; text-align: center; font-size: 14px; }
.sb-link .new {
  margin-left: auto;
  font-size: 9px; letter-spacing: 0.3px;
  background: var(--purple); color: #fff;
  padding: 1px 6px; border-radius: 4px; font-weight: 700;
}
.sb-foot {
  padding: 14px 22px; border-top: 1px solid var(--border);
  font-size: 11px; color: var(--ink-mute);
}

/* ===== Topbar ===== */
.main { margin-left: var(--side-w); min-height: 100vh; }
.topbar {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  padding: 0 36px; height: 58px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
  border-bottom: 1px solid var(--border);
}
.tb-eyebrow { display: none; }
.tb-title { font-size: 15px; font-weight: 600; letter-spacing: -0.3px; color: var(--ink); }
.tb-right { display: flex; align-items: center; gap: 10px; }
.tb-select {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 980px;
  padding: 6px 14px;
  font-size: 12px; color: var(--ink);
  outline: none; cursor: pointer;
}
.btn {
  background: var(--ink); color: #fff;
  border: none; border-radius: 980px;
  padding: 7px 16px; font-size: 12px; font-weight: 500;
  letter-spacing: -0.1px;
}
.btn:hover { background: #000; }
.btn.ghost {
  background: transparent; color: var(--ink);
  border: 1px solid var(--border-strong);
}
.btn.ghost:hover { background: var(--surface-deeper); }
.btn.primary {
  background: var(--magenta);
}
.btn.primary:hover { background: #8a2d50; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--magenta);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 11px; font-weight: 600;
}

.content { padding: 28px 36px 54px; }

/* ===== Page intro ===== */
.page-intro { margin-bottom: 22px; }
.page-intro .eyebrow { display: none; }
.page-intro h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.5px; color: var(--ink); }
.page-intro .lede { margin-top: 8px; font-size: 13px; color: var(--ink-mute); line-height: 1.6; max-width: 720px; }

/* ===== Cards & grids ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  box-shadow: none;
}
.card.warm { background: var(--surface); }
.card.tinted { background: var(--purple-bg); border-color: transparent; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 16px; }
.card-eyebrow { display: none; }
.card-title { font-size: 15px; font-weight: 600; letter-spacing: -0.2px; color: var(--ink); }
.card-sub { font-size: 12px; color: var(--ink-mute); margin-top: 4px; }

.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(2, 1fr); }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-4 { grid-template-columns: repeat(4, 1fr); }
.g-21 { grid-template-columns: 2fr 1fr; }
.g-12 { grid-template-columns: 1fr 2fr; }
.mb { margin-bottom: 20px; }

/* ===== KPI ===== */
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  position: relative;
}
.kpi::before { display: none; }
.kpi .accent { display: none; }
.kpi .label {
  font-size: 12px;
  color: var(--ink-mute);
  font-weight: 500;
  margin-bottom: 8px;
}
.kpi .value {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -1.2px;
  color: var(--ink);
  line-height: 1.05;
}
.kpi .value .unit { font-size: inherit; font-weight: inherit; color: inherit; }
.kpi .sub, .kpi .delta {
  margin-top: 12px;
  font-size: 12px;
  color: var(--ink-mute);
  font-weight: 400;
  display: flex; align-items: center; gap: 6px;
}
.kpi .sub-text, .kpi .mute { color: var(--ink-mute); }
.kpi .icon {
  position: absolute; top: 20px; right: 20px;
  width: 32px; height: 32px;
  border-radius: 10px;
  background: var(--surface-deeper);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
}

.badge-up { color: var(--green); background: transparent; padding: 0; font-weight: 600; font-size: 12px; }
.badge-down { color: var(--red); background: transparent; padding: 0; font-weight: 600; font-size: 12px; }
.badge-warn { color: var(--amber); background: transparent; padding: 0; font-weight: 600; font-size: 12px; }

/* ===== Tags ===== */
.tag {
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 980px;
  font-weight: 500;
  background: var(--surface-deeper);
  color: var(--ink-soft);
  display: inline-block;
}
.tag-rose, .tag-purple, .tag-pink, .tag-magenta { background: var(--purple-bg); color: var(--magenta); font-weight: 600; }
.tag-warm { background: var(--surface-deeper); color: var(--ink-soft); }
.tag-amber { background: var(--amber-bg); color: var(--amber); font-weight: 600; }
.tag-red, .tag-clay { background: var(--red-bg); color: var(--red); font-weight: 600; }
.tag-sage, .tag-teal { background: var(--teal-bg); color: var(--teal); font-weight: 600; }
.tag-new { background: var(--purple); color: #fff; }

/* ===== Tables ===== */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  font-size: 11px; font-weight: 500;
  color: var(--ink-mute);
  padding: 0 12px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 14px 12px;
  font-size: 13px; color: var(--ink);
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-deeper); }
td.num { font-weight: 600; }
td.fw { font-weight: 500; }
.row-total td { background: var(--surface-deeper); font-weight: 700; }

/* ===== Inputs ===== */
.input-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px dashed var(--border);
}
.input-row:last-child { border-bottom: none; }
.input-row label { font-size: 13px; color: var(--ink-soft); }
.input {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px;
  font-size: 13px; color: var(--ink); font-weight: 500;
  text-align: right; width: 150px;
  font-variant-numeric: tabular-nums;
  outline: none;
}
.input:focus { border-color: var(--purple); }
.input-full { width: 100%; text-align: left; }
.select {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 11px;
  font-size: 13px; color: var(--ink-soft);
  outline: none;
}

/* ===== Progress bars ===== */
.bar-bg { height: 6px; background: var(--surface-deeper); border-radius: 3px; overflow: hidden; }
.bar { height: 100%; border-radius: 3px; background: var(--purple); transition: width 0.5s ease; }
.bar-rose, .bar-purple { background: var(--purple); }
.bar-sage, .bar-green { background: var(--green); }
.bar-amber { background: var(--amber); }
.bar-clay, .bar-red { background: var(--red); }

.runway-bar { height: 14px; background: var(--surface-deeper); border-radius: 7px; overflow: hidden; margin: 10px 0; }
.runway-fill { height: 100%; border-radius: 7px; background: linear-gradient(90deg, var(--green), var(--purple)); transition: width 0.6s; }

/* ===== Alerts ===== */
.alert {
  background: var(--surface-deeper);
  border: none;
  border-left: 0;
  padding: 14px 16px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.alert strong { color: var(--ink); font-weight: 600; font-size: 13px; }
.alert .small { color: var(--ink-mute); font-size: 12px; line-height: 1.4; }
.alert .icn {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--ink-mute);
  color: #fff;
  font-size: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.alert.danger { background: var(--red-bg); }
.alert.danger .icn { background: var(--red); }
.alert.warn { background: var(--amber-bg); }
.alert.warn .icn { background: var(--amber); }
.alert.info { background: var(--surface-deeper); }
.alert.info .icn { background: var(--ink-mute); }
.alert.success { background: var(--teal-bg); }
.alert.success .icn { background: var(--green); }

/* ===== Timeline ===== */
.timeline { display: flex; flex-direction: column; gap: 8px; }
.tl-row {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.tl-row.accent { border-color: var(--magenta); background: var(--purple-bg); }
.tl-date { text-align: center; min-width: 40px; }
.tl-date .d { font-size: 18px; font-weight: 700; color: var(--ink); line-height: 1; font-variant-numeric: tabular-nums; }
.tl-row.accent .tl-date .d { color: var(--magenta); }
.tl-date .m { font-size: 9px; color: var(--ink-mute); text-transform: uppercase; margin-top: 3px; font-weight: 600; }
.tl-sep { width: 1px; height: 30px; background: var(--border); }
.tl-body { flex: 1; }
.tl-title { font-size: 13px; font-weight: 600; color: var(--ink); }
.tl-desc { font-size: 11px; color: var(--ink-mute); margin-top: 2px; }
.tl-amount { margin-left: auto; text-align: right; }
.tl-amount .a { font-size: 14px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.tl-row.accent .tl-amount .a { color: var(--magenta); }
.tl-amount .b { font-size: 9px; padding: 2px 6px; border-radius: 4px; margin-top: 3px; display: inline-block; }

/* ===== Slider ===== */
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; background: var(--surface-deeper);
  border-radius: 2px; outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--magenta); border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15); cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--magenta); border: 2px solid #fff; cursor: pointer;
}

/* ===== Helpers ===== */
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.muted { color: var(--ink-mute); }
.small { font-size: 11px; }
.serif { font-family: var(--sans); font-weight: 700; font-variant-numeric: tabular-nums; }
.upper { text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.between { justify-content: space-between; }
.center { align-items: center; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; }
.text-rose { color: var(--magenta); font-weight: 600; }
.text-sage, .text-green { color: var(--green); font-weight: 600; }
.text-clay, .text-red { color: var(--red); font-weight: 600; }
.text-amber { color: var(--amber); font-weight: 600; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.dot-rose, .dot-purple { background: var(--purple); }
.dot-magenta, .dot-pink { background: var(--c-pink); }
.dot-sage, .dot-green { background: var(--c-green); }
.dot-amber { background: var(--c-yellow); }
.dot-clay, .dot-red { background: var(--red); }
.dot-ink { background: var(--ink); }
.dot-blue { background: var(--c-blue); }

/* Stats inline */
.stat-row { display: flex; gap: 28px; flex-wrap: wrap; }
.stat-row .item .lbl { font-size: 11px; color: var(--ink-mute); }
.stat-row .item .val { font-size: 22px; font-weight: 700; color: var(--ink); margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -0.3px; }

/* Legacy hide */
.ws-pill { display: none; }

/* ===== Mobile Responsive ===== */
@media (max-width: 1024px) {
  .g-4 { grid-template-columns: repeat(2, 1fr); }
  .g-21, .g-12 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  :root { --side-w: 0; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 200;
    width: 240px;
  }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .topbar { padding: 0 14px; height: 52px; }
  .tb-right { gap: 6px; }
  .tb-select { padding: 5px 10px; font-size: 11px; }
  .btn { padding: 6px 12px; font-size: 11px; }
  .avatar { width: 28px; height: 28px; font-size: 11px; }
  .content { padding: 16px 14px 40px; }

  /* 모든 그리드 동일 갭으로 일관성 */
  .g-4 { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .g-3, .g-2 { grid-template-columns: 1fr; gap: 12px; }
  .g-21, .g-12 { grid-template-columns: 1fr; gap: 12px; }

  /* 모든 카드 동일 폭 — 가로 오버플로 방지 */
  body { overflow-x: hidden; }
  .card, .kpi { width: 100%; max-width: 100%; box-sizing: border-box; }
  .tbl-wrap { max-width: 100%; }
  canvas { max-width: 100% !important; }

  .tb-title { font-size: 14px; }

  /* KPI 컴팩트 */
  .kpi { padding: 14px 14px 12px; border-radius: 12px; }
  .kpi .label { font-size: 11px; margin-bottom: 6px; }
  .kpi .value { font-size: 22px; letter-spacing: -0.8px; }
  .kpi .sub, .kpi .delta { font-size: 11px; margin-top: 6px; gap: 4px; }
  .kpi .icon { width: 26px; height: 26px; font-size: 13px; top: 14px; right: 14px; border-radius: 8px; }

  .card { padding: 16px; border-radius: 12px; }
  .card-title { font-size: 14px; }
  .card-sub { font-size: 11px; }

  .mb { margin-bottom: 14px; }
  .grid { gap: 12px; }

  /* 알람·테이블 컴팩트 */
  .alert { padding: 10px 12px; font-size: 12px; gap: 10px; }
  .alert .icn { width: 22px; height: 22px; font-size: 11px; }
  .alert strong { font-size: 12.5px; }
  .alert .small { font-size: 11px; }
  thead th { font-size: 10px; padding: 0 8px 10px; }
  tbody td { padding: 10px 8px; font-size: 12px; }

  /* Mobile menu button shown */
  .mobile-menu-btn { display: flex; }
}
@media (min-width: 769px) {
  .mobile-menu-btn { display: none; }
}
.mobile-menu-btn {
  background: transparent; border: none;
  font-size: 22px; padding: 0; cursor: pointer;
  color: var(--ink); display: none;
  width: 32px; height: 32px;
  align-items: center; justify-content: center;
  border-radius: 8px;
}
.mobile-menu-btn:active { background: var(--surface-deeper); }
.tb-brand-mobile {
  display: none; font-weight: 700; font-size: 16px;
  letter-spacing: 1.5px; color: var(--ink);
  flex: 1; text-align: left;
}
@media (max-width: 768px) {
  .mobile-menu-btn { display: inline-flex !important; }
  .tb-brand-mobile { display: block; }
  .tb-title { display: none; }
  .topbar { gap: 8px; }
}
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 150;
}
.sidebar-backdrop.open { display: block; }

/* ===== Data Input Modal ===== */
#__dataModal { display: none; }
#__dataModal.open { display: block; }
#__dataModal .dm-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 250;
  backdrop-filter: blur(4px);
}
#__dataModal .dm-box {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%);
  width: 90%; max-width: 480px;
  max-height: 88vh; overflow-y: auto;
  background: var(--surface);
  border-radius: 16px;
  z-index: 251;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
#__dataModal .dm-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
#__dataModal .dm-title { font-size: 17px; font-weight: 700; }
#__dataModal .dm-close {
  background: transparent; border: none; cursor: pointer;
  font-size: 18px; color: var(--ink-mute);
  width: 30px; height: 30px; border-radius: 8px;
}
#__dataModal .dm-close:hover { background: var(--surface-deeper); }
#__dataModal .dm-body { padding: 18px 22px; }
#__dataModal .dm-section {
  font-size: 10px; font-weight: 700; letter-spacing: 0.8px;
  text-transform: uppercase; color: var(--ink-mute);
  margin: 14px 0 6px;
}
#__dataModal .dm-section:first-child { margin-top: 0; }
#__dataModal .dm-foot {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 16px 22px; border-top: 1px solid var(--border);
}
#__dataModal .input { width: 160px; }

@media (max-width: 768px) {
  #__dataModal .dm-box { width: 94%; }
  #__dataModal .input { width: 130px; }
  /* 모바일에서 토프바 데이터입력 버튼 숨김 (사이드바 메뉴로 이동) */
  .topbar .btn:not(.ghost) { display: none; }
  /* 토프바 select도 모바일에선 숨김 */
  .tb-select { display: none; }
}

.tb-home{display:inline-flex;align-items:center;min-height:44px;white-space:nowrap;color:#783452;font-weight:650;margin-right:8px}
