/* ecoG 2.0 — eco.G 로고에서 온 색: 숲 초록(글자), 새잎 연두(잎), 제품의 흰색 */
:root {
  --ink: #17261B;
  --forest: #134226;
  --leaf-light: #88BC50;
  --ink-2: #4D6152;
  --ink-3: #7F9384;
  --paper: #F5F7F2;
  --panel: #FFFFFF;
  --line: #DCE5DA;
  --line-2: #EBF0E9;
  --brand: #1F7A45;
  --brand-soft: #E6F2E9;
  --leaf: #2F8F5B;
  --leaf-soft: #E4F3EA;
  --amber: #B97A0F;
  --amber-soft: #FBF1DE;
  --red: #B9432F;
  --red-soft: #FBE9E5;
  --radius-s: 6px;
  --radius-m: 10px;
  --font: 'Wanted Sans Variable', 'Wanted Sans', Pretendard, 'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, sans-serif;
  --side: 216px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  font-variant-numeric: tabular-nums;
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ── 뼈대 ─────────────────────────── */
.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; background: linear-gradient(to right, var(--forest) var(--side), transparent var(--side)); }
.side {
  background: var(--forest);
  color: #D3E3D4;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.side .brand { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 8px 24px; }
.side .brand img { height: 38px; max-width: 150px; object-fit: contain; }
.side .brand img.custom { background: #fff; border-radius: 6px; padding: 3px 6px; height: 34px; }
.side .menu-btn { display: none; background: none; border: 1px solid rgba(255,255,255,.25); color: #fff; border-radius: 6px; padding: 6px 10px; cursor: pointer; }
.side .menu-btn svg { display: block; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a {
  color: #D3E3D4;
  padding: 9px 12px;
  border-radius: var(--radius-s);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 500;
}
.side nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.side nav a[aria-current='page'] { background: rgba(136,188,80,.28); color: #fff; }
.side nav .sep { height: 1px; background: rgba(255,255,255,.1); margin: 10px 8px; }
.side .badge { background: var(--amber); color: #fff; font-size: 12px; border-radius: 10px; padding: 0 7px; font-weight: 600; }
.side .me { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid rgba(255,255,255,.1); font-size: 13px; }
.side .me b { color: #fff; font-weight: 600; display: block; }
.side .me .links { display: flex; gap: 12px; margin-top: 6px; }
.side .me button { background: none; border: 0; color: #A9C7AE; padding: 0; cursor: pointer; }
.side .me button:hover { color: #fff; }

.main { min-width: 0; padding: 26px 32px 48px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.head .crumbs { font-size: 13px; color: var(--ink-2); margin-bottom: 4px; }
.head .crumbs a { color: var(--ink-2); }

/* ── 공통 부품 ─────────────────────── */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m); }
.panel > header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 16px 18px 6px; }
.panel > header p { margin: 0; font-size: 13px; color: var(--ink-2); }
.panel .body { padding: 8px 18px 18px; }
.grid { display: grid; gap: 16px; }
.g-2-1 { grid-template-columns: 2fr 1fr; }
.g-1-1 { grid-template-columns: 1fr 1fr; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--panel);
  padding: 7px 13px; border-radius: var(--radius-s); cursor: pointer; font-weight: 500; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #186638; }
.btn.danger { color: var(--red); }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; background: var(--panel); }
.seg button { border: 0; background: none; padding: 6px 12px; cursor: pointer; border-right: 1px solid var(--line-2); white-space: nowrap; }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed='true'] { background: var(--forest); color: #fff; }

.period { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.period input[type=date] { border: 1px solid var(--line); border-radius: var(--radius-s); padding: 5px 8px; background: var(--panel); }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.field input, .field select, .field textarea, .input {
  border: 1px solid var(--line); border-radius: var(--radius-s); padding: 8px 10px; background: var(--panel); width: 100%;
}
.field .hint { font-size: 12px; color: var(--ink-3); }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }

table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-weight: 600; color: var(--ink-2); font-size: 13px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 9px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.t th.r, table.t td.r { text-align: right; }
table.t th.sort { cursor: pointer; user-select: none; }
table.t th.sort:hover { color: var(--ink); background: #F2F7F0; }
table.t th.sort .arr { display: inline-block; min-width: 1em; margin-left: 3px; font-size: 10px; color: var(--leaf); }
table.t th.sort[aria-sort="none"] .arr::after { content: '↕'; color: var(--line); font-size: 11px; }
table.t th.sort[aria-sort="none"]:hover .arr::after { color: var(--ink-2); }
table.t tbody tr.click { cursor: pointer; }
table.t tbody tr.click:hover td { background: #F2F7F0; }
table.t tbody tr.inactive td:not(:first-child):not(:last-child) { opacity: .55; }
table.t tfoot td { font-weight: 650; border-top: 1px solid var(--line); border-bottom: 0; }
.tablewrap { overflow-x: auto; }

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; padding: 1px 8px; border-radius: 10px; font-weight: 550; white-space: nowrap; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.on { color: var(--leaf); background: var(--leaf-soft); }
.pill.off { color: var(--amber); background: var(--amber-soft); }
.pill.never { color: var(--ink-3); background: var(--line-2); }
.pill.drop { color: var(--red); background: var(--red-soft); }
.up { color: var(--leaf); }
.down { color: var(--red); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { background: none; border: 0; padding: 9px 12px; cursor: pointer; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 550; }
.tabs button[aria-selected='true'] { color: var(--ink); border-bottom-color: var(--brand); }
.tabs button span { color: var(--ink-3); font-weight: 500; margin-left: 4px; }

.empty { padding: 40px 10px; text-align: center; color: var(--ink-2); }
.loading { padding: 40px; text-align: center; color: var(--ink-3); }
.err { background: var(--red-soft); color: var(--red); border-radius: var(--radius-s); padding: 8px 12px; font-size: 14px; }
.note { background: var(--brand-soft); border-radius: var(--radius-s); padding: 10px 12px; font-size: 14px; }

/* ── 대시보드 머리말: 문장이 곧 지표 ── */
.impact {
  background: var(--forest);
  color: #fff;
  border-radius: var(--radius-m);
  padding: 26px 28px 22px;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}
.impact::after {
  /* 물결 한 줄 — 유일한 장식 */
  content: '';
  position: absolute; left: 0; right: 0; bottom: 0; height: 28px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 240 28' preserveAspectRatio='none'%3E%3Cpath d='M0 14 Q30 4 60 14 T120 14 T180 14 T240 14 V28 H0z' fill='%2388BC50' fill-opacity='.35'/%3E%3C/svg%3E") repeat-x;
  background-size: 240px 28px;
}
.impact .lead { font-size: 17px; color: #C4D9C6; margin: 0 0 4px; }
.impact .big { font-size: clamp(30px, 4.2vw, 46px); font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; margin: 0; }
.impact .big em { font-style: normal; color: #A8D46F; }
.impact .facts { display: flex; flex-wrap: wrap; gap: 10px 36px; margin-top: 18px; position: relative; z-index: 1; }
.impact .fact b { display: block; font-size: 24px; font-weight: 650; }
.impact .fact span { font-size: 13px; color: #A9C2AB; }
.impact .fact .chg { font-size: 13px; margin-left: 6px; }
.impact .fact .chg.up { color: #B7E08A; }
.impact .fact .chg.down { color: #F4A898; }

.health { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.health a { display: block; padding: 12px; border-radius: var(--radius-s); border: 1px solid var(--line-2); color: inherit; }
.health a:hover { border-color: var(--line); text-decoration: none; background: #F7FAF5; }
.health b { font-size: 26px; display: block; font-weight: 650; }
.health span { font-size: 13px; color: var(--ink-2); }
.health .on b { color: var(--leaf); }
.health .off b { color: var(--amber); }
.health .un b { color: var(--brand); }
.bar { height: 8px; border-radius: 4px; background: var(--line-2); overflow: hidden; display: flex; margin: 14px 0 6px; }
.bar i { display: block; height: 100%; }

.chart { width: 100%; height: 280px; }
.chart.tall { height: 340px; }
.chart.short { height: 200px; }

.rank li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.rank { list-style: none; padding: 0; margin: 0; }
.rank .meter { grid-column: 1 / -1; height: 4px; background: var(--line-2); border-radius: 2px; overflow: hidden; }
.rank .meter i { display: block; height: 100%; background: var(--brand); }

/* ── 서랍(상세 패널) ─────────────── */
.drawer-bg { position: fixed; inset: 0; background: rgba(19,66,38,.28); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(620px, 100vw);
  background: var(--paper); z-index: 41; overflow-y: auto; box-shadow: -8px 0 24px rgba(19,66,38,.12);
  animation: slidein .18s ease-out;
}
.drawer > header { position: sticky; top: 0; background: var(--paper); padding: 18px 22px 12px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; z-index: 1; }
.drawer .content { padding: 18px 22px 40px; display: flex; flex-direction: column; gap: 14px; }
.close { background: none; border: 0; font-size: 22px; line-height: 1; cursor: pointer; color: var(--ink-2); padding: 2px 6px; }
@keyframes slidein { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }

.modal-bg { position: fixed; inset: 0; background: rgba(19,66,38,.35); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--panel); border-radius: var(--radius-m); width: min(460px, 100%); max-height: 90vh; overflow-y: auto; }
.modal > header { padding: 18px 20px 4px; display: flex; justify-content: space-between; }
.modal .content { padding: 12px 20px 4px; }
.modal footer { padding: 12px 20px 18px; display: flex; justify-content: flex-end; gap: 8px; }

.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; font-size: 14px; margin: 0; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; word-break: break-all; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--forest); color: #fff; padding: 10px 16px; border-radius: var(--radius-s); z-index: 60; font-size: 14px; }

/* 조직 트리 (+/- 펼치기) */
.tree { list-style: none; padding-left: 0; margin: 0; }
.tree ul { list-style: none; padding: 0; margin: 0; }
.tree .node { display: flex; align-items: center; gap: 6px; padding: 5px 8px 5px 4px; border-radius: var(--radius-s); cursor: pointer; min-height: 34px; }
.tree .node:hover { background: var(--brand-soft); }
.tree .node[aria-selected='true'] { background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--leaf-light); font-weight: 600; }
.tree .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree .node .cnt { margin-left: auto; font-size: 12.5px; color: var(--ink-3); padding-left: 8px; }
.tree .tw { flex: 0 0 18px; width: 18px; height: 18px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 3px; background: var(--panel); font-size: 13px; line-height: 1; color: var(--ink-2); cursor: pointer; padding: 0; }
.tree .tw:hover { border-color: var(--brand); color: var(--brand); }
.tree .tw.empty { border: 0; background: none; cursor: default; }
.tree .type { font-size: 11.5px; color: var(--ink-3); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; white-space: nowrap; }
.tree-tools { display: flex; gap: 6px; margin-bottom: 8px; }

/* 로그인 */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.15fr 1fr; background: var(--panel); }
.login .art {
  position: relative; overflow: hidden; color: #fff; padding: 48px;
  display: flex; flex-direction: column; justify-content: flex-end;
  background: var(--forest) url('/img/photo-garden.jpg') center 30% / cover no-repeat;
}
.login .art::before { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(19,66,38,0) 35%, rgba(19,66,38,.88) 78%); }
.login .art > * { position: relative; }
.login .art img { height: 44px; width: auto; margin-bottom: 18px; align-self: flex-start; }
.login .art h1 { font-size: 34px; line-height: 1.3; max-width: 17ch; margin: 0 0 10px; }
.login .art p { color: #DDEBDD; max-width: 36ch; font-size: 16px; margin: 0; }
.login .form { display: grid; place-items: center; padding: 32px; }
.login form { width: min(340px, 100%); }
.login form > img { height: 46px; margin-bottom: 28px; }

/* 대시보드 머리말 오른쪽 장비 사진 (넓은 화면만) */
.impact.with-photo { padding-right: 260px; min-height: 236px; }
.impact .photo {
  position: absolute; right: 0; top: 0; bottom: 0; width: 240px;
  background: url('/img/photo-device.jpg') center 35% / cover no-repeat;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 38%); mask-image: linear-gradient(90deg, transparent 0, #000 38%);
}

/* 사진 속 세척기 몸통(로고 아래)에 얹는 시계·날씨 */
.dash-clock {
  position: absolute; right: 26px; top: 96px; width: 150px; z-index: 1;
  text-align: center; color: #fff; line-height: 1.2;
  background: rgba(19, 66, 38, .82); padding: 8px 8px 7px; border-radius: 10px;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.dash-clock time b { display: block; font-size: 22px; font-weight: 650; letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.dash-clock time small { display: block; color: #C4D9C6; font-size: 11px; margin-top: 1px; }
.dash-clock .wx { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 6px; padding-top: 6px; border-top: 1px solid rgba(196, 217, 198, .28); }
.dash-clock .wx[hidden] { display: none; }
.dash-clock .wx-icon { width: 26px; height: 26px; flex: none; }
.dash-clock .wx b { font-size: 19px; font-weight: 650; }
.dash-clock .wx span { font-size: 11px; color: #DDEBDD; text-align: left; line-height: 1.25; }
.dash-clock .wx small { display: block; color: #A9C2AB; font-size: 10px; }

@media (max-width: 1100px) {
  .impact.with-photo { padding-right: 28px; }
  .impact .photo { display: none; }
  /* 사진이 빠지면 머리말 오른쪽 위에 배경 없이 */
  .dash-clock { top: 18px; right: 20px; width: auto; background: none; padding: 0; text-align: right; -webkit-backdrop-filter: none; backdrop-filter: none; }
  .dash-clock .wx { justify-content: flex-end; border-top: 0; padding-top: 0; margin-top: 4px; }
}
@media (max-width: 600px) {
  .dash-clock { position: static; display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; text-align: left; }
  .dash-clock time b { font-size: 18px; }
  .dash-clock .wx { margin-top: 0; }
}
@media (max-width: 960px) {
  .g-2-1, .g-1-1, .g-tree { grid-template-columns: 1fr !important; }
}
/* 태블릿·휴대폰: 왼쪽 메뉴 → 위쪽 막대 + 펼치는 메뉴 */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; background: none; }
  .side { position: sticky; top: 0; z-index: 30; height: auto; padding: 10px 14px; flex-direction: column; }
  .side .brand { padding: 0; }
  .side .brand img { height: 30px; }
  .side .menu-btn { display: inline-flex; align-items: center; gap: 6px; }
  .side nav, .side .me { display: none; }
  .side.open nav { display: flex; padding-top: 10px; }
  .side.open .me { display: block; margin-top: 8px; }
  .main { padding: 18px 14px 40px; }
  .head { align-items: stretch; flex-direction: column; }
  .head h1 { font-size: 20px; }
  .period { width: 100%; }
  .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .tablewrap table.t { min-width: 680px; }
  .impact { padding: 20px 18px 30px; }
  .impact .facts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
  .impact .fact b { font-size: 20px; }
  .health { grid-template-columns: repeat(3, 1fr); }
  .chart { height: 230px; }
  .chart.tall { height: 300px; }
  .row { flex-direction: column; gap: 0; }
  .modal-bg { align-items: end; padding: 0; }
  .modal { width: 100%; border-radius: 12px 12px 0 0; max-height: 92vh; }
  .login { grid-template-columns: 1fr; }
  .login .art { min-height: 260px; padding: 24px; }
  .login .art h1 { font-size: 24px; }
  .login .form { padding: 28px 20px 40px; place-items: start center; }
}
@media (max-width: 420px) {
  .period input[type=date] { flex: 1; min-width: 0; }
  .health b { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
