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

/* hidden 속성이 .modal-overlay 의 display:flex 에 밀리지 않도록 */
[hidden] { display: none !important; }

:root {
  --bg: #0a0d12;
  --bg-panel: #10141c;
  --bg-card: #131822;
  --bg-hover: #1a2029;
  --line: #1e2530;
  --text: #e6ebf2;
  --text-dim: #7c8798;
  --accent: #3ddc84;
  --danger: #ff5c6c;
  --mono: 'JetBrains Mono', 'SF Mono', monospace;
  --sans: 'Inter', -apple-system, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

.app { display: flex; flex-direction: column; height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-panel);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--text-dim);
  transition: background 0.2s, box-shadow 0.2s;
}
.brand-dot.on { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.brand-dot.off { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.brand h1 {
  margin: 0; font-family: var(--mono); font-size: 15px; font-weight: 700;
  letter-spacing: 0.1em;
}
.brand h1 span { color: var(--accent); }
.status-text { font-family: var(--mono); font-size: 12px; color: var(--text-dim); text-align: right; max-width: 620px; }

.body { flex: 1; display: flex; min-height: 0; }

.sidebar {
  width: 260px;
  border-right: 1px solid var(--line);
  background: var(--bg-panel);
  display: flex;
  flex-direction: column;
  padding: 14px;
  overflow-y: auto;
}
.sidebar-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-dim); margin-bottom: 10px;
}
.device-list { display: flex; flex-direction: column; gap: 6px; }
.device-item {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.device-item:hover { border-color: var(--accent); }
.device-item.active { border-color: var(--accent); background: var(--bg-hover); }
.device-name { font-size: 13px; font-weight: 600; }
.device-ip { font-family: var(--mono); font-size: 11px; color: var(--text-dim); }
.device-count { font-family: var(--mono); font-size: 11px; color: var(--accent); margin-top: 2px; }
.device-edit { font-size: 10px; color: var(--text-dim); text-decoration: underline; margin-top: 4px; display: inline-block; }

.filter-clear {
  margin-top: 12px;
  background: none;
  border: 1px solid var(--line);
  color: var(--text-dim);
  border-radius: 6px;
  padding: 8px;
  font-size: 12px;
  cursor: pointer;
}
.filter-clear:hover { color: var(--text); border-color: var(--accent); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.toolbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid var(--line);
}
.search-input {
  flex: 1; background: var(--bg-card); border: 1px solid var(--line);
  color: var(--text); border-radius: 6px; padding: 8px 12px; font-size: 13px;
}
.count-label { font-family: var(--mono); font-size: 12px; color: var(--text-dim); }

.table-wrap { flex: 1; overflow-y: auto; }
.log-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.log-table thead th {
  position: sticky; top: 0;
  background: var(--bg-panel);
  text-align: left;
  padding: 10px 20px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--line);
}
.log-table td { padding: 8px 20px; border-bottom: 1px solid var(--line); }
.log-table tr:hover td { background: var(--bg-hover); }
.cell-time { font-family: var(--mono); color: var(--text-dim); white-space: nowrap; }
.cell-domain { font-family: var(--mono); }
.cell-type { font-family: var(--mono); color: var(--text-dim); font-size: 11px; }
.threat-badge {
  display: inline-block; margin-right: 6px; padding: 0 5px; border-radius: 3px;
  font-family: sans-serif; font-size: 10px; font-weight: 700; letter-spacing: 0.03em;
  color: #e0a060; background: rgba(224, 160, 96, 0.14); border: 1px solid rgba(224, 160, 96, 0.4);
  cursor: help;
}

.empty-state { color: var(--text-dim); font-size: 12px; padding: 12px 4px; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
}
.modal {
  background: var(--bg-panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 20px; width: 320px;
}
.modal h3 { margin: 0 0 6px; font-size: 15px; }
.modal-ip { font-family: var(--mono); font-size: 12px; color: var(--text-dim); margin: 0 0 12px; }
.modal input {
  width: 100%; background: var(--bg-card); border: 1px solid var(--line);
  color: var(--text); border-radius: 6px; padding: 8px 10px; font-size: 13px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.btn-primary {
  background: var(--accent); color: #06110b; border: none;
  font-weight: 700; font-size: 13px; padding: 8px 16px; border-radius: 6px; cursor: pointer;
}
.btn-ghost {
  background: none; border: 1px solid var(--line); color: var(--text-dim);
  font-size: 13px; padding: 8px 16px; border-radius: 6px; cursor: pointer;
}

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

.status-warn {
  margin-left: 14px; padding: 4px 10px; border-radius: 6px;
  background: rgba(220, 120, 40, 0.15); border: 1px solid rgba(220, 120, 40, 0.5);
  color: #e0a060; font-size: 12px;
}

.redirect-banner {
  display: flex; align-items: center; gap: 10px; margin-left: 14px;
  padding: 4px 10px; border-radius: 6px;
  background: rgba(220, 120, 40, 0.15); border: 1px solid rgba(220, 120, 40, 0.5);
  color: #e0a060; font-size: 12px;
}
.redirect-banner button {
  font-family: inherit; font-size: 12px; font-weight: 600; padding: 3px 10px;
  border-radius: 5px; border: 1px solid rgba(220, 120, 40, 0.7);
  background: rgba(220, 120, 40, 0.25); color: #f0c090; cursor: pointer;
}
.redirect-banner button:hover { background: rgba(220, 120, 40, 0.4); }
.redirect-banner button:disabled { opacity: 0.6; cursor: default; }

/* --- 요금제 배지 / 구독 --- */
.topbar-right { display: flex; align-items: center; gap: 12px; justify-content: flex-end; }

.plan-badge {
  margin-left: 12px; padding: 3px 10px; border-radius: 999px;
  background: none; border: 1px solid var(--line); color: var(--text-dim);
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  cursor: pointer; font-family: inherit;
}
.plan-badge:hover { color: var(--text); border-color: var(--accent); }
.plan-badge.pro { color: var(--accent); border-color: var(--accent); }

.export-group { display: flex; gap: 6px; }
.btn-small { padding: 5px 10px; font-size: 11px; }
.btn-ghost.locked { opacity: 0.55; }

.history-note {
  padding: 8px 20px; font-size: 12px; color: var(--text-dim);
  border-bottom: 1px solid var(--line); background: rgba(255,255,255,0.02);
}

/* 이 컴퓨터 자신의 질의만 잡히고 있을 때. 오류가 아니라 "다음 할 일" 안내라
   빨간색을 쓰지 않는다. */
.setup-hint {
  padding: 10px 20px; font-size: 12px; line-height: 1.5; color: var(--text);
  border-bottom: 1px solid var(--line);
  background: rgba(90, 170, 255, 0.10);
  border-left: 3px solid rgba(90, 170, 255, 0.55);
}

.unrouted-block { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.unrouted-list { display: flex; flex-direction: column; gap: 6px; }
.unrouted-item {
  padding: 6px 8px; border-radius: 6px;
  border: 1px dashed var(--line); opacity: 0.75;
}
.unrouted-item .device-ip { font-family: var(--mono); font-size: 12px; }
.unrouted-item .device-count { font-size: 11px; color: var(--text-dim); }
.unrouted-note { margin-top: 8px; font-size: 11px; color: var(--text-dim); line-height: 1.45; }

.device-locked {
  margin-top: 10px; width: 100%; text-align: left;
  background: none; border: 1px dashed var(--line); border-radius: 6px;
  color: var(--text-dim); font-size: 12px; padding: 10px; cursor: pointer;
  font-family: inherit;
}
.device-locked:hover { color: var(--text); border-color: var(--accent); }

.modal-wide { width: 520px; }
.plan-current { color: var(--text-dim); font-size: 12px; margin: 0 0 14px; }

.plan-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.plan-col { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.plan-col-pro { border-color: var(--accent); }
.plan-col-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.plan-price { color: var(--accent); font-weight: 500; text-transform: none; letter-spacing: 0; }
.plan-list { list-style: none; margin: 0; padding: 0; }
.plan-list li {
  font-size: 12px; color: var(--text-dim); padding: 3px 0 3px 14px; position: relative;
}
.plan-list li::before { content: "·"; position: absolute; left: 4px; }

.plan-license { margin-bottom: 12px; }
.plan-label {
  display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-dim); margin-bottom: 6px;
}
.plan-license input { font-family: var(--mono); font-size: 12px; }

.plan-error {
  color: #e0a060; font-size: 12px; margin: 0 0 12px;
  padding: 8px 10px; border-radius: 6px;
  background: rgba(220, 120, 40, 0.12); border: 1px solid rgba(220, 120, 40, 0.4);
}

.modal-actions-split { display: flex; justify-content: space-between; align-items: center; }
.modal-actions-right { display: flex; gap: 8px; }

.update-block {
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line);
}
.update-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-dim); margin-bottom: 8px;
}
.update-note {
  font-size: 11px; color: var(--text-dim); margin: 6px 0 10px; line-height: 1.5;
}
.update-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.update-status { font-size: 11px; color: var(--text-dim); }
.update-block input:disabled + span { opacity: 0.55; }

.plan-legal {
  font-size: 11px; color: var(--text-dim); margin: 14px 0 0; text-align: center;
}
.plan-legal a { color: inherit; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  max-width: 70vw; padding: 10px 16px; border-radius: 8px;
  background: var(--bg-panel); border: 1px solid var(--line);
  color: var(--text); font-size: 12px; z-index: 20;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
}
.toast.error { border-color: rgba(220, 120, 40, 0.6); color: #e0a060; }

/* --- 알림 룰 --- */
.modal-tall { max-height: 86vh; overflow-y: auto; }
.modal-sub { color: var(--text-dim); font-size: 12px; margin: 0 0 14px; }

.rules-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.rule-item {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
}
.rule-item.disabled { opacity: 0.5; }
.rule-main { flex: 1; min-width: 0; }
.rule-name { font-size: 13px; font-weight: 600; }
.rule-cond { font-size: 11px; color: var(--text-dim); font-family: var(--mono); margin-top: 2px; }
.rule-tags { display: flex; gap: 5px; margin-top: 5px; }
.rule-tag {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em;
  border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; color: var(--text-dim);
}
.rule-actions { display: flex; gap: 6px; flex-shrink: 0; }

.rule-form {
  border: 1px solid var(--accent); border-radius: 8px;
  padding: 14px; margin-bottom: 12px;
}
.field-row { display: flex; gap: 10px; margin-bottom: 10px; }
.field-row-checks { align-items: center; gap: 18px; }
.field { flex: 1; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-narrow { flex: 0 0 140px; }
.field > span {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim);
}
.field input, .field select {
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  color: var(--text); padding: 7px 9px; font-size: 12px; font-family: inherit; width: 100%;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); }
.field-help { font-size: 11px; color: var(--text-dim); margin: -4px 0 10px; }

.check { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-dim); cursor: pointer; }
.check input { accent-color: var(--accent); }

.btn-block { width: 100%; margin-bottom: 14px; }

.smtp-block {
  border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin-bottom: 12px;
}
.smtp-block summary {
  cursor: pointer; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim);
}
.smtp-block[open] summary { margin-bottom: 12px; color: var(--text); }

/* 체험 만료 예고. 7일 전부터 뜨고, 마지막 3일은 눈에 띄게 바뀐다. */
.trial-note {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px; font-size: 12px; line-height: 1.5;
  background: rgba(255, 179, 71, 0.1);
  border-bottom: 1px solid rgba(255, 179, 71, 0.35);
}
.trial-note span { flex: 1; }
.trial-note button {
  background: rgba(255, 179, 71, 0.25); border: 0; border-radius: 5px;
  color: inherit; padding: 5px 10px; font-size: 12px; cursor: pointer;
}
.trial-note button:hover { background: rgba(255, 179, 71, 0.4); }
.trial-note.urgent {
  background: rgba(220, 90, 90, 0.12); border-bottom-color: rgba(220, 90, 90, 0.45);
}
.trial-note.urgent button { background: rgba(220, 90, 90, 0.28); }
.trial-note.urgent button:hover { background: rgba(220, 90, 90, 0.42); }

.hint { color: var(--text-dim); font-size: 12px; margin: 4px 0 8px; }
.hint.error { color: var(--danger); }
.hint.ok { color: var(--accent); }
