@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+KR:wght@400;500;600;700&family=JetBrains+Mono:wght@400;600&display=swap");

:root {
  color-scheme: dark;
  --bg: #060c1d;
  --bg-2: #0a1430;
  --panel: #0f1a33;
  --panel-2: #13213f;
  --line: #1f3260;
  --line-2: #2a4278;
  --text: #e6edf9;
  --text-2: #9fb0d0;
  --muted: #6c7fa6;
  --accent: #38d6ff;
  --accent-dim: rgba(56, 214, 255, 0.14);
  --danger: #ff5d6c;
  --s-HTH00: #3987e5; --s-HTH10: #d95926; --s-HTH20: #199e70;
  --s-HTH30: #c98500; --s-HTH50: #d55181; --s-HTHEC: #9085e9; --s-기타: #6c7fa6;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --sans: "IBM Plex Sans KR", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background:
    linear-gradient(rgba(56, 214, 255, 0.035) 1px, transparent 1px) 0 0 / 32px 32px,
    linear-gradient(90deg, rgba(56, 214, 255, 0.035) 1px, transparent 1px) 0 0 / 32px 32px,
    radial-gradient(1200px 600px at 80% -10%, #12244d 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--sans);
}
button, input, select { font: inherit; color: inherit; }
.mono { font-family: var(--mono); }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh;
  background: linear-gradient(180deg, var(--bg-2), var(--bg));
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 20px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.brand-mark {
  width: 34px; height: 34px; display: grid; place-items: center;
  border: 1px solid var(--accent); color: var(--accent); font: 600 16px var(--mono);
  clip-path: polygon(0 0, 78% 0, 100% 22%, 100% 100%, 22% 100%, 0 78%);
  background: var(--accent-dim);
}
.brand b { display: block; font-size: 15px; letter-spacing: .02em; }
.brand small { color: var(--muted); font: 10px var(--mono); letter-spacing: .14em; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav button {
  display: flex; align-items: center; gap: 10px; text-align: left;
  background: none; border: 1px solid transparent; border-radius: 6px;
  padding: 10px 12px; color: var(--text-2); cursor: pointer;
}
.nav button:hover:not(:disabled) { background: var(--panel); color: var(--text); }
.nav button.on { background: var(--accent-dim); border-color: rgba(56, 214, 255, .35); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.nav button:disabled { opacity: .45; cursor: default; }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav .tag { margin-left: auto; font: 10px var(--mono); color: var(--muted); border: 1px solid var(--line); padding: 0 5px; border-radius: 3px; }
.side-foot { margin-top: auto; font: 11px/1.7 var(--mono); color: var(--muted); padding: 12px 8px 0; border-top: 1px solid var(--line); }
.side-foot .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #2bd98a; box-shadow: 0 0 8px #2bd98a; margin-right: 6px; }
.side-foot a { color: var(--text-2); }

.main { padding: 24px 28px 48px; min-width: 0; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.head h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.head .eyebrow { font: 11px var(--mono); color: var(--accent); letter-spacing: .2em; text-transform: uppercase; margin-bottom: 4px; }
.head .sub { color: var(--muted); font-size: 12px; }

/* ---------- panels ---------- */
.panel {
  position: relative; background: linear-gradient(180deg, var(--panel), #0c1630);
  border: 1px solid var(--line); border-radius: 8px; padding: 16px 18px;
}
.panel::before, .panel::after {
  content: ""; position: absolute; width: 12px; height: 12px; border: 1px solid var(--accent); opacity: .7; pointer-events: none;
}
.panel::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; border-top-left-radius: 8px; }
.panel::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; border-bottom-right-radius: 8px; }
.panel h2 { margin: 0 0 12px; font-size: 13px; font-weight: 600; color: var(--text-2); display: flex; align-items: center; gap: 8px; }
.panel h2::before { content: ""; width: 6px; height: 6px; background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.panel h2 .right { margin-left: auto; }

/* ---------- filter bar ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin-bottom: 16px; }
.field { display: flex; align-items: center; gap: 6px; }
.field label { font: 11px var(--mono); color: var(--muted); letter-spacing: .08em; }
.inp {
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 5px;
  padding: 6px 9px; height: 32px; min-width: 0;
}
.inp:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-dim); }
input[type=date].inp { font-family: var(--mono); font-size: 12px; }
input[type=date]::-webkit-calendar-picker-indicator { filter: invert(.8); }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 5px; overflow: hidden; }
.seg button { background: var(--bg-2); border: 0; padding: 0 10px; height: 30px; color: var(--text-2); cursor: pointer; font-size: 12px; }
.seg button + button { border-left: 1px solid var(--line-2); }
.seg button.on { background: var(--accent-dim); color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px;
  border: 1px solid var(--line-2); border-radius: 15px; background: var(--bg-2); color: var(--text-2);
  cursor: pointer; font-size: 12px;
}
.chip i { width: 8px; height: 8px; border-radius: 2px; background: var(--c); }
.chip.on { border-color: var(--c); color: var(--text); background: color-mix(in srgb, var(--c) 16%, var(--bg-2)); }
.btn {
  height: 32px; padding: 0 14px; border-radius: 5px; border: 1px solid var(--accent);
  background: var(--accent-dim); color: var(--accent); cursor: pointer; font-weight: 500;
}
.btn:hover { background: rgba(56, 214, 255, .24); }
.btn.ghost { border-color: var(--line-2); background: none; color: var(--text-2); }
.search { flex: 1 1 220px; display: flex; }
.search .inp { width: 100%; }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.kpi .lbl { font: 11px var(--mono); color: var(--muted); letter-spacing: .1em; }
.kpi .val { font: 600 28px/1.2 var(--mono); margin-top: 6px; }
.kpi .val small { font-size: 13px; color: var(--text-2); font-weight: 400; margin-left: 4px; }
.kpi .hint { font-size: 12px; color: var(--text-2); margin-top: 2px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.chart-box { position: relative; height: 280px; }
.chart-box.tall { height: 340px; }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; font: 500 11px var(--mono); color: var(--muted); letter-spacing: .06em;
  padding: 8px 10px; border-bottom: 1px solid var(--line-2); white-space: nowrap; background: var(--panel);
  position: sticky; top: 0;
}
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.num, th.num { text-align: right; font-family: var(--mono); }
tbody tr { cursor: pointer; }
tbody tr:hover td { background: rgba(56, 214, 255, .05); }
.logs { table-layout: fixed; }
.logs td { word-break: break-word; white-space: pre-line; line-height: 1.45; }
.logs .sub { display: block; color: var(--muted); font-size: 11.5px; }
.logs .c-dt { white-space: nowrap; font-size: 12px; }
.logs .c-eq b { font-size: 12px; color: var(--text); }
select.inp { padding-right: 6px; }
select.inp option { background: var(--bg-2); }
.sel-op { max-width: 280px; }

.trend-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.trend-bar .legend { margin: 0; }
.zoom { display: flex; align-items: center; gap: 10px; font-size: 11.5px; color: var(--muted); }
.zoom .seg button { min-width: 34px; }
.pan { width: 100%; margin: 10px 0 0; accent-color: var(--accent); }
.pan:disabled { opacity: .3; }
.panel h2 .tabs { margin-left: auto; flex-wrap: wrap; }
.panel h2 .tabs button { font-weight: 400; }
.pill { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-size: 12px; }
.pill i { width: 8px; height: 8px; border-radius: 2px; background: var(--c); }
.down-hi { color: var(--danger); }
.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; margin-top: 12px; font: 12px var(--mono); color: var(--text-2); }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(3, 7, 18, .7); backdrop-filter: blur(3px); display: none; place-items: center; padding: 16px; z-index: 20; }
.modal.open { display: grid; }
.modal .panel { width: min(720px, 100%); max-height: 86vh; overflow: auto; }
.dl { display: grid; grid-template-columns: 96px 1fr; gap: 8px 14px; margin: 0; }
.dl dt { font: 11px var(--mono); color: var(--muted); padding-top: 2px; }
.dl dd { margin: 0; white-space: pre-wrap; word-break: break-word; }
.close { position: absolute; top: 10px; right: 12px; background: none; border: 0; color: var(--text-2); font-size: 20px; cursor: pointer; }

/* chart tooltip */
.tip {
  position: fixed; pointer-events: none; z-index: 30; display: none;
  background: #0b1530; border: 1px solid var(--line-2); border-radius: 6px; padding: 8px 10px; font-size: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
}

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--text-2); margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; background: var(--c); }

.loading { opacity: .5; transition: opacity .2s; }

/* ---------- mobile ---------- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side {
    position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; z-index: 10;
    flex-direction: row; padding: 6px; border-right: 0; border-top: 1px solid var(--line);
  }
  .brand, .side-foot { display: none; }
  .nav { flex-direction: row; width: 100%; }
  .nav button { flex: 1; flex-direction: column; gap: 2px; font-size: 11px; padding: 6px; }
  .nav button.on { box-shadow: inset 0 2px 0 var(--accent); }
  .nav .tag { display: none; }
  .main { padding: 16px 16px 90px; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .kpi .val { font-size: 22px; }
  .sel-op { max-width: 100%; }
  /* 작업일지: 표 → 카드 */
  .logs colgroup, .logs thead { display: none; }
  .logs, .logs tbody, .logs tr, .logs td { display: block; width: auto; }
  .logs tr { border: 1px solid var(--line); border-radius: 6px; margin-bottom: 10px; padding: 6px 4px; }
  .logs td { border: 0; padding: 4px 8px; display: grid; grid-template-columns: 64px 1fr; gap: 8px; text-align: left; }
  .logs td::before { content: attr(data-k); font: 11px var(--mono); color: var(--muted); padding-top: 2px; }
  .logs td.empty { display: block; }
  .logs td.empty::before { content: none; }
}

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .panel { width: min(380px, 100%); padding: 28px; }
.login h1 { font-size: 18px; margin: 14px 0 4px; }
.login p { color: var(--muted); font-size: 12px; margin: 0 0 20px; }
.login .inp { width: 100%; height: 40px; margin-bottom: 12px; }
.login .btn { width: 100%; height: 40px; }
.login .err { color: var(--danger); font-size: 12px; min-height: 18px; margin-top: 8px; }
