/* illyusion File Monitoring — dashboard stylesheet.
   A dark security-operations theme: one accent, status colours reserved
   for state. Everything is a class: the page's CSP forbids inline styles. */

:root {
  color-scheme: dark;
  --bg: #0d1117;
  --bg-elev: #121923;
  --surface: #161e2a;
  --surface-2: #1c2634;
  --line: #273243;
  --line-strong: #37475c;
  --fg: #e6edf3;
  --muted: #8b9bb0;
  --accent: #62a8ff;
  --accent-strong: #2f7fe0;
  --ok: #3fb950;
  --warn: #e3b341;
  --bad: #f85149;
  --info: #a371f7;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 8px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 15px; }
p { margin: 0 0 10px; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.ok-text { color: var(--ok); }
.warn-text { color: var(--warn); }
.bad-text { color: var(--bad); }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 8px; top: 8px; background: var(--surface); padding: 6px 10px; z-index: 50; }
.offscreen { position: fixed; left: -9999px; top: 0; }

/* Layout */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--line);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px; }
.brand-large { padding-bottom: 10px; }
.brand-mark { color: var(--accent); font-size: 20px; }
.brand-name { font-weight: 700; letter-spacing: 0.02em; }
.brand-sub { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  color: var(--fg); padding: 9px 10px; border-radius: var(--radius);
  font-weight: 500;
}
.nav-item:hover { background: var(--surface); text-decoration: none; }
.nav-item.active { background: var(--surface-2); color: var(--accent); }
.nav-icon { width: 18px; text-align: center; color: var(--muted); }
.nav-item.active .nav-icon { color: var(--accent); }
.main-col { min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 24px; border-bottom: 1px solid var(--line);
  background: var(--bg-elev); position: sticky; top: 0; z-index: 5;
}
.page-title { font-size: 18px; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.menu-btn { display: none; background: none; border: 1px solid var(--line); color: var(--fg); border-radius: 6px; padding: 4px 8px; font-size: 16px; }
.content { padding: 22px 24px 60px; max-width: 1500px; }

/* Cards, tiles, grids */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.card-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-body { padding: 14px 16px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; border-left-width: 4px; color: var(--fg); }
.tile-link:hover { text-decoration: none; border-color: var(--line-strong); }
.tile-neutral { border-left-color: var(--line-strong); }
.tile-ok { border-left-color: var(--ok); }
.tile-warn { border-left-color: var(--warn); }
.tile-bad { border-left-color: var(--bad); }
.tile-value { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; }
.tile-label { color: var(--muted); font-size: 12px; margin-top: 2px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; }
.grid-2 .card, .grid-3 .card { margin-bottom: 0; }
.grid-2, .grid-3 { margin-bottom: 18px; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table td.mono { white-space: nowrap; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: rgba(255, 255, 255, 0.025); }
.row-pending td { background: rgba(227, 179, 65, 0.06); }
.row-disabled td { opacity: 0.6; }
.th-sort { background: none; border: none; color: inherit; font: inherit; text-transform: inherit; letter-spacing: inherit; padding: 0; cursor: pointer; }
.th-sort:hover { color: var(--fg); }

/* Badges, tags, dots */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; border: 1px solid transparent; }
.badge-pending { color: var(--warn); border-color: rgba(227, 179, 65, 0.5); background: rgba(227, 179, 65, 0.12); }
.badge-active { color: var(--ok); border-color: rgba(63, 185, 80, 0.5); background: rgba(63, 185, 80, 0.12); }
.badge-suspended { color: var(--muted); border-color: var(--line-strong); background: var(--surface-2); }
.badge-revoked { color: var(--bad); border-color: rgba(248, 81, 73, 0.5); background: rgba(248, 81, 73, 0.12); }
.badge-health-healthy { color: var(--ok); border-color: rgba(63, 185, 80, 0.5); }
.badge-health-degraded { color: var(--warn); border-color: rgba(227, 179, 65, 0.5); }
.badge-health-unhealthy { color: var(--bad); border-color: rgba(248, 81, 73, 0.5); }
.badge-health-unknown { color: var(--muted); border-color: var(--line-strong); }
.tags { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 4px; font-family: var(--mono); font-size: 11px; background: var(--surface-2); border: 1px solid var(--line-strong); }
.tag-read { color: var(--accent); }
.tag-write, .tag-modify { color: var(--warn); }
.tag-delete { color: var(--bad); }
.tag-execute { color: var(--info); }
.tag-permission_change { color: #ff9f5a; }
.tag-action { color: var(--info); }
.tag-platform { color: var(--muted); }
.tag-noise { color: var(--muted); margin-left: 6px; opacity: .85; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: middle; }
.dot-on { background: var(--ok); box-shadow: 0 0 6px rgba(63, 185, 80, 0.8); }
.dot-off { background: var(--line-strong); }
.warn-mark { color: var(--warn); cursor: help; }

/* Buttons & forms */
.btn { font: inherit; font-weight: 500; padding: 7px 13px; border-radius: 6px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--fg); cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); }
.btn-danger { background: rgba(248, 81, 73, 0.12); border-color: rgba(248, 81, 73, 0.6); color: var(--bad); }
.btn-danger:hover { background: rgba(248, 81, 73, 0.25); }
.btn-ghost { background: transparent; }
.btn.small { padding: 4px 9px; font-size: 12px; margin-right: 4px; }
.btn.wide { width: 100%; margin-top: 6px; }
.input { font: inherit; width: 100%; padding: 8px 10px; border-radius: 6px; border: 1px solid var(--line-strong); background: var(--bg); color: var(--fg); }
.input:focus { border-color: var(--accent); outline: none; }
.input.search { max-width: 320px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field-label { color: var(--muted); font-size: 12px; }
.check { display: inline-flex; align-items: center; gap: 6px; padding: 6px 0; font-family: var(--mono); font-size: 12.5px; }
.check-row { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar-split { justify-content: flex-start; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font: inherit; font-size: 12.5px; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line-strong); background: transparent; color: var(--muted); cursor: pointer; }
.chip.active { color: var(--fg); background: var(--surface-2); border-color: var(--accent); }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; padding: 14px 16px; align-items: end; }
.filters-actions { display: flex; gap: 8px; }
.rule-form { display: flex; flex-direction: column; gap: 10px; padding: 12px; border: 1px dashed var(--line-strong); border-radius: var(--radius); margin-bottom: 14px; background: var(--bg); }
.rule-form-row { display: flex; gap: 14px; align-items: end; flex-wrap: wrap; }
.rule-form-row .field:first-child { flex: 1 1 320px; }
.kvs { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; }
.kvs.compact { margin-top: 12px; font-size: 12.5px; }
.kv { display: contents; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.detail-title { font-size: 20px; display: flex; align-items: center; gap: 8px; }
.health-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.problems, .warnings, .steps { margin: 0 0 8px; padding-left: 18px; }
.problem-unhealthy { color: var(--bad); }
.problem-degraded { color: var(--warn); }
.warnings { background: rgba(227, 179, 65, 0.08); border: 1px solid rgba(227, 179, 65, 0.4); border-radius: var(--radius); padding: 10px 10px 10px 28px; margin-bottom: 14px; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; gap: 10px; flex-wrap: wrap; }
.pager-buttons { display: flex; gap: 8px; }
.command { display: flex; gap: 8px; align-items: flex-start; margin: 8px 0 12px; }
.command-text { flex: 1; margin: 0; padding: 10px 12px; background: var(--bg); border: 1px solid var(--line-strong); border-radius: 6px; white-space: pre-wrap; word-break: break-all; }

/* States */
.state { padding: 24px; text-align: center; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--radius); display: flex; justify-content: center; align-items: center; gap: 10px; }
.state.compact { padding: 12px; }
.state-error { color: var(--bad); border-color: rgba(248, 81, 73, 0.5); background: rgba(248, 81, 73, 0.06); border-style: solid; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; display: inline-block; }
.spinner.small { width: 12px; height: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Modal & toast */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 16px; }
.modal { background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 20px; max-width: 460px; width: 100%; box-shadow: var(--shadow); }
.modal h2 { margin-bottom: 8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.toast { position: fixed; right: 20px; bottom: 20px; background: var(--surface-2); border: 1px solid var(--ok); color: var(--fg); padding: 10px 14px; border-radius: var(--radius); box-shadow: var(--shadow); z-index: 30; max-width: 420px; display: flex; gap: 10px; align-items: center; }
.toast-error { border-color: var(--bad); }
.toast-close { background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; line-height: 1; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login { width: 100%; max-width: 380px; padding: 26px; display: flex; flex-direction: column; gap: 12px; }
.login h1 { font-size: 17px; }

/* Responsive */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: 240px; transform: translateX(-100%); transition: transform 0.15s ease; z-index: 10; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: inline-block; }
  .content { padding: 16px; }
  .topbar { padding: 10px 16px; }
  .topbar-right .muted { display: none; }
}

/* Escalation severity tags (events flag + escalation table) */
.sevtag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 10px; font-weight: 600; color: #fff; white-space: nowrap; letter-spacing: .02em; }
.sevtag.lvl-critical { background: #6a040f; }
.sevtag.lvl-high { background: #c0392b; }
.sevtag.lvl-medium { background: #e67e22; }
.sevtag.lvl-low { background: #2e86c1; }
.sevtag.lvl-informational { background: #7f8c8d; }
.esc-flag { margin-left: 6px; }
