/*
 * StaysHere admin console.
 * Direction: industrial-utilitarian, the feel of a well-labelled control panel.
 * Warm paper plane, hairline rules, tight corners, monospace for anything a
 * machine produced (versions, hosts, ids). One accent (signal green) for the
 * things an operator acts on; colour otherwise belongs to the data.
 * System fonts only: the console makes no request to any other server.
 */

:root {
  color-scheme: light;
  --plane: #f4f3ee;
  --surface: #fcfcfb;
  --ink: #0f1318;
  --ink-2: #52514e;
  --muted: #898781;
  --line: #e1e0d9;
  --line-strong: #c3c2b7;
  --wash: rgba(15, 19, 24, 0.045);
  --accent: #1a6e45;
  --accent-ink: #ffffff;
  --danger: #b3261e;
  --rail: #14181d;
  --rail-ink: #e9ebee;
  --rail-muted: #8a919c;
  --rail-line: #262b33;
  --series-1: #2a78d6; /* 차단 */
  --series-2: #eb6834; /* 가림 */
  --series-3: #1baf7a; /* 경고 */
  --bar: #6f6e69;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --plane: #0d0d0d;
    --surface: #1a1a19;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --line: #2c2c2a;
    --line-strong: #383835;
    --wash: rgba(255, 255, 255, 0.06);
    --accent: #5fce98;
    --accent-ink: #0d1a13;
    --danger: #ff9b91;
    --rail: #111312;
    --rail-line: #232624;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --bar: #a3a29b;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background-color: var(--plane);
  /* A faint drafting grid on the plane. */
  background-image: radial-gradient(var(--line) 1px, transparent 1px);
  background-size: 20px 20px;
  color: var(--ink);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

/* ── Shell ─────────────────────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: 216px minmax(0, 1fr); min-height: 100vh; }
.rail { background: var(--rail); color: var(--rail-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px 18px; border-bottom: 1px solid var(--rail-line); }
.brand img { width: 30px; height: 30px; border-radius: 7px; }
.brand strong { display: block; font-size: 15px; letter-spacing: 0.01em; }
.brand span { display: block; font: 10.5px/1.3 var(--mono); color: var(--rail-muted); letter-spacing: 0.08em; text-transform: uppercase; }
.org { padding: 14px 18px; border-bottom: 1px solid var(--rail-line); display: grid; gap: 6px; }
.org span { font: 10.5px/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--rail-muted); }
.org strong { font-size: 14px; overflow-wrap: anywhere; }
.org select { width: 100%; background: var(--rail); color: var(--rail-ink); border: 1px solid var(--rail-line); border-radius: 5px; padding: 6px 8px; font-size: 13px; }
.nav { padding: 12px 10px; display: grid; gap: 2px; }
.nav a {
  display: flex; align-items: baseline; gap: 12px; padding: 9px 10px; border-radius: 5px;
  color: var(--rail-muted); text-decoration: none; font-weight: 600; border-left: 2px solid transparent;
}
.nav a i { font: 10.5px var(--mono); font-style: normal; opacity: 0.7; }
.nav a:hover { color: var(--rail-ink); background: rgba(255, 255, 255, 0.04); }
.nav a[aria-current="page"] { color: var(--rail-ink); background: rgba(255, 255, 255, 0.07); border-left-color: #5fce98; }
.rail-foot { margin-top: auto; padding: 14px 18px 18px; border-top: 1px solid var(--rail-line); font-size: 12px; color: var(--rail-muted); display: grid; gap: 10px; }
.rail-foot .server { font: 11px/1.4 var(--mono); overflow-wrap: anywhere; }
.rail-foot button { justify-self: start; background: none; border: 1px solid var(--rail-line); color: var(--rail-ink); border-radius: 5px; padding: 5px 10px; cursor: pointer; }
.rail-foot button:hover { background: rgba(255, 255, 255, 0.06); }
/* The language switch: here and on the login screen. */
select.language { justify-self: start; width: auto; padding: 5px 8px; border-radius: 5px; font-size: 12px; cursor: pointer; }
.rail-foot select.language { background: var(--rail); color: var(--rail-ink); border: 1px solid var(--rail-line); }
.login select.language { justify-self: end; background: transparent; border: 1px solid var(--line); color: var(--ink-2); }

main { padding: 28px 32px 56px; max-width: 1180px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head h1 { font-size: 22px; letter-spacing: -0.01em; }
.page-head p { color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.tag { font: 10.5px/1 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); display: block; margin-bottom: 8px; }

/* Views arrive in sequence: one deliberate moment of motion. */
.view > * { animation: rise 0.36s ease-out both; }
.view > *:nth-child(2) { animation-delay: 0.04s; }
.view > *:nth-child(3) { animation-delay: 0.08s; }
.view > *:nth-child(4) { animation-delay: 0.12s; }
.view > *:nth-child(n + 5) { animation-delay: 0.16s; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .view > * { animation: none; } }
.stale { opacity: 0.55; transition: opacity 0.15s ease-in-out; }

/* ── Building blocks ───────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 18px 20px; }
.card + .card, .grid + .card, .card + .grid, .filters + .grid { margin-top: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { font-size: 14px; }
.card-head .sub { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 8px; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid .card { margin-top: 0; }
.hint { font-size: 12.5px; color: var(--ink-2); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.empty { padding: 28px 0; text-align: center; color: var(--muted); font-size: 13px; }
.error { color: var(--danger); font-size: 13px; }

button.btn, a.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  border-radius: 5px; padding: 6px 12px; font-weight: 600; font-size: 13px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--wash); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: 0.45; cursor: default; filter: none; }
.btn.small { padding: 3px 9px; font-size: 12px; }
:is(button, a, input, select, textarea, summary, [tabindex]):focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; }

input[type="text"], input[type="password"], input[type="email"], select, textarea {
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 5px; padding: 6px 9px; min-width: 0;
}
textarea { width: 100%; resize: vertical; font-family: var(--mono); font-size: 12.5px; }
label.field { display: grid; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.check { display: flex; gap: 10px; align-items: flex-start; }
.check input { margin-top: 3px; accent-color: var(--accent); }

.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 5px; overflow: hidden; background: var(--surface); }
.segmented button { border: 0; background: none; padding: 5px 12px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.segmented button + button { border-left: 1px solid var(--line-strong); }
.segmented button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.filters select { font-size: 12.5px; padding: 5px 8px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font: 10.5px/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 500; padding: 0 10px 8px 0; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
td { padding: 9px 10px 9px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; padding-right: 0; padding-left: 10px; }
/* A right-aligned number ends where the next column's text begins; without this the two read as one word. */
th.num + th:not(.num), td.num + td:not(.num) { padding-left: 20px; }
td.actions { text-align: right; white-space: nowrap; padding-right: 0; }
td.actions .btn + .btn { margin-left: 6px; }
.table-wrap { overflow-x: auto; }

/* Identity is carried by a mark beside the text, never by colouring the text. */
.key { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 7px; vertical-align: baseline; }
.key.s1 { background: var(--series-1); }
.key.s2 { background: var(--series-2); }
.key.s3 { background: var(--series-3); }
.led { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 7px; background: var(--muted); }
.led.on { background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.led.off { background: var(--danger); }
.pill { display: inline-block; font: 10.5px/1 var(--mono); letter-spacing: 0.04em; border: 1px solid var(--line-strong); border-radius: 3px; padding: 3px 5px; color: var(--ink-2); }

/* ── Activity ──────────────────────────────────────────────────────────── */
.tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.tile { padding: 16px 20px; border-left: 1px solid var(--line); min-width: 0; }
.tile:first-child { border-left: 0; }
.tile .label { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.tile .value { font-size: 30px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.15; margin-top: 4px; }
.tile .note { font-size: 11.5px; color: var(--muted); }

.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--ink-2); }
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis-line { stroke: var(--line-strong); stroke-width: 1; }
.chart text { fill: var(--muted); font: 11px var(--sans); font-variant-numeric: tabular-nums; }
.chart .seg { pointer-events: none; }
.chart .seg.s1 { fill: var(--series-1); }
.chart .seg.s2 { fill: var(--series-2); }
.chart .seg.s3 { fill: var(--series-3); }
.chart .hit { fill: transparent; outline: none; }
.chart .hit:hover, .chart .hit:focus-visible { fill: var(--wash); }
.tooltip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 148px; padding: 9px 11px; border-radius: 5px;
  background: var(--ink); color: var(--surface); font-size: 12px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
}
.tooltip .when { opacity: 0.7; margin-bottom: 5px; font-family: var(--mono); font-size: 11px; }
.tooltip .row { display: flex; align-items: center; gap: 8px; }
.tooltip .row b { min-width: 28px; text-align: right; font-variant-numeric: tabular-nums; }
.tooltip .row span { opacity: 0.8; }
.tooltip .stroke { width: 10px; height: 3px; border-radius: 2px; flex: none; }
.tooltip .stroke.s1 { background: var(--series-1); }
.tooltip .stroke.s2 { background: var(--series-2); }
.tooltip .stroke.s3 { background: var(--series-3); }
.tooltip .stroke.none { background: transparent; }
.tooltip .rule { height: 1px; background: currentColor; opacity: 0.18; margin: 5px 0; }

.ranked { display: grid; gap: 10px; }
.ranked .row { display: grid; grid-template-columns: minmax(0, 150px) minmax(0, 1fr) auto; align-items: center; gap: 12px; font-size: 13px; }
.ranked .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranked .track { height: 8px; }
.ranked .fill { height: 8px; width: var(--w); min-width: 2px; background: var(--bar); border-radius: 0 4px 4px 0; }
.ranked .val { font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }
.ranked .val small { color: var(--muted); margin-left: 6px; }

.items { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.items .sample { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-left: 6px; }
.more { display: flex; justify-content: center; padding-top: 12px; }

/* ── Policy ────────────────────────────────────────────────────────────── */
.savebar { display: flex; align-items: center; gap: 12px; }
.savebar .state { font-size: 12.5px; color: var(--ink-2); }
.savebar .state.dirty { color: var(--ink); font-weight: 600; }
.form-row { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; padding: 14px 0; border-top: 1px solid var(--line); }
.form-row:first-of-type { border-top: 0; padding-top: 0; }
.form-row:last-child { padding-bottom: 0; }
.form-row > div:first-child strong { display: block; font-size: 13.5px; }
.form-row > div:first-child span { font-size: 12.5px; color: var(--ink-2); }
.detector-group { font: 10.5px/1 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); padding: 14px 0 6px; }
.detector-group:first-child { padding-top: 0; }
.detector { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.detector .changed { font: 10.5px var(--mono); color: var(--muted); margin-left: 8px; }
.detector select, .rules select { padding: 4px 6px; font-size: 12.5px; }
.pack { padding: 14px 0; border-top: 1px solid var(--line); }
.pack:first-child { border-top: 0; padding-top: 0; }
.pack:last-child { padding-bottom: 0; }
.pack-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pack-head strong { font-size: 13.5px; }
.pack > .hint { margin: 4px 0 8px; max-width: 68ch; }
.pack .template { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.pack .template strong { font-size: 13px; font-weight: 500; }
.pack .template code { font-family: var(--mono); font-size: 12px; background: var(--wash); padding: 1px 5px; border-radius: 3px; margin: 0 8px; }
.pack .template .hint { display: block; margin-top: 2px; }
.rules { display: grid; gap: 8px; }
.rules .rule { display: grid; grid-template-columns: minmax(0, 1fr) 96px minmax(0, 1.4fr) 104px auto; gap: 8px; align-items: center; }
.rules .rule input { width: 100%; font-size: 13px; }
.rules .rule input.pattern { font-family: var(--mono); font-size: 12.5px; }
.rules .heads { font: 10.5px/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

/* ── Deploy ────────────────────────────────────────────────────────────── */
.create { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.create label.field input { width: 240px; }
.create > input { width: 280px; }
.create + .hint, .table-wrap + .create, .empty + .create { margin-top: 14px; }
.pill { margin-left: 8px; }
.login .hint { margin: 0; }
.steps { margin: 0; padding-left: 18px; font-size: 13px; color: var(--ink-2); display: grid; gap: 4px; }
.steps code, .hint code { font-family: var(--mono); font-size: 12px; background: var(--wash); padding: 1px 5px; border-radius: 3px; }

/* ── Login ─────────────────────────────────────────────────────────────── */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login form { width: min(360px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 26px; display: grid; gap: 16px; animation: rise 0.36s ease-out both; }
.login .brand { padding: 0; border: 0; color: var(--ink); }
.login .brand span { color: var(--muted); }
.login input { width: 100%; padding: 8px 10px; }
.login .btn { justify-content: center; padding: 8px 12px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; }
  .nav { grid-auto-flow: column; overflow-x: auto; }
  .rail-foot { margin-top: 0; padding: 8px 12px; border-top: 0; grid-auto-flow: column; justify-content: end; align-items: center; }
  .rail-foot > div { display: none; }
  main { padding: 20px 16px 40px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile { border-left: 0; border-top: 1px solid var(--line); }
  .grid.two { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; gap: 8px; }
  .rules .rule { grid-template-columns: 1fr 1fr; }
}
