/* Components: the pieces every screen is built from. */

/* ---------------------------------------------------------------- buttons */

button, .button {
  font: inherit;
  font-size: var(--t-sm);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  height: 34px;
  padding: 0 var(--s-4);
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease);
}
button:hover:not(:disabled) { background: var(--surface-hover); }
/* A link dressed as a button (a download, a "see all") behaves like one. */
a.button:hover { background: var(--surface-hover); text-decoration: none; }
.button.small { height: 28px; padding: 0 var(--s-3); font-size: var(--t-xs); }
button:disabled { opacity: 0.5; cursor: default; }
button.primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 88%, #ffffff) 0%, var(--accent) 100%);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 4px 12px -4px color-mix(in srgb, var(--accent) 60%, transparent);
}
button.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
button:active:not(:disabled) { transform: translateY(0.5px); }
button.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line-strong)); }
button.danger:hover:not(:disabled) { background: var(--danger-soft); }
button.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
button.ghost:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }
button.small { height: 28px; padding: 0 var(--s-3); font-size: var(--t-xs); }
button.icon { width: 34px; padding: 0; }
button.icon.small { width: 28px; }
button.link {
  height: auto; padding: 0; border: 0; background: none; color: var(--accent);
}
button.link:hover:not(:disabled) { background: none; text-decoration: underline; }

/* ---------------------------------------------------------------- inputs */

input, select, textarea {
  font: inherit;
  font-size: var(--t-sm);
  color: var(--text);
  background: var(--surface-sunken);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0 var(--s-3);
  height: 34px;
  min-width: 0;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
textarea { height: auto; padding: var(--s-2) var(--s-3); line-height: 1.5; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
input:hover:not(:disabled):not(:focus), select:hover:not(:disabled):not(:focus), textarea:hover:not(:disabled):not(:focus) { border-color: color-mix(in srgb, var(--accent) 30%, var(--line-strong)); }
input:disabled, select:disabled, textarea:disabled { opacity: 0.6; }
input[type="checkbox"], input[type="radio"] {
  width: 16px; height: 16px; padding: 0; accent-color: var(--accent); cursor: pointer;
}
/* A long option ("…(권장)") never widens its box past the column it is in. */
select { cursor: pointer; padding-right: var(--s-6); max-width: 100%; }
option, optgroup { background: var(--surface); color: var(--text); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > .label { font-size: var(--t-sm); font-weight: 500; color: var(--text); }
.field > .help { font-size: var(--t-xs); color: var(--text-3); line-height: 1.45; }
.field > .error { font-size: var(--t-xs); color: var(--danger); }
.field.inline { flex-direction: row; align-items: center; gap: var(--s-3); }
/* Label column width for horizontal fields — one token so a wider
   language pack (or a Korean-only deployment) can override in one place
   instead of grepping .inline. */
.field.inline > .label { flex: 0 0 var(--label-min, 180px); }
.form { display: flex; flex-direction: column; gap: var(--s-5); }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); }

/* A switch: what a boolean setting looks like. */
.switch { display: inline-flex; align-items: flex-start; gap: var(--s-3); cursor: pointer; }
.switch input {
  appearance: none;
  flex: none;
  width: 34px;
  height: 20px;
  padding: 0;
  margin-top: 1px;
  border-radius: var(--radius-pill);
  background: var(--line-strong);
  border: 0;
  position: relative;
  transition: background var(--dur) var(--ease);
}
.switch input::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform var(--dur) var(--ease);
}
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(14px); }
.switch .switch-text { display: flex; flex-direction: column; gap: 2px; }
.switch .switch-text .help { font-size: var(--t-xs); color: var(--text-3); }

/* Two to four mutually exclusive choices. */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.segmented button {
  height: 28px;
  border: 0;
  background: transparent;
  color: var(--text-2);
  padding: 0 var(--s-3);
  border-radius: var(--radius-sm);
}
.segmented button.on { background: var(--surface-3); color: var(--text); box-shadow: var(--shadow-1); }

/* Choice cards: a three-way decision with a sentence each. */
.choices { display: grid; gap: var(--s-2); }
.choice {
  display: flex;
  gap: var(--s-3);
  align-items: flex-start;
  padding: var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  background: var(--surface);
}
.choice:hover { border-color: var(--line-strong); }
.choice.on { border-color: var(--accent); background: var(--accent-soft); }
.choice input { margin-top: 2px; }
.choice .choice-title { font-weight: 500; }
.choice .choice-help { font-size: var(--t-xs); color: var(--text-3); }

/* A list of short values, one chip each. */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 5px;
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-sunken);
}
.tags:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tags input { border: 0; background: transparent; height: 22px; flex: 1; min-width: 120px; padding: 0 4px; }
.tags input:focus { box-shadow: none; }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 4px 0 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: var(--t-xs);
}
.tag button { height: 18px; width: 18px; padding: 0; border: 0; background: none; color: var(--text-3); }

/* ---------------------------------------------------------------- badges */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 9px;
  border-radius: var(--radius-pill);
  font-size: var(--t-xs);
  font-weight: 600;
  white-space: nowrap;
  background: var(--muted-soft);
  color: var(--text-2);
}
.badge.block, .badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.mask, .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.allow, .badge.muted { background: var(--muted-soft); color: var(--text-2); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.high { background: var(--high-soft); color: var(--high); }
.badge.accent { background: var(--accent-soft); color: var(--accent-hover); }
.badge.outline { background: transparent; border: 1px solid var(--line-strong); color: var(--text-2); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: var(--text-3); }
.dot.critical { background: var(--danger); }
.dot.high { background: var(--high); }
.dot.medium { background: var(--warn); }
.dot.low { background: var(--info); }
.dot.ok { background: var(--ok); }
.dot.off { background: var(--text-3); }
.dot.warn { background: var(--warn); }
.dot.live { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); animation: pulse 2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px transparent; } }

.severity { display: inline-flex; align-items: center; gap: 6px; font-size: var(--t-sm); color: var(--text-2); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 var(--s-3);
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text-2);
  font-size: var(--t-sm);
  font-weight: 500;
}
.chip:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.chip .count { font-size: var(--t-xs); color: var(--text-3); }
/* Category chips on /flow. Fixed height 24px so they fit inside a rank row
 * without pushing the row's text baseline down. */
.chip-credential, .chip-personal, .chip-internal, .chip-integrity, .chip-other {
  display: inline-flex; align-items: center;
  height: 22px; padding: 0 10px;
  border-radius: var(--radius-pill);
  font-size: var(--t-xs); font-weight: 500;
  border: 1px solid transparent;
}
.chip-credential { background: var(--warn-soft, rgba(230, 160, 30, 0.15)); color: var(--warn); border-color: var(--warn); }
.chip-personal   { background: var(--danger-soft, rgba(200, 60, 60, 0.15)); color: var(--danger); border-color: var(--danger); }
.chip-internal   { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.chip-integrity  { background: var(--surface-2); color: var(--text-2); border-color: var(--line-strong); }
.chip-other      { background: transparent; color: var(--text-3); border-color: var(--line); }
.token {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding: 0 4px 0 10px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: var(--t-xs);
  color: var(--text-2);
}
.token strong { color: var(--text); font-weight: 600; }
.token button { width: 20px; height: 20px; padding: 0; border: 0; background: none; color: var(--text-3); border-radius: 50%; }
.token button:hover { background: var(--surface-hover); color: var(--text); }

/* ---------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  min-width: 0;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-5) var(--s-5) 0;
  min-height: 44px;
}
.card-head h2 { font-size: 15px; font-weight: 650; letter-spacing: -0.015em; }
.card-head .sub { color: var(--text-3); font-size: var(--t-xs); }
.card-body { padding: var(--s-4) var(--s-5) var(--s-5); }
.card-body.flush { padding: 0; }
.card + .card { margin-top: 0; }
.section-title {
  font-size: var(--t-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: var(--s-2) 0;
}

/* A figure with a label, a direction, and where to go from it. */
.kpi {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-5);
  text-align: left;
  height: auto;
  align-items: stretch;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--card-shadow);
  cursor: default;
  white-space: normal;
  /* A tile that is a button would centre its content; tiles in a row line
     up at the top instead. */
  justify-content: flex-start;
  --kpi-tone: var(--accent);
}
.kpi.tone-danger { --kpi-tone: var(--danger); }
.kpi.tone-warn { --kpi-tone: var(--warn); }
.kpi.tone-ok { --kpi-tone: var(--ok); }
.kpi .kpi-icon {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-right: 4px;
  border-radius: 8px;
  color: var(--kpi-tone);
  background: color-mix(in srgb, var(--kpi-tone) 14%, transparent);
  flex: none;
}
/* Only a tile that opens something (a button) says so on hover. */
button.kpi { cursor: pointer; }
button.kpi { transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
button.kpi:hover:not(:disabled) { background: var(--surface); border-color: color-mix(in srgb, var(--kpi-tone) 45%, var(--line-strong)); transform: translateY(-1px); box-shadow: var(--card-shadow), var(--shadow-1); }
.kpi .kpi-label { font-size: var(--t-sm); color: var(--text-2); font-weight: 500; display: flex; gap: 6px; align-items: center; }
.kpi .kpi-tag { display: inline-flex; align-items: center; padding: 1px 6px; margin-left: 2px; border-radius: 8px; background: var(--surface-sunken); color: var(--text-3); font-size: var(--t-xs); font-weight: 500; letter-spacing: .02em; }
.kpi .kpi-value { font-size: var(--t-kpi); font-weight: 700; line-height: 1.1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi .kpi-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); min-height: 22px; color: var(--text-3); font-size: var(--t-xs); }
.kpi.tone-danger .kpi-value { color: var(--danger); }
.kpi.tone-warn .kpi-value { color: var(--warn); }
.kpi.tone-ok .kpi-value { color: var(--ok); }
.delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 22px;
  padding: 0 8px 0 6px;
  border-radius: var(--radius-pill);
  font-size: var(--t-xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-3);
  background: var(--muted-soft);
  white-space: nowrap;
}
.delta.flat { padding: 0 8px; }
.delta.up { color: var(--danger); background: var(--danger-soft); }
.delta.down { color: var(--ok); background: var(--ok-soft); }

/* Facts: a label and a value, down a column. */
.facts {
  display: grid;
  grid-template-columns: minmax(96px, max-content) minmax(0, 1fr);
  gap: var(--s-2) var(--s-4);
  margin: 0;
  font-size: var(--t-sm);
}
.facts dt { color: var(--text-3); }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- lists */

.table-frame {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: auto;
  min-height: 0;
}
.page.fill .table-frame { flex: 1; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--t-sm); }
table.data.fixed { table-layout: fixed; }
table.data.fixed td { overflow: hidden; }
table.data th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: color-mix(in srgb, var(--surface-sunken) 55%, var(--surface));
  text-align: left;
  font-weight: 600;
  font-size: var(--t-xs);
  letter-spacing: 0.01em;
  color: var(--text-3);
  padding: 0 var(--s-4);
  height: 38px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
/* A title that orders the list (dataTable's sort, R35 W-3): a button drawn as
   the title it is -- no frame or fill, the title's own size and colour -- with
   the arrow of the order beside it. Written heavier than the `button` rules
   further down, so their frame, hover fill and press nudge stay off it. On a
   phone the head is out of sight with the rest of it; the order chip sorts. */
table.data th .sort-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  height: auto;
  padding: 2px 0;
  border: 0;
  border-radius: 4px;
  background: none;
  box-shadow: none;
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
  vertical-align: middle;
  transform: none;
}
table.data th .sort-button:hover:not(:disabled) { background: none; color: var(--text); }
table.data th .sort-button.on { color: var(--text); }
table.data th .sort-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
table.data th .sort-button .icon { flex: none; opacity: 0.45; }
table.data th .sort-button:hover .icon,
table.data th .sort-button:focus-visible .icon { opacity: 0.85; }
table.data th .sort-button.on .icon { opacity: 1; color: var(--accent); }
table.data th .sort-gap { margin: 0 6px; }
table.data td {
  padding: 0 var(--s-4);
  height: 46px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background var(--dur-fast) var(--ease); }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover { background: var(--surface-hover); }
table.data tbody tr.selected { background: var(--accent-soft); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td .cell-main { display: block; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.data td .cell-sub { display: block; color: var(--text-3); font-size: var(--t-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.data td.wrap .cell-main,
table.data td.wrap .cell-sub { white-space: normal; overflow-wrap: anywhere; }
/* A long word -- a URL in an endpoint's error -- breaks rather than widening
   its column past the frame. */
table.data td.wrap { overflow-wrap: anywhere; }
table.data.compact td { height: 36px; }
table.data tr.repeat td { color: var(--text-2); }
.col-time { width: 150px; }
.col-action { width: 88px; }
.col-severity { width: 96px; }

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-3) 0 0;
  color: var(--text-3);
  font-size: var(--t-xs);
}
.pager .pages { display: flex; gap: 2px; align-items: center; }
.pager .pages button { min-width: 30px; height: 28px; padding: 0 8px; border-color: transparent; background: transparent; color: var(--text-2); }
.pager .pages button.on { background: var(--accent-soft); color: var(--text); border-color: var(--accent); }
.pager select { height: 28px; }

.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain > li { padding: var(--s-3) 0; border-bottom: 1px solid var(--line); }
.list-plain > li:last-child { border-bottom: 0; }

/* A ranked list with a bar for scale. */
.rank { display: flex; flex-direction: column; gap: var(--s-2); }
.rank-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px var(--s-3);
  padding: 6px var(--s-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--t-sm);
}
.rank-row:hover { background: var(--surface-hover); }
/* A row that opens something is a button, and must not look like one. */
button.rank-row { width: 100%; height: auto; border: 0; background: none; font: inherit; color: inherit; text-align: left; box-shadow: none; justify-content: stretch; }
.nowrap { white-space: nowrap; }
.rank-row .bar { grid-column: 1 / -1; height: 4px; border-radius: 4px; background: var(--surface-sunken); overflow: hidden; }
.rank-row .bar > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }

/* ---------------------------------------------------------------- filters */

.filterbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
}
.search {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  height: 34px;
  padding: 0 var(--s-3);
  /* Laid out at its smallest, then grown into what the chips leave: a
     wrapping row breaks lines on the starting size, not the shrunk one. */
  flex: 1 1 220px;
  max-width: 340px;
  min-width: 200px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-sunken);
  color: var(--text-3);
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input { border: 0; background: transparent; height: 32px; padding: 0; flex: 1; }
.search input:focus { box-shadow: none; }
.filterbar .divider { width: 1px; height: 20px; background: var(--line); margin: 0 var(--s-1); }
.active-filters { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; margin-bottom: var(--s-3); }
.result-line { color: var(--text-3); font-size: var(--t-xs); margin-left: auto; white-space: nowrap; }

/* The line between the filters and the table: what the list holds, how it is
   shown. */
.list-meta { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-2); min-height: 32px; }
.list-meta .count { display: inline-flex; align-items: center; gap: var(--s-1); color: var(--text-3); font-size: var(--t-xs); }
.hint { display: inline-flex; color: var(--text-3); cursor: help; border-radius: 50%; }
.hint:hover, .hint:focus-visible { color: var(--text-2); }

/* ---------------------------------------------------------------- popover / menu */

.popover {
  position: fixed;
  z-index: 60;
  min-width: 220px;
  max-width: 360px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  padding: var(--s-2);
  animation: pop-in var(--dur) var(--ease-out);
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } }
.popover .menu-item {
  width: 100%;
  justify-content: flex-start;
  border: 0;
  background: transparent;
  height: 34px;
  color: var(--text);
}
.popover .menu-item:hover:not(:disabled) { background: var(--surface-hover); }
.popover .menu-sep { height: 1px; background: var(--line); margin: var(--s-2) 0; }
.popover .menu-head { padding: var(--s-2) var(--s-3); }
.popover .form { padding: var(--s-2); gap: var(--s-3); }

/* ---------------------------------------------------------------- drawer */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--overlay);
  animation: fade-in var(--dur) var(--ease);
}
.scrim.leaving { animation: fade-out var(--dur) var(--ease) forwards; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 41;
  width: min(var(--drawer-w), 100vw);
  background: var(--surface);
  border-left: 1px solid var(--line-strong);
  box-shadow: var(--shadow-3);
  display: flex;
  flex-direction: column;
  animation: slide-in var(--dur-slow) var(--ease-out);
}
.drawer.wide { width: min(760px, 100vw); }
.drawer.leaving { animation: slide-out var(--dur) var(--ease) forwards; }
@keyframes slide-in { from { transform: translateX(32px); opacity: 0; } }
@keyframes slide-out { to { transform: translateX(32px); opacity: 0; } }
.drawer-head {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  padding: var(--s-5) var(--s-6) var(--s-4);
  border-bottom: 1px solid var(--line);
}
.drawer-head .titles { flex: 1; min-width: 0; }
.drawer-head .eyebrow { display: flex; gap: var(--s-2); align-items: center; margin-bottom: var(--s-2); }
.drawer-head h2 { font-size: var(--t-lg); overflow-wrap: anywhere; }
.drawer-head .sub { color: var(--text-3); font-size: var(--t-sm); margin-top: 2px; }
.drawer-body { flex: 1; overflow: auto; padding: var(--s-5) var(--s-6) var(--s-8); display: flex; flex-direction: column; gap: var(--s-6); }
.drawer-foot { padding: var(--s-3) var(--s-6); border-top: 1px solid var(--line); display: flex; gap: var(--s-2); justify-content: flex-end; }
.drawer-section h3 { font-size: var(--t-sm); color: var(--text-2); margin-bottom: var(--s-3); font-weight: 600; }

/* ---------------------------------------------------------------- modal */

.modal-wrap {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  /* One column no wider than the screen. An auto column grew to the widest
     thing inside -- a table's columns -- so on a phone the dialog ran off the
     right edge, close button and all, instead of its table scrolling. */
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: var(--s-6);
  background: var(--overlay);
  backdrop-filter: blur(2px);
  animation: fade-in var(--dur) var(--ease);
}
.modal-wrap.leaving { animation: fade-out var(--dur) var(--ease) forwards; }
.modal {
  width: min(520px, 100%);
  min-width: 0;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  box-shadow: var(--shadow-3);
  animation: pop-in var(--dur) var(--ease-out);
}
.modal.wide { width: min(820px, 100%); }
.modal-head { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-5) var(--s-6) 0; }
.modal-head h2 { flex: 1; }
.modal-body { padding: var(--s-4) var(--s-6); overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--s-2); padding: var(--s-4) var(--s-6) var(--s-5); }

/* ---------------------------------------------------------------- toast */

.toasts {
  position: fixed;
  right: var(--s-6);
  bottom: var(--s-6);
  z-index: 70;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  align-items: flex-end;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  max-width: 440px;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-2);
  font-size: var(--t-sm);
  animation: pop-in var(--dur) var(--ease-out);
}
.toast.error { border-color: color-mix(in srgb, var(--danger) 50%, var(--line-strong)); }
.toast.error svg { color: var(--danger); }
.toast.ok svg { color: var(--ok); }
.toast.leaving { animation: fade-out var(--dur) var(--ease) forwards; }

/* ---------------------------------------------------------------- tabs */

.tabs {
  display: flex;
  gap: var(--s-1);
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--s-5);
  overflow-x: auto;
}
.tabs a, .tabs button {
  height: 38px;
  padding: 0 var(--s-3);
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: none;
  color: var(--text-2);
  font-weight: 500;
  font-size: var(--t-sm);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  white-space: nowrap;
  margin-bottom: -1px;
}
.tabs a:hover, .tabs button:hover:not(:disabled) { color: var(--text); background: none; }
.tabs a.on, .tabs button.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tabs a svg, .tabs button svg { color: var(--text-3); }
.tabs a.on svg, .tabs button.on svg { color: var(--accent-hover); }

/* ---------------------------------------------------------------- fold */

details.fold { border-top: 1px dashed var(--line); padding-top: var(--s-3); }
details.fold > summary {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-2);
  font-size: var(--t-sm);
  font-weight: 500;
  user-select: none;
}
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary svg { transition: transform var(--dur) var(--ease); }
details.fold[open] > summary svg { transform: rotate(90deg); }
details.fold > .fold-body { padding-top: var(--s-4); display: flex; flex-direction: column; gap: var(--s-5); }

/* ---------------------------------------------------------------- notices */

.callout {
  display: flex;
  gap: var(--s-3);
  align-items: flex-start;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--radius);
  background: var(--info-soft);
  color: var(--text);
  font-size: var(--t-sm);
}
.callout svg { flex: none; color: var(--info); margin-top: 2px; }
.callout.warn { background: var(--warn-soft); }
.callout.warn svg { color: var(--warn); }
.callout.danger { background: var(--danger-soft); }
.callout.danger svg { color: var(--danger); }
.callout.ok { background: var(--ok-soft); }
.callout.ok svg { color: var(--ok); }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-12) var(--s-6);
  text-align: center;
  color: var(--text-3);
}
.empty svg { color: var(--text-3); opacity: 0.7; }
.empty .empty-title { color: var(--text); font-weight: 600; font-size: var(--t-md); }
.empty .empty-text { max-width: 420px; font-size: var(--t-sm); }

/* Loading: shapes where content will land, never a spinner in the middle. */
.skeleton { display: flex; flex-direction: column; gap: var(--s-3); }
.bone {
  height: 12px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-hover) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  z-index: 80;
  background: var(--accent);
  transition: width var(--dur-slow) var(--ease), opacity var(--dur) var(--ease);
}

/* A timeline: what happened, in order. */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 1px; background: var(--line-strong); }
.timeline li { position: relative; padding: 0 0 var(--s-3) var(--s-6); font-size: var(--t-sm); }
.timeline li::before {
  content: "";
  position: absolute;
  left: 1px;
  top: 6px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--text-3);
}
.timeline li.block::before { border-color: var(--danger); }
.timeline li.mask::before { border-color: var(--warn); }
.timeline li .when { color: var(--text-3); font-size: var(--t-xs); }

/* A value to copy -- a token, a command -- with the button beside it. */
.copy-row {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-2) var(--s-2) var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-sunken);
}
.copy-row code { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: var(--t-sm); }

/* Numbered steps: how to do something that takes more than one place. */
.steps { list-style: none; counter-reset: step; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-5); }
.steps > li { counter-increment: step; position: relative; padding-left: 40px; min-height: 26px; }
.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: -2px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--t-sm);
  font-weight: 600;
}
.steps p { margin: var(--s-1) 0 0; }
.steps pre.code { margin-top: var(--s-2); }

.col-actions { width: 96px; text-align: right; }

pre.code {
  margin: 0;
  padding: var(--s-3) var(--s-4);
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Where the rules matched in kept evidence (R34 W-14). No color-mix: the
   theme test reads these tokens. */
mark.hit {
  color: inherit;
  background: rgba(255, 97, 91, .30);
  border-radius: 3px;
  padding: 0 1px;
  box-shadow: inset 0 -2px 0 var(--danger);
}

mark.hit.exempted {
  background: var(--ok-soft);
  box-shadow: inset 0 -2px 0 var(--ok);
}

.evidence-legend mark.hit {
  font-family: var(--font-mono);
}

/* Kept evidence read in the console (review 3-15): the text as it was sent. */
pre.evidence-text {
  margin: 0;
  padding: var(--s-3) var(--s-4);
  max-height: 60vh;
  overflow: auto;
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: var(--t-sm);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.health {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  height: 30px;
  padding: 0 5px 0px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  font-size: var(--t-sm);
}
.health:hover:not(:disabled) { background: var(--surface-hover); }
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-weight: 600;
  font-size: var(--t-sm);
}
.account { border: 0; background: none; height: 38px; padding: 0 var(--s-2); gap: var(--s-2); }
.account:hover:not(:disabled) { background: var(--surface-hover); }

/* ---------------------------------------------------------------- settings */

/* A question and its answer on one line, the way settings read. */
.setting { display: flex; align-items: center; justify-content: space-between; gap: var(--s-5); }
.setting + .setting { border-top: 1px solid var(--line); padding-top: var(--s-4); }
.setting-text { min-width: 0; flex: 1; }
.setting-label { font-weight: 500; font-size: var(--t-sm); }
.setting-help { color: var(--text-3); font-size: var(--t-xs); margin-top: 2px; }
.setting-control { flex: none; }

/* On/off boxes that make one list together. */
.check-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(190px, 100%), 1fr)); gap: var(--s-3) var(--s-4); }
/* The services an exception applies to, checked by name (R35 W-2): a hundred
   and more, so the list scrolls inside the dialog. */
.service-pick { max-height: 240px; overflow-y: auto; padding: var(--s-3); border: 1px solid var(--line); border-radius: var(--radius); }
.service-pick .check-list { grid-template-columns: repeat(auto-fill, minmax(min(160px, 100%), 1fr)); gap: var(--s-2) var(--s-3); }
.check { display: flex; align-items: flex-start; gap: var(--s-2); font-size: var(--t-sm); cursor: pointer; }
.check input { margin-top: 3px; flex: none; }

.tags.plain { border: 0; background: none; padding: 0; min-height: 0; box-shadow: none; }
.rule-picker { display: flex; flex-direction: column; gap: var(--s-2); }
.switch.compact .switch-text { display: none; }
.grid.align-start { align-items: start; }
table.data tr.off td { opacity: .55; }
table.data tr.off td.col-switch { opacity: 1; }
.col-menu { width: 52px; text-align: right; }

/* A click past a dialog moves it rather than closing it. */
.modal.nudge { animation: nudge .28s var(--ease); }
@keyframes nudge { 0%, 100% { transform: none; } 35% { transform: scale(1.012); } }
@media (prefers-reduced-motion: reduce) { .modal.nudge { animation: none; } }
.modal .stayed { flex: 1; align-self: center; font-size: var(--t-xs); color: var(--warn); }
/* A dialog's own error, above its buttons (review 3-9). */
.modal-foot:has(.modal-error) { flex-wrap: wrap; }
.modal .modal-error { flex-basis: 100%; margin: 0 0 var(--s-2); }
/* A menu item reached from the keyboard (review 3-8). */
.popover .menu-item:focus-visible { background: var(--surface-hover); outline-offset: -2px; }

/* Chart legend + mixBar strip: extracted from ui/charts.js's inline styles
   so magic pixels (10 / 12 / 14 / 6) live in one place, and the swatch
   colour is the only per-item state. */
.legend { display: flex; flex-wrap: wrap; gap: 14px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: var(--t-xs); color: var(--text-3); }
.legend-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.mixbar { display: flex; height: 10px; border-radius: 6px; overflow: hidden; background: var(--surface-sunken); }

/* Server resources (관리 → 시스템 정보): a block per resource, a bar per use.
   Green, amber past the warning level, red past the danger level; the figure
   beside the bar carries the same colour so the state reads without the bar. */
.resources { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: var(--s-5); }
.resource { display: flex; flex-direction: column; gap: var(--s-3); min-width: 0; }
.resource h4 { margin: 0; font-size: var(--t-sm); font-weight: 600; color: var(--text-3); }
.usage { display: flex; flex-direction: column; gap: var(--s-1); min-width: 0; }
.usage-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-3); min-width: 0; }
.usage-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usage-value.ok { color: var(--ok); }
.usage-value.warn { color: var(--warn); }
.usage-value.danger { color: var(--danger); }
.meter { height: 8px; border-radius: 999px; overflow: hidden; background: var(--surface-sunken); }
.meter > span { display: block; height: 100%; border-radius: inherit; background: var(--ok); transition: width var(--dur) var(--ease); }
.meter.warn > span { background: var(--warn); }
.meter.danger > span { background: var(--danger); }

/* ---------------------------------------------------------------- narrow windows */

/* A tablet held upright, a narrow window: what no longer fits on one line
   wraps, and a table keeps its columns and scrolls inside its own frame
   rather than squeezing its main column down to a letter. */
@media (max-width: 860px) {
  table.data.fixed { min-width: 680px; }
  /* A table that stacks (dataTable's stack, the default): each row a card,
     its title cell on top and the others under their names, wrapping --
     nothing waits off to the right for a swipe nobody knows to make. */
  table.data.stack-rows, table.data.stack-rows tbody { display: block; }
  table.data.stack-rows.fixed { min-width: 0; table-layout: auto; }
  table.data.stack-rows thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  table.data.stack-rows tbody tr { display: flex; flex-direction: column; padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line); }
  table.data.stack-rows tbody tr:last-child { border-bottom: 0; }
  table.data.stack-rows td { display: flex; align-items: baseline; gap: var(--s-3); width: auto; height: auto; min-width: 0; padding: 3px 0; border-bottom: 0; text-align: left; overflow: visible; overflow-wrap: anywhere; }
  table.data.stack-rows td.stack-title { order: -1; flex-direction: column; align-items: stretch; gap: 2px; padding-bottom: var(--s-2); }
  table.data.stack-rows td:not(.stack-title)[data-label]::before { content: attr(data-label); flex: 0 0 84px; color: var(--text-3); font-size: var(--t-xs); }
  table.data.stack-rows td > * { min-width: 0; }
  table.data.stack-rows td .cell-main, table.data.stack-rows td .cell-sub { white-space: normal; overflow-wrap: anywhere; }
  table.data.stack-rows td.nowrap { white-space: normal; }
  table.data.stack-rows td .cell-actions { justify-content: flex-start; padding-top: var(--s-2); }
  .card-head { flex-wrap: wrap; }
  .card-head > :first-child { flex: 1 1 200px; min-width: 0; }
  .search { flex: 1 1 100%; max-width: none; min-width: 0; }
  .result-line { margin-left: 0; }
  .list-meta, .pager { flex-wrap: wrap; }
  .setting { flex-wrap: wrap; gap: var(--s-3); }
  .setting-text { flex: 1 1 220px; }
  /* Wrapped onto its own line, the answer is as wide as the line at most. */
  .setting-control { flex: 0 1 auto; min-width: 0; max-width: 100%; }
  .segmented { max-width: 100%; overflow-x: auto; }
  .drawer-head { padding: var(--s-4) var(--s-4) var(--s-3); }
  .drawer-body { padding: var(--s-4) var(--s-4) var(--s-6); gap: var(--s-5); }
  .drawer-foot { padding: var(--s-3) var(--s-4); flex-wrap: wrap; }
}

/* A phone. */
@media (max-width: 600px) {
  /* Below 16px a phone's browser zooms the page into every field it focuses. */
  input:not([type="checkbox"]):not([type="radio"]), select, textarea { font-size: 16px; }
  .form-row { grid-template-columns: minmax(0, 1fr); }
  .field.inline { flex-direction: column; align-items: stretch; gap: 6px; }
  .field.inline > .label { flex: none; }
  .card-head { padding: var(--s-4) var(--s-4) 0; }
  .card-body { padding: var(--s-3) var(--s-4) var(--s-4); }
  .card-body.flush { padding: 0; }
  .modal-wrap { padding: var(--s-2); }
  .modal { max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); }
  .modal-head { padding: var(--s-4) var(--s-4) 0; }
  .modal-body { padding: var(--s-3) var(--s-4); }
  .modal-foot { padding: var(--s-3) var(--s-4) var(--s-4); flex-wrap: wrap; }
  .toasts { left: var(--s-3); right: var(--s-3); bottom: var(--s-3); align-items: stretch; }
  .toast { max-width: none; }
  .popover { max-width: calc(100vw - 16px); }
  /* Dividers part groups on one line; wrapped, they start lines instead. */
  .filterbar .divider { display: none; }
  .facts { grid-template-columns: minmax(84px, max-content) minmax(0, 1fr); gap: var(--s-2) var(--s-3); }
  .empty { padding: var(--s-8) var(--s-4); }
}

/* Buttons at the end of a row. */
.cell-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* A day's bar lightens under the pointer, so the hover title has a subject. */
.bar-slot rect[fill]:not([fill="transparent"]) { transition: filter var(--dur-fast) var(--ease); }
.bar-slot:hover rect[fill]:not([fill="transparent"]) { filter: brightness(1.15) saturate(1.05); }

/* A phone: the figures two by two, compact, so the overview's four tiles
   take one screen rather than four. Only grids made of tiles. */
@media (max-width: 600px) {
  .grid.cols-3:has(> .kpi), .grid.cols-4:has(> .kpi) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
  .kpi { padding: var(--s-4); gap: 6px; }
  .kpi .kpi-value { font-size: 24px; }
  .kpi .kpi-label { font-size: var(--t-xs); flex-wrap: wrap; }
  .kpi .kpi-icon { width: 24px; height: 24px; border-radius: 7px; }
  .kpi .kpi-foot { flex-wrap: wrap; gap: 6px; }
}


/* =========================================================
   MINOSS AI GUARD COMPONENT OVERRIDES
========================================================= */

button, .button,
input, select, textarea,
.search, .tags, .segmented, .copy-row {
  border-radius: 6px;
}

button, .button {
  border-color: var(--line-strong);
  background: var(--surface-2);
}
button:hover:not(:disabled), a.button:hover { background: var(--surface-3-hover); }

button.primary {
  background: #1765c7;
  border-color: #2776d7;
  box-shadow: 0 5px 14px rgba(20, 91, 178, .18);
}
button.primary:hover:not(:disabled) {
  background: #2177dc;
  border-color: #3c8af0;
}

input, select, textarea,
.search, .tags {
  background: var(--surface-sunken);
  border-color: var(--line-strong);
}
input:focus, select:focus, textarea:focus,
.search:focus-within, .tags:focus-within {
  border-color: #2d72b9;
  box-shadow: 0 0 0 3px rgba(38, 118, 201, .10);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--card-shadow);
  overflow: hidden;
}
.card-head {
  min-height: 48px;
  padding: 14px 15px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.card-head h2 {
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
}
.card-body { padding: 15px; }

.kpi {
  border-radius: 10px;
  background: var(--surface);
  border-color: var(--line);
  box-shadow: var(--card-shadow);
  padding: 18px;
}
.kpi .kpi-label { color: var(--text-2); font-weight: 600; }
.kpi .kpi-value {
  color: var(--text);
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -1px;
}
.kpi .kpi-icon {
  border-radius: 8px;
  background: color-mix(in srgb, var(--kpi-tone) 14%, transparent);
}
button.kpi:hover:not(:disabled) {
  background: var(--surface);
  border-color: color-mix(in srgb, var(--kpi-tone) 45%, var(--line-strong));
}

.badge {
  min-height: 22px;
  border: 1px solid transparent;
}
.badge.block, .badge.danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
}
.badge.mask, .badge.warn {
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 45%, transparent);
}
.badge.ok {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 45%, transparent);
}
.badge.info {
  color: var(--info);
  border-color: color-mix(in srgb, var(--info) 45%, transparent);
}

.table-frame {
  border-color: var(--line);
  border-radius: 8px;
  background: var(--surface);
}
table.data th {
  background: var(--surface-2);
  color: var(--text-2);
  border-bottom-color: var(--line-strong);
}
table.data td { border-bottom-color: color-mix(in srgb, var(--line-strong) 70%, transparent); }
table.data tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-sunken) 55%, transparent); }
table.data tbody tr.clickable:hover { background: var(--surface-hover); }
table.data tbody tr.selected {
  background: color-mix(in srgb, var(--accent) 15%, var(--surface));
  box-shadow: inset 3px 0 0 var(--accent-hover);
}

.popover {
  background: var(--surface-2);
  border-color: var(--line-strong);
  border-radius: 7px;
}
.drawer {
  background: var(--surface);
  border-left-color: var(--line-strong);
}
.modal {
  background: var(--surface);
  border-color: var(--line-strong);
  border-radius: 12px;
}
.toast {
  background: var(--surface-2);
  border-color: var(--line-strong);
}

.tabs { border-bottom-color: var(--line); }
.tabs a.on, .tabs button.on {
  border-bottom-color: var(--accent-hover);
  color: var(--text);
}
.tabs a.on svg, .tabs button.on svg { color: var(--accent-hover); }

.rank-row:hover { background: var(--surface-hover); }
.rank-row .bar { background: var(--surface-sunken); }
.rank-row .bar > i { background: var(--accent-hover); }

.health {
  background: transparent;
  border-color: var(--line-strong);
}
.avatar {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

:root[data-theme="dark"] .account,
:root:not([data-theme]) .account { color: #ffffff; }
