/*
 * Sara 대시보드 스타일.
 * 방향: 순흑 평면(true-black flat). 높이는 명도 단계로만 구분하고(#000 바탕, #111 카드, #2a2a2a 안쪽 면),
 * 카드에는 테두리와 그림자를 두지 않는다. 색은 데이터에만 쓴다(--accent 하나). 활성 메뉴는 글자 밝기로 표시한다.
 * 모든 색, 간격, 글자 크기는 아래 토큰으로만 참조한다. 인라인 style 은 CSP 가 막으므로 쓰지 않는다.
 *
 * 격자 계산(1440px 창): 사이드바 210 + 본문 여백 29 x 2 + 내용 1172.
 * 개요 = 1fr + 384(오른쪽 열) + 간격 14 → 본문 열 774. 카드 둘이 한 줄이면 (774 - 14) / 2 = 380.
 */

@font-face {
  font-family: "Pretendard";
  src: url("/static/fonts/PretendardVariable.subset.woff2?v=1") format("woff2-variations");
  font-weight: 45 920;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --ground: #000000;
  --surface: #111111;
  --raised: #2a2a2a;
  --border: #1a1a1a;
  --rule: #1f1f1f;
  --control: #6b6b6b;
  --text: #ffffff;
  --nav: #bbbbbb;
  --muted: #b4b4b4;
  --faint: #949494;
  --accent: #c6f24e;
  --positive: #c6f24e;
  --negative: #e5484d;
  --warning: #e5a93b;
  --chart-1: #c6f24e;
  --chart-2: #e6e6e6;
  --chart-3: #6b6b6b;
  --grid: #2b2b2b;
  --pill-positive-bg: #222a10;
  --pill-positive-ink: #c6f24e;
  --pill-negative-bg: #2c1a20;
  --pill-negative-ink: #f07a8a;
  --pill-warning-bg: #2b2414;
  --pill-warning-ink: #e5a93b;
  --pill-neutral-bg: #222222;
  --pill-neutral-ink: #ffffff;
  /* 24시간 띠의 농도 단계. 0 은 메시지 없음, 4 는 가장 많은 시간 */
  --hr-0: #1c1c1c;
  --hr-1: #2f3a14;
  --hr-2: #4e6218;
  --hr-3: #86a626;
  --hr-4: #c6f24e;

  --radius-card: 20px;
  --radius-control: 999px;
  --radius-well: 12px;
  --gap: 14px;
  --pad: 22px;
  --gutter: 29px;
  --control-height: 36px;
  --row-height: 48px;
  --sidebar-width: 210px;
  --topbar-height: 64px;
  --fs-title: 24px;
  --fs-section: 16px;
  --fs-kpi: 24px;
  --fs-lead: 36px;
  --fs-body: 14px;
  --fs-small: 12px;
  --font: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font: 400 var(--fs-body)/21px var(--font);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul[class], ol[class] { padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--text); }
code { background: var(--raised); padding: 1px 6px; border-radius: 6px; font-size: 0.92em; }
strong { font-weight: 600; }

h1 { font-size: var(--fs-title); line-height: 30px; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: var(--fs-section); line-height: 22px; font-weight: 600; }
h3 { font-size: var(--fs-body); line-height: 20px; font-weight: 600; }

.muted { color: var(--muted); }
.small { font-size: var(--fs-small); line-height: 18px; }
.num { font-variant-numeric: tabular-nums; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; left: 8px; top: -48px; z-index: 20; background: var(--text); color: #000; padding: 8px 14px; border-radius: 999px; text-decoration: none; }
.skip:focus { top: 8px; }

/* ---- 틀: 위쪽 줄과 사이드바 ---- */

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  height: var(--topbar-height); padding: 0 var(--gutter) 0 0;
  background: var(--ground); border-bottom: 1px solid var(--border);
}
.brand {
  display: flex; align-items: center; gap: 10px; flex: none;
  width: var(--sidebar-width); padding-left: 20px; height: 100%;
  font-size: 17px; font-weight: 600; text-decoration: none; letter-spacing: -0.01em;
}
.no-menu .brand { width: auto; padding-left: var(--gutter); }
.with-menu .brand { border-right: 1px solid var(--border); }
.mark { width: 28px; height: 28px; flex: none; display: block; }
.crumbs { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--muted); }
.crumbs a { text-decoration: none; color: var(--muted); white-space: nowrap; }
.crumbs a:hover { color: var(--text); }
.crumbs .sep { color: var(--faint); }
.crumbs .here { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.topnav {
  margin-left: auto; display: flex; align-items: center; gap: 18px; flex: none;
  height: 100%;
}
.topnav a { text-decoration: none; color: var(--muted); white-space: nowrap; }
.topnav a:hover { color: var(--text); }
.who {
  display: flex; align-items: center; gap: 14px; height: 100%;
  padding-left: 18px; border-left: 1px solid var(--border);
}
.who .user { color: var(--text); font-weight: 500; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.menu-toggle { display: none; }

.layout { display: block; }
.with-menu .layout { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
.sidebar {
  position: sticky; top: var(--topbar-height); align-self: start;
  height: calc(100vh - var(--topbar-height)); overflow-y: auto;
  padding: 18px 12px 24px; border-right: 1px solid var(--border);
}
.menu-group + .menu-group { margin-top: 22px; }
.menu-title { color: var(--faint); font-size: var(--fs-small); line-height: 18px; padding: 0 12px 6px; }
.sidebar a.nav {
  display: flex; align-items: center; height: 32px; margin-bottom: 2px; padding: 0 12px;
  border-radius: 10px; color: var(--nav); text-decoration: none;
}
.sidebar a.nav:hover { color: var(--text); background: var(--surface); }
.sidebar a.nav.active { color: var(--text); font-weight: 600; }
.sidebar-account { display: none; }

main { min-width: 0; padding: 28px var(--gutter) 64px; }
.with-menu main { max-width: 1260px; }
.no-menu main { max-width: 1060px; margin: 0 auto; width: 100%; }

/* ---- 제목 줄 ---- */

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head .lead { color: var(--muted); margin-top: 4px; max-width: 70ch; }
.page-head .lead strong { color: var(--text); font-weight: 600; }

/* ---- 면(카드) ---- */

.card { background: var(--surface); border-radius: var(--radius-card); padding: var(--pad); margin: 0 0 var(--gap); }
.card > :first-child { margin-top: 0; }
.card h2 { margin-bottom: 10px; }
.card h3 { margin-bottom: 4px; }
.card p + p { margin-top: 8px; }
.card.narrow { max-width: 560px; margin-left: auto; margin-right: auto; }
.block > h2 { margin: 0 0 8px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--gap); }
.grid .card { margin: 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }

/* ---- 버튼과 입력 ---- */

.btn, button.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--control-height); padding: 0 18px; border-radius: var(--radius-control);
  border: 1px solid var(--control); background: transparent; color: var(--text);
  font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--text); text-decoration: none; }
.btn:active { background: var(--raised); }
.btn.primary { background: var(--text); border-color: var(--text); color: #000; font-weight: 600; }
.btn.primary:hover { background: #e2e2e2; border-color: #e2e2e2; }
.btn.danger { border-color: var(--negative); color: #f07a8a; }
.btn.danger:hover { background: var(--pill-negative-bg); border-color: #f07a8a; }
.btn.small { height: 30px; min-width: 64px; padding: 0 14px; font-size: 13px; }
.btn:disabled { opacity: 1; color: var(--faint); border-color: var(--raised); background: transparent; cursor: not-allowed; }
.btn:disabled:hover { border-color: var(--raised); }
button.link { background: none; border: 0; padding: 0; color: var(--text); cursor: pointer; text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 3px; }
button.link:hover { text-decoration-color: var(--text); }
form.inline { display: inline; margin: 0; }

input[type="text"], input[type="number"], select, textarea {
  width: 100%; min-height: var(--control-height); padding: 7px 14px;
  background: var(--raised); color: var(--text); border: 1px solid var(--control); border-radius: 12px;
}
textarea { border-radius: 14px; line-height: 21px; resize: vertical; }
select { padding-right: 10px; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }

.form label { display: block; margin-bottom: 16px; color: var(--muted); font-weight: 500; }
.form label > input, .form label > select, .form label > textarea { display: block; margin-top: 8px; color: var(--text); font-weight: 400; }
.form label.check { display: flex; gap: 10px; align-items: center; color: var(--text); font-weight: 400; }
.form input[type="checkbox"] { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 16px; }
.row { display: flex; gap: 8px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.row select, .row input[type="text"] { flex: 1; min-width: 140px; width: auto; }

/* ---- 알약과 상태 ---- */

.badge {
  display: inline-flex; align-items: center; height: 22px; padding: 0 10px; border-radius: 999px;
  font-size: 12px; font-weight: 500; white-space: nowrap; flex: none;
  background: var(--pill-neutral-bg); color: var(--pill-neutral-ink);
}
.badge.ok { background: var(--pill-positive-bg); color: var(--pill-positive-ink); }
.badge.warn { background: var(--pill-warning-bg); color: var(--pill-warning-ink); }
.badge.off { background: var(--pill-neutral-bg); color: var(--muted); }

.flash { padding: 12px 16px; border-radius: var(--radius-well); margin-bottom: var(--gap); }
.flash.ok { background: var(--pill-positive-bg); color: var(--pill-positive-ink); }
.flash.err { background: var(--pill-negative-bg); color: var(--pill-negative-ink); }
main > .notice { margin-bottom: var(--gap); }
.notice { padding: 10px 14px; border-radius: var(--radius-well); background: var(--pill-warning-bg); color: var(--pill-warning-ink); font-size: 13px; line-height: 19px; }

.status .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); margin-right: 8px; vertical-align: 1px; }
.status.alive .dot { background: var(--positive); }
.status.dead .dot { background: var(--negative); }
.status-pending, .status-running { color: var(--warning); }
.status-done { color: var(--positive); }
.status-error { color: #f07a8a; }

/* ---- 표 ---- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 12px 12px 12px 0; border-bottom: 1px solid var(--rule); vertical-align: top; overflow-wrap: anywhere; }
th { color: var(--muted); font-weight: 400; font-size: var(--fs-small); line-height: 18px; white-space: nowrap; padding-top: 6px; padding-bottom: 8px; }
tbody tr:last-child td { border-bottom: 0; }
@media (min-width: 801px) {
  #command-log td:nth-child(1) { width: 3em; }
  #command-log td:nth-child(3) { white-space: nowrap; width: 4.5em; }
  #command-log td.num { white-space: nowrap; width: 11em; }
}
th.num, td.num { text-align: right; padding-right: 0; padding-left: 12px; }
td .sub { display: block; color: var(--faint); font-size: var(--fs-small); line-height: 18px; }
.table-panel { background: var(--surface); border-radius: var(--radius-card); padding: 10px var(--pad) 8px; }

.chips { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chips li { display: flex; gap: 12px; align-items: center; min-height: 32px; padding: 3px 14px; background: var(--raised); border-radius: 999px; }
ul.plain { margin: 8px 0; padding-left: 20px; }
ul.plain li + li { margin-top: 4px; }

.kv { display: grid; grid-template-columns: max-content max-content; gap: 6px 28px; margin: 12px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

details { margin-top: 12px; }
summary { cursor: pointer; color: var(--muted); }
summary:hover { color: var(--text); }

/* ---- 탭 ---- */

.tabs { display: flex; gap: 22px; }
.tab { position: relative; display: inline-flex; align-items: center; height: 36px; color: var(--nav); text-decoration: none; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--text); font-weight: 600; }
.tab.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--text); }

/* ---- 설정 화면: 왼쪽 설명, 오른쪽 면 ---- */

.setting { display: grid; grid-template-columns: minmax(200px, 300px) minmax(0, 1fr); gap: 8px 32px; margin-bottom: 32px; align-items: start; }
.setting-head h2 { margin-top: 2px; }
.setting-head p { color: var(--muted); margin-top: 6px; }
.setting-head .badge { margin-top: 10px; }
.setting > .card { margin: 0; }
.setting-body { min-width: 0; }
.setting .form { max-width: 680px; }

/* ---- 서버 목록 ---- */

.guild-head { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.icon { width: 44px; height: 44px; border-radius: 50%; background: var(--raised); flex: none; }
.name { font-weight: 600; overflow-wrap: anywhere; }

/* ---- 서버 개요 ---- */

.ov-grid { display: grid; grid-template-columns: minmax(0, 1fr) 384px; gap: var(--gap); align-items: start; }
.ov-main, .ov-rail { display: contents; }
.ov-grid > .notice, .ov-main > .notice { grid-column: 1; }
.ov-main > .kpis, .ov-main > .block-off { grid-column: 1; grid-row: 1; }
.ov-rail > .status-card { grid-column: 2; grid-row: 1; }
.ov-main > .block-chart { grid-column: 1 / -1; grid-row: 2; }
.ov-grid > .block-modules { grid-column: 1 / -1; grid-row: 4; }
.ov-main > .kpis, .ov-main > .block-off, .ov-rail > .status-card { align-self: stretch; }
.ov-main > .ov-pair { grid-column: 1 / -1; grid-row: 3; }
.ov-main > .card, .ov-rail > .card, .ov-main > .kpis { margin: 0; }
.ov-pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.ov-pair > .card { margin: 0; min-width: 0; display: flex; flex-direction: column; }
.ov-pair > .card > .empty { flex: 1; }
.ov-pair.compact { align-items: start; }
.ov-log { margin-top: 28px; }
.log-note { margin: -2px 0 10px; }
td.id { color: var(--faint); width: 4.5em; }

.kpis { display: grid; grid-template-columns: 1.35fr 1fr; background: var(--surface); border-radius: var(--radius-card); }
.kpi { padding: var(--pad); min-width: 0; }
.kpi + .kpi { border-left: 1px solid var(--raised); }
.kpi-label { color: var(--muted); }
.kpi-value { margin-top: 6px; font-size: var(--fs-kpi); line-height: 32px; font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.kpi.lead .kpi-value { font-size: var(--fs-lead); line-height: 44px; font-weight: 600; }
.kpi-value .unit { font-size: var(--fs-body); font-weight: 400; color: var(--muted); margin-left: 4px; letter-spacing: 0; }
.kpi-value.none { color: var(--faint); }
.kpi-note { margin-top: 6px; color: var(--muted); font-size: var(--fs-small); line-height: 18px; font-variant-numeric: tabular-nums; }

.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.card-head .meta { color: var(--faint); font-size: var(--fs-small); }

.bars { display: grid; grid-template-columns: 36px minmax(0, 1fr); column-gap: 8px; }
.bars .ylab { grid-row: 1; width: 36px; height: 160px; overflow: visible; }
.ylab text { fill: var(--faint); font-size: 12px; text-anchor: end; font-variant-numeric: tabular-nums; }
.plot { min-width: 0; }
.plot svg { width: 100%; height: 160px; overflow: visible; }
.plot .gl { stroke: var(--grid); stroke-width: 1; vector-effect: non-scaling-stroke; shape-rendering: crispEdges; }
.plot .base { stroke: var(--faint); stroke-width: 1; vector-effect: non-scaling-stroke; shape-rendering: crispEdges; }
.plot .b { fill: var(--chart-1); }
.plot .b:hover { fill: #dcff7a; }
.xlab { display: grid; grid-template-columns: repeat(7, 1fr); margin-top: 8px; font-variant-numeric: tabular-nums; text-align: center; }
.xlab li { min-width: 0; font-size: var(--fs-small); line-height: 17px; color: var(--muted); }
.xlab li b { display: block; font-weight: 500; color: var(--text); font-size: 13px; }
.xlab li.today { color: var(--text); }

.hourstrip { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; margin-top: 4px; flex: 1 1 56px; min-height: 56px; }
.hourstrip li { background: var(--hr-0); position: relative; }
.hourstrip li.l1 { background: var(--hr-1); }
.hourstrip li.l2 { background: var(--hr-2); }
.hourstrip li.l3 { background: var(--hr-3); }
.hourstrip li.l4 { background: var(--hr-4); }
.hourstrip li.top::after { content: ""; position: absolute; left: 0; right: 0; bottom: -7px; height: 3px; background: var(--text); }
.hourticks { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 12px; color: var(--faint); font-size: var(--fs-small); }
.hourlist { margin-top: 10px; }
.hourlist li, .rank li {
  display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 0 10px; align-items: baseline;
  padding: 8px 0; border-top: 1px solid var(--rule);
}
.hourlist .rk, .rank .rk { color: var(--faint); font-variant-numeric: tabular-nums; }
.hourlist .ct, .rank .ct { font-weight: 500; font-variant-numeric: tabular-nums; text-align: right; }
.rank .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank li { grid-template-columns: 22px minmax(0, 1fr) auto; row-gap: 6px; padding: 10px 0 11px; }
.rank progress { grid-column: 2 / -1; }
progress { appearance: none; -webkit-appearance: none; width: 100%; height: 2px; border: 0; background: var(--raised); display: block; }
progress::-webkit-progress-bar { background: var(--raised); }
progress::-webkit-progress-value { background: var(--chart-1); }
progress::-moz-progress-bar { background: var(--chart-1); }

.empty { padding: 14px 16px; border: 1px dashed var(--control); border-radius: var(--radius-well); color: var(--muted); }
.empty .btn { margin-top: 10px; }

.segs { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; margin: 8px 0 4px; }
.segs span { height: 6px; border-radius: 3px; background: var(--raised); }
.segs span.on { background: var(--accent); }

.status-card { display: flex; flex-direction: column; gap: 4px; justify-content: space-between; }
.status-card strong { font-size: var(--fs-section); }
.block-modules h2 .hint { margin-left: 10px; font-size: var(--fs-small); font-weight: 400; color: var(--faint); }
.modules { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.module { position: relative; background: var(--surface); border-radius: var(--radius-card); padding: 14px 16px; min-height: 84px; display: flex; flex-direction: column; gap: 6px; outline-offset: 2px; }
.module:hover, .module:focus-within { background: var(--raised); z-index: 3; }
.module-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.module-head h3 { font-size: var(--fs-section); }
.module-sum { color: var(--muted); font-size: 13px; line-height: 19px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 0; }
.module-more {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 4;
  display: flex; flex-direction: column; gap: 8px; padding: 4px 16px 14px;
  background: var(--raised); border-radius: 0 0 var(--radius-card) var(--radius-card);
  opacity: 0; pointer-events: none;
}
.module:hover .module-more, .module:focus-within .module-more { opacity: 1; pointer-events: auto; }
.module:hover, .module:focus-within { border-radius: var(--radius-card) var(--radius-card) 0 0; }
.module-more p { color: var(--muted); font-size: 13px; line-height: 19px; margin: 0; }
.module .req { color: var(--muted); font-size: var(--fs-small); line-height: 18px; }
.module .module-act { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.module .module-act a { font-size: var(--fs-small); color: #f07a8a; text-decoration-color: #f07a8a; }
/* 마우스가 없는 기기(터치)는 호버가 없으니 설명과 버튼을 항상 펼쳐 둔다 */
@media (hover: none) {
  .module-sum { display: none; }
  .module-more { position: static; opacity: 1; pointer-events: auto; padding: 0; background: none; }
  .module:hover, .module:focus-within { border-radius: var(--radius-card); }
}

/* ---- 통계 화면 ---- */

.charts { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); margin-bottom: var(--gap); }
.charts .card { margin: 0; min-width: 0; }
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.chart-head h2 { margin: 0; }
.chart-box { position: relative; height: 240px; }
.stats-pair { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: var(--gap); margin-bottom: var(--gap); align-items: start; }
.stats-pair > .card, .stack-col > .card { margin: 0; }
.stack-col { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }

/* ---- 좁은 화면 ---- */

@media (max-width: 1100px) {
  .ov-grid { grid-template-columns: minmax(0, 1fr) 320px; }
  .stats-pair { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .ov-grid { display: flex; flex-direction: column; align-items: stretch; }
  .ov-main, .ov-rail { display: contents; }
  .ov-grid > *, .ov-main > *, .ov-rail > * { order: 5; }
  .ov-rail > .status-card { order: 1; }
  .ov-main > .kpis, .ov-main > .block-off { order: 2; }
  .ov-main > .block-chart { order: 3; }
  .ov-grid > .block-modules { order: 4; }
  .ov-pair { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 800px) {
  :root { --gutter: 16px; --pad: 18px; --topbar-height: 56px; }
  .with-menu .layout { display: block; }
  .topbar { gap: 8px; }
  .brand, .with-menu .brand { width: auto; border-right: 0; padding-left: 16px; }
  .crumbs { flex: 1; }
  .crumbs .back, .crumbs .sep:first-of-type { display: none; }
  .with-menu .topnav { display: none; }
  .no-menu .topnav { gap: 14px; }
  .no-menu .who { padding-left: 14px; }
  .no-menu .who .user { display: none; }
  .js .menu-toggle {
    display: inline-flex; align-items: center; height: 36px; padding: 0 16px; margin-left: auto;
    background: transparent; border: 1px solid var(--control); border-radius: 999px; color: var(--text); font-weight: 500;
  }
  .sidebar {
    position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); padding: 12px 16px 16px;
    max-height: none;
  }
  .js .sidebar { display: none; }
  .js.menu-open .sidebar {
    display: block; position: fixed; z-index: 9; inset: var(--topbar-height) 0 0 0; height: auto;
    background: var(--ground); overflow-y: auto; padding: 16px 16px 40px;
  }
  .sidebar a.nav { height: 44px; font-size: 15px; }
  .sidebar-account { display: block; margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--border); }
  .sidebar-account .user { color: var(--muted); padding: 0 12px 6px; }
  .sidebar-account form { margin: 0; }
  .sidebar-account button.link { display: flex; align-items: center; height: 44px; padding: 0 12px; font-size: 15px; text-decoration: none; color: var(--nav); }
  main { padding-top: 22px; }

  .page-head { margin-bottom: 18px; }
  .two-col, .charts { grid-template-columns: 1fr; }
  .setting { grid-template-columns: 1fr; gap: 10px; }
  .ov-pair { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi { padding: 16px 14px; }
  .kpi.lead { grid-column: 1 / -1; }
  .kpi.lead + .kpi { border-left: 0; border-top: 1px solid var(--raised); grid-column: 1 / -1; }
  .kpi.lead .kpi-value { font-size: 32px; }
  .modules { grid-template-columns: 1fr; }
  .module .module-act .btn { height: 44px; }
  .btn { min-height: 44px; }
  .btn.small { height: 44px; min-height: 44px; }
  .chart-box { height: 220px; }
  .tabs { gap: 18px; }
  .tab { height: 44px; }
  .row .btn { flex: none; }

  /* 표를 두 줄 항목으로 바꾼다. 항목 이름은 data-label 로 앞에 붙인다. */
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; }
  table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.stack tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
  table.stack tbody tr:last-child { border-bottom: 0; }
  table.stack td { padding: 0; border: 0; }
  table.stack td.c-main { grid-column: 1; order: 1; font-weight: 500; }
  table.stack td.c-status { grid-column: 2; grid-row: 1; order: 2; text-align: right; }
  table.stack td.c-sub { order: 3; grid-column: 1 / -1; color: var(--muted); font-size: var(--fs-small); line-height: 18px; text-align: left; padding-left: 0; }
  table.stack td.c-sub:empty { display: none; }
  table.stack td.c-sub::before { content: attr(data-label) " "; color: var(--faint); }
  table.stack td[colspan] { grid-column: 1 / -1; }
  .table-panel { padding: 6px 16px; }
}

@media (max-width: 480px) {
  .bars { grid-template-columns: 32px minmax(0, 1fr); column-gap: 6px; }
  .hourlist li, .rank li { grid-template-columns: 20px minmax(0, 1fr) auto; }
  .btn { padding: 0 16px; }
}

/* ---- 접는 항목(Dashboard 고정 메시지) ---- */

.pins { display: flex; flex-direction: column; gap: 8px; }
.pin { margin: 0; background: var(--surface); border-radius: var(--radius-card); }
.pin > summary {
  display: grid; grid-template-columns: minmax(120px, 220px) minmax(0, 1fr) auto 14px; align-items: center; gap: 16px;
  min-height: 56px; padding: 10px 22px; cursor: pointer; list-style: none; color: var(--text); border-radius: var(--radius-card);
}
.pin > summary::-webkit-details-marker { display: none; }
.pin > summary::after {
  content: ""; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg); margin-top: -4px; justify-self: end;
}
.pin[open] > summary::after { transform: rotate(-135deg); margin-top: 4px; }
.pin > summary:hover { background: #181818; }
.pin-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pin-text { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pin-new > summary .pin-text { grid-column: 2 / 4; }
.pin-body { padding: 4px 22px 22px; max-width: 760px; }
.pin-body .form label:last-of-type { margin-bottom: 0; }
.icon.placeholder { display: grid; place-items: center; font-weight: 600; color: var(--muted); }

@media (max-width: 800px) {
  .pin > summary { grid-template-columns: minmax(0, 1fr) auto 14px; gap: 4px 12px; padding: 12px 16px; min-height: 56px; }
  .pin-name { grid-column: 1; }
  .pin-text { grid-column: 1 / 3; grid-row: 2; }
  .pin > summary .badge { grid-column: 2; grid-row: 1; }
  .pin > summary::after { grid-column: 3; grid-row: 1; }
  .pin-new > summary .pin-text { grid-column: 1 / 3; }
  .pin-body { padding: 4px 16px 18px; }
}

@media (prefers-reduced-motion: no-preference) {
  .btn, .sidebar a.nav, .topnav a, .tab { transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease; }
}

.more { margin-left: 12px; font-size: var(--fs-small); font-weight: 400; color: var(--muted); }
.more:hover { color: var(--text); }
.filters { align-items: flex-end; margin-bottom: 16px; gap: 16px; }
.filters .check { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }

/* ---- 넓은 화면: 틀 전체를 가운데로 모은다 ---- */
@media (min-width: 801px) {
  .with-menu .layout { max-width: 1470px; margin-left: auto; margin-right: auto; }
  .with-menu .topbar {
    padding-left: max(0px, calc((100% - 1470px) / 2));
    padding-right: max(var(--gutter), calc((100% - 1470px) / 2 + var(--gutter)));
  }
}

/* ---- 처음 화면(로그인 전) ---- */
.landing {
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 56px;
  align-items: center; min-height: calc(100vh - var(--topbar-height) - 140px);
}
.landing-mark { width: 88px; height: 88px; margin-bottom: 28px; }
.landing-name { color: var(--muted); font-size: var(--fs-section); margin: 0 0 10px; }
.landing h1 { font-size: clamp(34px, 4.6vw, 56px); line-height: 1.14; letter-spacing: -0.02em; margin: 0 0 20px; }
.landing-lead { color: var(--text); font-size: 18px; line-height: 28px; max-width: 30em; margin: 0 0 28px; }
.landing-action { margin: 0 0 18px; }
.landing-action .btn { height: 48px; padding: 0 28px; font-size: 16px; }
.landing-note { max-width: 36em; line-height: 20px; margin: 0; }
.landing-modules { list-style: none; margin: 0; padding: 6px var(--pad); background: var(--surface); border-radius: var(--radius-card); }
.landing-modules li { display: grid; gap: 4px; padding: 16px 0; border-bottom: 1px solid var(--rule); }
.landing-modules li:last-child { border-bottom: 0; }
.landing-modules strong { font-size: 16px; font-weight: 600; }
.landing-modules span { color: var(--muted); line-height: 20px; }
@media (max-width: 800px) {
  .landing { grid-template-columns: 1fr; gap: 36px; min-height: 0; padding-top: 8px; }
  .landing-mark { width: 64px; height: 64px; margin-bottom: 20px; }
  .landing-action .btn { width: 100%; }
}

/* ---- 개요 머리: 관리 중인 서버 ---- */
.guild-id { display: flex; align-items: center; gap: 20px; min-width: 0; }
.guild-icon { width: 72px; height: 72px; border-radius: 50%; flex: none; background: var(--raised); object-fit: cover; }
.guild-icon.placeholder { display: grid; place-items: center; font-size: 28px; font-weight: 600; color: var(--muted); }
.guild-kicker { color: var(--muted); font-size: var(--fs-small); line-height: 18px; margin: 0 0 2px; }
.guild-head h1 { overflow-wrap: anywhere; }
@media (max-width: 480px) {
  .guild-id { gap: 14px; }
  .guild-icon { width: 56px; height: 56px; }
}

/* ---- 티켓: 역할 선택, 기록 대화 ---- */

.field-label { color: var(--muted); font-weight: 500; }
.check-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px 16px; margin: 8px 0 12px; max-height: 220px; overflow-y: auto; }
.check-list label.check { margin: 0; }
.msgs { margin-top: var(--gap); display: flex; flex-direction: column; gap: 2px; }
.msg { background: var(--surface); padding: 12px var(--pad); border-radius: var(--radius-well); }
.msg-head { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; margin-bottom: 4px; }
.msg-author { font-weight: 600; }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-extra { margin-top: 6px; color: var(--muted); overflow-wrap: anywhere; }
.pager { justify-content: center; margin: 16px 0; }

/* ---- 티켓 화면 간격 ---- */
.sect { margin-bottom: 32px; }
.sect > p.muted { margin: 0 0 12px; }
.card.summary { max-width: 420px; margin-bottom: 28px; }
.table-panel .row { margin-top: 0; }
@media (min-width: 801px) {
  #command-log td:nth-child(2) { min-width: 14em; }
}
