/*
 * FW-GUI stylesheet.
 *
 * Two themes share one set of components. Colours, radii and type live in
 * custom properties scoped by the data-theme attribute on <html>:
 *   dark  - graphite console, amber accent
 *   light - white surfaces, navy bar, blue accent
 * Pages shown before login, or to an account with no theme yet, use dark.
 * Components below this block must only use the tokens, never literal
 * colours, so that both themes stay complete.
 */

/* ------------------------------------------------------------------ */
/* Tokens                                                              */
/* ------------------------------------------------------------------ */
:root {
    --fs: 13px;
    --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, sans-serif;
    --mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, "Ubuntu Mono", monospace;
    --bar-h: 44px;
    --nav-w: 208px;
    --brand: #ffbf12;
    --brand-text: #15171a;
}

:root,
[data-theme="dark"] {
    color-scheme: dark;
    --r: 2px;
    --bg: #15171a;
    --panel: #1b1e22;
    --panel-head: #1f2328;
    --nav-bg: #181a1e;
    --text: #d6d9de;
    --heading: #eef0f3;
    --muted: #848b96;
    --line: #2a2e34;
    --line-strong: #3a3f47;
    --row-line: #23272c;
    --hover: #22262b;
    --accent: #ffbf12;
    --accent-hover: #ffcc3d;
    --accent-text: #15171a;
    --focus: rgba(255, 191, 18, 0.25);
    --link: #e8b43a;
    --bar-bg: #101215;
    --bar-text: #eef0f3;
    --bar-muted: #8d94a0;
    --bar-line: #2a2e34;
    --bar-field: #1d2024;
    --nav-text: #b5bac2;
    --nav-active-text: #ffffff;
    --nav-active-bg: #22262b;
    --btn-bg: #22262b;
    --btn-line: #343940;
    --th: #8d94a0;
    --th-bg: #1b1e22;
    --chip-bg: #202429;
    --input-bg: #121417;
    --input-line: #343940;
    --seg-on: rgba(255, 191, 18, 0.14);
    --seg-on-text: #ffcc3d;
    --code-bg: #121417;
    --ok: #4cc38a;
    --ok-bg: rgba(76, 195, 138, 0.10);
    --danger: #e5484d;
    --danger-bg: rgba(229, 72, 77, 0.10);
    --warn: #f0a43a;
    --warn-bg: rgba(240, 164, 58, 0.12);
    --info: #5b9df5;
    --info-bg: rgba(91, 157, 245, 0.12);
    --ref: #7fb1f5;
    --nav-group: #e8b43a;
    --nav-group-line: #2a2e34;
    --icon: #c9ced6;
    --v4: #2fc6d6;
    --v4-bg: rgba(47, 198, 214, 0.12);
    --v6: #b197fc;
    --v6-bg: rgba(177, 151, 252, 0.13);
    --if-public_wan: #f0565c;
    --if-private_wan: #f59e42;
    --if-lan: #4cc38a;
    --if-dmz: #f5c518;
    --if-c-blue: #5b9df5;
    --if-c-pink: #f06595;
    --if-c-brown: #c4925a;
    --if-c-gray: #9aa1ab;
}

[data-theme="light"] {
    /* "Framed" (4.1.12): gray canvas, white bordered panels, tinted headers,
       darker ink; the top bar matches the dark theme. */
    color-scheme: light;
    --r: 4px;
    --bg: #dde1e7;
    --panel: #ffffff;
    --panel-head: #e9edf2;
    --nav-bg: #f7f8fa;
    --text: #141a22;
    --heading: #0b1220;
    --muted: #4a5260;
    --line: #b3bcc8;
    --line-strong: #8f9aa8;
    --row-line: #d9dee5;
    --hover: #e6eefb;
    --accent: #2463eb;
    --accent-hover: #1d55cf;
    --accent-text: #ffffff;
    --focus: rgba(36, 99, 235, 0.2);
    --link: #2463eb;
    --bar-bg: #101215;
    --bar-text: #eef0f3;
    --bar-muted: #8d94a0;
    --bar-line: #2a2e34;
    --bar-field: #1d2024;
    --nav-text: #1f2733;
    --nav-active-text: #1b2a41;
    --nav-active-bg: #dfe8fb;
    --btn-bg: #ffffff;
    --btn-line: #aab3bf;
    --th: #2f3743;
    --th-bg: #e1e5eb;
    --chip-bg: #e9ecf0;
    --input-bg: #ffffff;
    --input-line: #aab3bf;
    --seg-on: #2463eb;
    --seg-on-text: #ffffff;
    --code-bg: #fbfcfd;
    --ok: #18794e;
    --ok-bg: #e9f6ef;
    --danger: #c8302f;
    --danger-bg: #fdeceb;
    --warn: #a35a00;
    --warn-bg: #fff4e0;
    --info: #2463eb;
    --info-bg: #eaf0fd;
    --ref: #2463eb;
    --nav-group: #2463eb;
    --nav-group-line: #d3d8df;
    --icon: #252c36;
    --v4: #0891b2;
    --v4-bg: #e0f6fa;
    --v6: #6d28d9;
    --v6-bg: #f1ebfd;
    --if-public_wan: #c8302f;
    --if-private_wan: #ea580c;
    --if-lan: #18794e;
    --if-dmz: #ca8a04;
    --if-c-blue: #2463eb;
    --if-c-pink: #c2255c;
    --if-c-brown: #8a5a2b;
    --if-c-gray: #5b6472;
}

/* ------------------------------------------------------------------ */
/* Base                                                                */
/* ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html {
    font-size: var(--fs);
    line-height: 1.45;
    background: var(--bg);
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4, h5 { color: var(--heading); font-weight: 600; }
ul { list-style: none; }
code, pre, .mono { font-family: var(--mono); }
.mono { font-size: 0.95em; }
.small { font-size: 0.88em; }
.muted { color: var(--muted); }
.strong { font-weight: 600; }
.center { text-align: center; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------------ */
/* Top bar                                                             */
/* ------------------------------------------------------------------ */
.topbar {
    height: var(--bar-h);
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 0 16px;
    background: var(--bar-bg);
    color: var(--bar-text);
    border-bottom: 1px solid var(--bar-line);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: calc(var(--nav-w) - 16px);
    color: var(--bar-text);
}
.brand:hover { text-decoration: none; }
.brand b { font-weight: 700; letter-spacing: 0.02em; }
.brand-sub { color: var(--bar-muted); font-size: 0.9em; }

.logo {
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: var(--r);
    background: var(--brand);
    color: var(--brand-text);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.02em;
}

.cfg { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.cfg-form { display: flex; align-items: center; gap: 10px; margin: 0; }
.cfg-label {
    color: var(--bar-muted);
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.cfg-select {
    font: inherit;
    font-weight: 600;
    height: 26px;
    padding: 0 8px;
    max-width: 260px;
    border: 1px solid var(--bar-line);
    border-radius: var(--r);
    background: var(--bar-field);
    color: var(--bar-text);
}

.cfg-link { display: inline-flex; align-items: center; }
.cfg-link:hover { text-decoration: none; border-color: var(--bar-muted); }
.user { display: flex; align-items: center; gap: 16px; color: var(--bar-muted); }
.user a { color: var(--bar-muted); }
.user a:hover { color: var(--bar-text); text-decoration: none; }
.user-name { color: var(--bar-text); font-weight: 600; }

.theme-switch {
    display: inline-flex;
    border: 1px solid var(--bar-line);
    border-radius: var(--r);
    overflow: hidden;
}
.theme-switch button {
    font: inherit;
    font-size: 0.88em;
    border: 0;
    background: transparent;
    color: var(--bar-muted);
    padding: 3px 10px;
    cursor: pointer;
}
.theme-switch button:hover { color: var(--bar-text); }
.theme-switch button[aria-pressed="true"] {
    background: var(--bar-field);
    color: var(--bar-text);
    font-weight: 600;
}

/* ------------------------------------------------------------------ */
/* First-login theme chooser                                           */
/* ------------------------------------------------------------------ */
.chooser-page { display: grid; place-items: center; padding: 40px 16px; }
.chooser {
    width: min(860px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 24px 28px;
}
.chooser .brand { color: var(--heading); min-width: 0; }
.chooser h1 { font-size: 1.5em; margin: 14px 0 4px; }
.chooser .lead { margin-bottom: 18px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.tile {
    position: relative;
    display: block;
    cursor: pointer;
    border: 2px solid var(--line);
    border-radius: 6px;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
}
.tile:hover { border-color: var(--line-strong); }
.tile input { position: absolute; opacity: 0; }
.tile:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.tile:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--focus); }
.tile-cap {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border-top: 1px solid var(--line);
    background: var(--panel);
}
.tile-cap b { font-size: 1.05em; color: var(--heading); }
.tile-cap span { color: var(--muted); font-size: 0.88em; }
.tick { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--line-strong); display: inline-block; }
.tile:has(input:checked) .tick { border-color: var(--accent); background: radial-gradient(var(--accent) 45%, transparent 50%); }
.m-bar { display: flex; align-items: center; gap: 6px; height: 26px; padding: 0 8px; background: var(--bar-bg); color: var(--bar-text); font-size: 10px; }
.m-bar .logo { width: 14px; height: 14px; font-size: 6px; }
.m-cfg { margin-left: 10px; border: 1px solid var(--bar-line); padding: 0 6px; border-radius: var(--r); color: var(--bar-muted); }
.m-body { display: grid; grid-template-columns: 70px 1fr; height: 170px; }
.m-nav { background: var(--nav-bg); border-right: 1px solid var(--line); padding: 10px 0; }
.m-nav i { display: block; height: 6px; margin: 7px 10px; border-radius: 2px; background: var(--line-strong); }
.m-nav i.on { background: var(--accent); }
.m-main { padding: 8px 10px; font-size: 10px; }
.m-title { font-family: var(--mono); font-weight: 700; color: var(--heading); margin-bottom: 5px; }
.m-row { display: grid; grid-template-columns: 22px 1fr 52px 70px; align-items: center; gap: 6px; padding: 3px 4px; border-bottom: 1px solid var(--row-line); background: var(--panel); }
.m-row .act { min-width: 0; font-size: 7.5px; padding: 0 3px; }
.m-num { font-family: var(--mono); color: var(--muted); text-align: right; }
.m-mono { font-family: var(--mono); color: var(--muted); }
.m-btn { display: inline-block; margin-top: 7px; padding: 2px 8px; border-radius: var(--r); background: var(--accent); color: var(--accent-text); font-weight: 600; }

/* ------------------------------------------------------------------ */
/* Shell: nav + main                                                   */
/* ------------------------------------------------------------------ */
.shell {
    display: grid;
    grid-template-columns: var(--nav-w) minmax(0, 1fr);
    flex: 1;
}
.shell-bare { grid-template-columns: minmax(0, 1fr); }

.nav {
    background: var(--nav-bg);
    border-right: 1px solid var(--line);
    padding: 10px 0 24px;
    font-size: 0.95em;
}
.nav-group {
    margin-top: 10px;
    padding: 10px 16px 4px;
    border-top: 1px solid var(--nav-group-line);
    color: var(--nav-group);
    font-size: 0.78em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.nav > .nav-group:first-child { margin-top: 0; border-top: 0; padding-top: 4px; }
.nav-item {
    display: block;
    padding: 5px 16px;
    color: var(--nav-text);
    border-left: 2px solid transparent;
}
.nav-item:hover { background: var(--hover); text-decoration: none; }
.nav-item.active {
    color: var(--nav-active-text);
    background: var(--nav-active-bg);
    border-left-color: var(--accent);
    font-weight: 600;
}

.main { padding: 16px 20px 40px; min-width: 0; }

.foot {
    padding: 8px 16px;
    border-top: 1px solid var(--line);
    background: var(--nav-bg);
    color: var(--muted);
    font-size: 0.82em;
}

/* ------------------------------------------------------------------ */
/* Page header, headings                                               */
/* ------------------------------------------------------------------ */
.page-head,
.view-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 12px;
}
.page-head h2,
.view-header .section-title,
.form-header .section-title {
    font-size: 1.45em;
    letter-spacing: -0.01em;
    margin: 0;
    padding: 0;
    border: 0;
    text-transform: none;
    color: var(--heading);
}
.page-actions { display: flex; gap: 6px; }
.crumb { color: var(--muted); font-size: 0.85em; }
.lead, .form-description, .config-description { color: var(--muted); max-width: 80ch; }

.section-title {
    font-size: 1.15em;
    color: var(--heading);
    margin: 0 0 10px;
}
.subsection-title {
    font-size: 0.78em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--th);
    margin: 14px 0 6px;
}

/* ------------------------------------------------------------------ */
/* Tabs                                                                */
/* ------------------------------------------------------------------ */
.tabs {
    display: flex;
    align-items: flex-start;
    gap: 0 22px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 14px;
}
.tab {
    padding: 6px 12px;
    color: var(--muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    font-weight: 500;
}
/* One IP version's tabs. Each group wraps to its own row as a unit when
   the versions do not fit on one line, and wraps internally only if a
   single version is wider than the page. */
.tab-groups { display: flex; flex-wrap: wrap; gap: 0 22px; flex: 1; min-width: 0; }
.tab-group { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--heading); border-bottom-color: var(--accent); }
.tab-sep {
    min-width: 34px;
    padding: 4px 8px;
    margin-right: 2px;
    border-radius: var(--r);
    font-size: 0.75em;
    font-weight: 700;
    color: var(--muted);
    letter-spacing: 0.08em;
}

/* ------------------------------------------------------------------ */
/* Buttons                                                             */
/* ------------------------------------------------------------------ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font: inherit;
    font-size: 0.92em;
    font-weight: 500;
    line-height: 1;
    height: 28px;
    padding: 0 12px;
    border-radius: var(--r);
    border: 1px solid var(--btn-line);
    background: var(--btn-bg);
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
}
.btn:hover { border-color: var(--line-strong); background: var(--hover); text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--focus); border-color: var(--accent); }
.btn-sm { height: 24px; padding: 0 8px; font-size: 0.85em; }
.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-text);
    font-weight: 600;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #ffffff;
    font-weight: 600;
}
.btn-danger:hover { background: var(--danger); filter: brightness(1.08); }
.btn-success { background: var(--ok); border-color: var(--ok); color: #ffffff; }
.full-width { width: 100%; margin-bottom: 6px; }

/* Icon-sized row actions */
.ib {
    display: inline-grid;
    place-items: center;
    font: inherit;
    font-size: 1.1em;
    line-height: 1;
    width: 24px;
    min-width: 24px;
    height: 24px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--r);
    background: transparent;
    color: var(--icon);
    cursor: pointer;
    text-decoration: none;
}
.ib:hover { border-color: var(--btn-line); color: var(--text); background: var(--btn-bg); }
.icon { display: block; }
.ib .icon { transform: translateY(1px); }
.rename-icon .icon { display: inline-block; vertical-align: -2px; }
.ib:disabled { opacity: 0.3; cursor: default; pointer-events: none; }
.ib-danger:hover { color: var(--danger); border-color: var(--danger); background: transparent; }

/* ------------------------------------------------------------------ */
/* Blocks (panels)                                                     */
/* ------------------------------------------------------------------ */
.block {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r);
    margin-bottom: 14px;
}
.block-body, .block.pad { padding: 12px 14px; }
.block-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--line);
    background: var(--panel-head);
    border-radius: var(--r) var(--r) 0 0;
}
.block-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 14px; min-width: 0; }
.block-title h3 { font-size: 1.05em; }
.block-title h3.mono { font-size: 1.05em; }
.block-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.block-actions form { margin: 0; }
.meta { color: var(--muted); font-size: 0.88em; }
.meta b { color: var(--text); font-weight: 600; }
.block-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.block-grid > .block { margin-bottom: 0; }
.block-grid + .block-grid, .block-grid + .block { margin-top: 14px; }

/* ------------------------------------------------------------------ */
/* Data tables                                                         */
/* ------------------------------------------------------------------ */
table.grid { width: 100%; border-collapse: collapse; }
.grid th {
    text-align: left;
    font-weight: 600;
    font-size: 0.78em;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--th);
    padding: 6px 10px;
    border-bottom: 1px solid var(--line);
    background: var(--th-bg);
    white-space: nowrap;
}
.grid td {
    padding: 5px 10px;
    border-bottom: 1px solid var(--row-line);
    vertical-align: middle;
}
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tbody tr:hover { background: var(--hover); }
/* Light theme: striped rows and heavier headers. Cells carry the stripe, so
   hover is set on the cells too. */
[data-theme="light"] .grid tbody tr:nth-child(even):not(.default-row) > td { background: #f2f4f7; }
[data-theme="light"] .grid tbody tr:not(.default-row):hover > td { background: var(--hover); }
[data-theme="light"] .grid th { font-weight: 650; }
.grid .num { width: 56px; text-align: right; color: var(--muted); font-family: var(--mono); }
.grid td.nowrap, .grid td.mono { white-space: nowrap; }
.grid td.desc { min-width: 160px; }
.num-input {
    font: inherit;
    font-family: var(--mono);
    width: 64px;
    height: 22px;
    padding: 0 4px;
    text-align: right;
    border: 1px solid transparent;
    border-radius: var(--r);
    background: transparent;
    color: var(--muted);
    -moz-appearance: textfield;
}
.num-input::-webkit-inner-spin-button, .num-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.num-input:hover { border-color: var(--input-line); }
.num-input:focus { outline: none; border-color: var(--accent); background: var(--input-bg); color: var(--text); box-shadow: 0 0 0 2px var(--focus); }
.renumber-form { margin: 0; }
/* Chain rules: fixed columns so every chain's table lines up. */
/* Rule and group tables use fixed layout so every chain's columns line up.
   Columns with a fixed vocabulary (number, action, protocol, state, log,
   row actions) are sized for their longest value with headroom for wider
   system fonts; free-text columns wrap instead of truncating, so nothing is
   ever hidden. */
.grid.rules, .grid.rules-filter, .grid.groups { table-layout: fixed; }
.grid.rules td, .grid.rules-filter td, .grid.groups td { overflow-wrap: break-word; }
.grid.rules td.nowrap, .grid.rules-filter td.nowrap { white-space: nowrap; }
.grid.rules th:nth-child(1), .grid.rules-filter th:nth-child(1) { width: 88px; }   /* # (999999) */
.grid.rules th:nth-child(3), .grid.rules-filter th:nth-child(3) { width: 112px; }  /* action: CONTINUE */
.grid.rules th:nth-child(4) { width: 96px; }                                       /* proto: tcp_udp */
.grid.rules th:nth-child(7) { width: 148px; }                                      /* state: EST REL NEW INV */
.grid.rules th:nth-child(8) { width: 56px; }                                       /* log */
.grid.rules th:nth-child(9), .grid.rules-filter th:nth-child(7) { width: 144px; }  /* row actions */
.grid.rules-filter th:nth-child(4) { width: 22%; }
.grid.rules-filter th:nth-child(5) { width: 14%; }
.grid.rules-filter th:nth-child(6) { width: 12%; }
.grid.groups th:nth-child(1) { width: 200px; }
.grid.groups th:nth-child(2) { width: 24%; }
.grid.groups th:nth-child(3) { width: 72px; }
.grid.groups th:nth-child(5) { width: 80px; }
/* Below these widths the free-text columns would be narrower than their
   headers; scroll the table inside its panel instead. */
.table-scroll { overflow-x: auto; }
.table-scroll > .grid.rules { min-width: 1020px; }
.table-scroll > .grid.rules-filter { min-width: 820px; }
.grid .chips { white-space: normal; }
.grid .col-name { width: 200px; }
.grid .col-type { width: 160px; }
.empty-state p { margin-bottom: 8px; }
.grid .row-actions { width: 1%; text-align: right; white-space: nowrap; }
.row-actions form { display: inline; margin: 0; }
/* Implicit default action: last row of a chain or filter, read-only */
.grid tr.default-row td { background: var(--panel-head); border-top: 1px dashed var(--line-strong); }
.grid tr.default-row:hover { background: transparent; }
.default-mark { font-family: var(--font); font-size: 0.72em; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.default-lock { display: inline-block; width: 22px; text-align: center; font-size: 0.85em; opacity: 0.45; filter: grayscale(1); }
.grid tr.empty-rules td { color: var(--muted); font-style: italic; text-align: center; padding: 10px; }
.grid tr.is-disabled td { opacity: 0.5; }
.grid tr.is-disabled td.desc { opacity: 0.75; }

.ref {
    font-family: var(--mono);
    font-size: 0.92em;
    color: var(--ref);
    border-bottom: 1px dotted var(--ref);
}
.ref[data-ref] { cursor: help; }
.ref[data-ref]:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

/* Group detail card, shown by ref-cards.js on hover/focus of a .ref */
.ref-popover {
    position: fixed;
    z-index: 50;
    width: max-content;
    min-width: 220px;
    max-width: 360px;
    background: var(--panel);
    border: 1px solid var(--line-strong);
    border-radius: var(--r);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
    pointer-events: none;
}
.ref-card-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px 2px; }
.ref-card-meta { padding: 0 10px 6px; color: var(--muted); font-size: 0.88em; }
.ref-card-desc { padding: 0 10px 6px; color: var(--text); }
.ref-card-scroll { border-top: 1px solid var(--line); max-height: 260px; overflow: auto; }
.ref-card-values td { padding: 3px 10px; }
.ref-card-values .num { width: 32px; }
.yes { color: var(--ok); }
/* A table cell value that toggles on click (chain view Log column). */
.toggle-form { display: inline; margin: 0; }
.cell-toggle { background: none; border: 0; padding: 0 4px; font: inherit; color: inherit; cursor: pointer; border-radius: 4px; }
.cell-toggle:hover, .cell-toggle:focus-visible { background: var(--btn-bg); }
.chip {
    display: inline-block;
    font-family: var(--mono);
    font-size: 0.85em;
    padding: 0 6px;
    margin: 1px 2px 1px 0;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--chip-bg);
    color: var(--text);
    white-space: nowrap;
}

/* Action and status badges */
.act {
    display: inline-block;
    min-width: 58px;
    font-size: 0.78em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 1px 6px;
    border-radius: var(--r);
    color: var(--muted);
    background: var(--chip-bg);
    text-align: center;
}
.act-accept, .act-continue { color: var(--ok); background: var(--ok-bg); }
.act-drop { color: var(--danger); background: var(--danger-bg); }
.act-reject { color: var(--warn); background: var(--warn-bg); }
.act-jump, .act-return, .act-offload, .act-queue { color: var(--info); background: var(--info-bg); }

.pill {
    display: inline-block;
    font-size: 0.78em;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: var(--r);
    white-space: nowrap;
}
.pill-off {
    color: var(--muted);
    border: 1px solid var(--line-strong);
    margin-left: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.7em;
}
.pill-ok { color: var(--ok); background: var(--ok-bg); }
.pill-warn { color: var(--warn); background: var(--warn-bg); }
.pill-danger { color: var(--danger); background: var(--danger-bg); }
.pill-info { color: var(--info); background: var(--info-bg); }
.tag {
    font-size: 0.72em;
    font-weight: 700;
    letter-spacing: 0.06em;
    padding: 1px 6px;
    border-radius: var(--r);
    border: 1px solid var(--line-strong);
    color: var(--muted);
    align-self: center;
}
/* IP version: teal for IPv4, violet for IPv6, wherever the version is shown */
a.tab-sep:hover { text-decoration: none; background: var(--hover); }
.tab-sep.active { background: var(--chip-bg); box-shadow: inset 0 -2px 0 var(--accent); }
.tab-sep-ipv4.active { background: var(--v4-bg); box-shadow: inset 0 -2px 0 var(--v4); }
.tab-sep-ipv6.active { background: var(--v6-bg); box-shadow: inset 0 -2px 0 var(--v6); }
.tag-ipv4, .tab-sep-ipv4 { color: var(--v4); }
.tag-ipv6, .tab-sep-ipv6 { color: var(--v6); }
/* Interface types: a coloured dot and outlined label. Deliberately never a
   filled badge, so red/orange/green interfaces don't read as drop, reject
   or accept actions. */
.iftype {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: var(--font);
    font-size: 0.82em;
    font-weight: 600;
    line-height: 18px;
    padding: 0 7px;
    color: var(--if);
    border: 1px solid var(--if);
    border-radius: 999px;
    white-space: nowrap;
}
.iftype .dot, .if-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--if); flex: none; }
.iftype-bare { border: 0; padding: 0; }
.if-name { display: inline-flex; align-items: center; gap: 6px; }
.chip-if { display: inline-flex; align-items: center; }
.chip-if .mono { font-size: 1em; }
.iftype-public_wan { --if: var(--if-public_wan); }
.iftype-private_wan { --if: var(--if-private_wan); }
.iftype-lan { --if: var(--if-lan); }
.iftype-dmz { --if: var(--if-dmz); }
.iftype-custom, .iftype-c-blue { --if: var(--if-c-blue); }
.iftype-c-pink { --if: var(--if-c-pink); }
.iftype-c-brown { --if: var(--if-c-brown); }
.iftype-c-gray { --if: var(--if-c-gray); }
.iftype-none { --if: var(--muted); }
/* Interface form: custom label and colour only apply to the Custom type */
.custom-type-fields { display: none; }
form:has(input[name="interface_type"][value="custom"]:checked) .custom-type-fields { display: block; }
.tag-ipv4 { background: var(--v4-bg); border-color: var(--v4); }
.tag-ipv6 { background: var(--v6-bg); border-color: var(--v6); }

/* Version sections on the chain, filter and group pages */
.version-section + .version-section { margin-top: 26px; }
.version-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 8px;
}
.version-head h3 {
    font-size: 1em;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--heading);
}
.version-ipv4 > .version-head h3 { color: var(--v4); }
.version-ipv6 > .version-head h3 { color: var(--v6); }

.empty-state {
    padding: 16px;
    text-align: center;
    color: var(--muted);
    background: var(--panel);
    border: 1px dashed var(--line-strong);
    border-radius: var(--r);
    margin-bottom: 14px;
}

/* ------------------------------------------------------------------ */
/* Forms                                                               */
/* ------------------------------------------------------------------ */
.input,
.form-input,
.form-select,
.form-textarea,
.form-file {
    font: inherit;
    font-size: 1em;
    width: 100%;
    height: 28px;
    padding: 0 8px;
    border: 1px solid var(--input-line);
    border-radius: var(--r);
    background: var(--input-bg);
    color: var(--text);
}
.form-textarea, textarea.input { height: auto; min-height: 160px; padding: 6px 8px; font-family: var(--mono); line-height: 1.5; }
.form-file { height: auto; padding: 4px; }
.input:focus,
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--focus);
}
.input::placeholder, .form-input::placeholder, .form-textarea::placeholder { color: var(--muted); opacity: 0.8; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }

fieldset,
.form-section {
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--panel);
    padding: 10px 14px 12px;
    margin-bottom: 12px;
}
legend,
.form-section > h3,
.form-section-title {
    font-size: 0.78em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--th);
}
legend { padding: 0 6px; margin-left: -6px; }
.form-section > h3, .form-section-title { margin: 0 0 8px; padding: 0; border: 0; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 8px 14px;
    align-items: start;
}
.field,
.form-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin: 0 0 8px;
}
.form-grid > .form-group { margin: 0; }
.form-grid > .form-section { margin-bottom: 0; }
.field.wide, .form-group.wide, .form-group.full-width { grid-column: 1 / -1; }
.field > span,
.form-label,
.field-label {
    font-size: 0.88em;
    color: var(--muted);
    font-weight: 500;
}
.form-help { font-size: 0.85em; color: var(--muted); }

.form-actions,
.form-foot {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
    padding-top: 6px;
}
.form-foot { justify-content: space-between; }
.form-foot.flush { padding-top: 0; }

.checkbox-label, .radio-label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }

/* ------------------------------------------------------------------ */
/* Form pages                                                          */
/* ------------------------------------------------------------------ */
.chain-form, .rule-form, .filter-form, .filter-rule-form, .flowtable-form,
.group-form, .extra-config, .snapshot-diff, .form-page { max-width: 1100px; }
.form-header, .config-header { display: block; margin-bottom: 12px; }
.form-header .section-title { margin-bottom: 4px; }
.section-description { color: var(--muted); max-width: 90ch; margin-bottom: 4px; }
.form-section > .subsection-title:first-child { margin-top: 0; }
.form-content > .form-section:last-of-type, .form > .form-section:last-of-type { margin-bottom: 0; }

/* Radio choices: a segmented control inside .radio-group, a plain list elsewhere */
.radio-item, .checkbox-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 0;
    cursor: pointer;
    color: var(--text);
}
.radio-group { display: flex; flex-wrap: wrap; gap: 4px; }
.radio-group .radio-item {
    padding: 3px 12px;
    color: var(--muted);
    background: var(--input-bg);
    border: 1px solid var(--input-line);
    border-radius: var(--r);
}
.radio-group .radio-item:hover { border-color: var(--line-strong); color: var(--text); }
.radio-group .radio-item input { position: absolute; opacity: 0; pointer-events: none; }
.radio-group .radio-item:has(input:checked) { background: var(--seg-on); border-color: var(--accent); color: var(--seg-on-text); font-weight: 600; }
.radio-group .radio-item:has(input:focus-visible) { box-shadow: inset 0 0 0 2px var(--focus); }
/* Chips whose label carries its own colour (interface types): mark the
   selection with an outline so the colour stays readable. */
.radio-group .radio-item:has(.iftype):has(input:checked) {
    background: var(--input-bg);
    border-color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent);
    color: var(--text);
}
.radio-group-vertical, .action-targets, .radio-column, .input-column {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.checkbox-grid, .checkbox-group { display: flex; flex-wrap: wrap; gap: 2px 18px; }
.field-description { color: var(--muted); font-size: 0.88em; margin-bottom: 4px; }

/* Group form: the IP version only applies to address and network groups */
.ip-version-group { opacity: 0.55; }
.ip-version-group.active { opacity: 1; }

/* Chain rule form: Source and Destination side by side, options below.
   The tab buttons and their script stay in the page but are not needed. */
.basic-config-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px 14px;
}
.basic-config-grid .form-group { margin: 0; }
.basic-config-grid .full-width { grid-column: span 2; margin: 0; }
.basic-config-grid .form-group:last-child { grid-column: span 3; }
.tabs-container { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px 0; }
.tabs-nav { display: none; }
.tab-content {
    display: block;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--panel);
    padding: 10px 14px 12px;
}
#advanced-tab { grid-column: 1 / -1; }
.tab-title {
    font-size: 0.78em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--th);
    margin: 0 0 8px;
}
.source-config, .destination-config { display: flex; flex-direction: column; gap: 12px; }
.config-row { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 10px; align-items: start; }
.config-grid, .advanced-config { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.state-column, .options-column { display: flex; flex-direction: column; gap: 8px; }

/* Small single-card forms (interface, hostname, login) */
.form-container { max-width: 560px; }
.form-card, .login-form {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 14px 16px;
}
.login-container { max-width: 380px; margin: 40px auto; }
.login-container .section-title { font-size: 1.45em; }
.register-link { margin-top: 10px; color: var(--muted); }

/* Snapshot diff chooser */
.snapshot-selectors { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.selector-group { display: flex; flex-direction: column; gap: 3px; min-width: 260px; }
.vs-indicator { color: var(--muted); font-weight: 700; padding-bottom: 6px; }

/* ------------------------------------------------------------------ */
/* Push to firewall                                                    */
/* ------------------------------------------------------------------ */
.config-push { max-width: 1200px; }
.push-header { margin-bottom: 12px; }
.push-header .section-title, .config-header .section-title { font-size: 1.45em; margin-bottom: 4px; }
.push-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 14px; margin-bottom: 14px; }
.connection-card, .auth-card, .deployment-card, .operational-section, .results-section, .config-preview {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 12px 14px;
}
.connection-card .subsection-title, .auth-card .subsection-title, .deployment-card .subsection-title,
.operational-section .subsection-title, .config-preview .subsection-title { margin-top: 0; }
.operational-section, .config-preview, .deployment-card { margin-bottom: 14px; }
.connection-status { border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 10px; }
.status-item {
    display: grid;
    grid-template-columns: 90px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    padding: 5px 10px;
    border-bottom: 1px solid var(--row-line);
}
.status-item:last-child { border-bottom: 0; }
.status-label { color: var(--muted); font-size: 0.88em; }
.status-value { font-family: var(--mono); font-size: 0.92em; display: flex; align-items: center; gap: 6px; }
.status-indicator { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.status-indicator.online { background: var(--ok); }
.status-indicator.offline { background: var(--danger); }
.hostname-form { margin-bottom: 8px; }
.auth-actions, .deployment-actions { display: flex; gap: 6px; justify-content: flex-end; padding-top: 4px; }
.option-help { display: block; color: var(--muted); font-size: 0.85em; margin-left: 22px; }
.checkbox-item:has(.option-help) { flex-wrap: wrap; }
.deployment-warning { padding: 7px 12px; border-left: 3px solid var(--warn); background: var(--warn-bg); border-radius: var(--r); margin-bottom: 10px; }
.deployment-options { margin-bottom: 8px; }
.operational-form { display: flex; align-items: flex-end; gap: 10px; }
.operational-form .form-group { flex: 1; margin: 0; }
.preview-toolbar, .results-toolbar, .config-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.config-size { color: var(--muted); font-size: 0.88em; }
.results-content {
    font-family: var(--mono);
    font-size: 0.92em;
    line-height: 1.5;
    background: var(--code-bg);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 10px 14px;
    margin: 0 0 14px;
    overflow-x: auto;
    white-space: pre;
}

/* Operational command output: toolbar, parsed tables (op-output.js) */
.op-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 4px 0 10px; }
.op-cmd { font-family: var(--mono); font-weight: 700; color: var(--heading); font-size: 1.05em; }
.op-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-left: auto; }
.op-tools .input { width: 220px; height: 26px; }
.seg { display: inline-flex; border: 1px solid var(--btn-line); border-radius: var(--r); overflow: hidden; }
.seg button { font: inherit; font-size: 0.88em; border: 0; background: var(--btn-bg); color: var(--muted); padding: 0 10px; height: 26px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--seg-on); color: var(--seg-on-text); font-weight: 600; }
.op-text { font-family: var(--mono); font-size: 0.88em; color: var(--muted); white-space: pre; overflow-x: auto; margin: 0 0 8px; }
.op-grid th[data-sort] { cursor: pointer; }
.op-grid th[data-sort]:hover { color: var(--text); }
.op-grid th.sorted::after { content: " \25BE"; }
.op-grid th.sorted.asc::after { content: " \25B4"; }
.op-grid td.r, .op-grid th.r { text-align: right; }
.op-grid tr.op-filtered { display: none; }
.op-stack { display: flex; flex-direction: column; gap: 1px; }
.op-up { color: var(--ok); }
.op-down { color: var(--danger); }
.op-pill { margin: 0; text-transform: none; letter-spacing: 0; font-size: 0.78em; }
.op-check { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 0.92em; cursor: pointer; }
/* show firewall view */
.op-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.op-stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 12px; }
.op-stat b { display: block; font-size: 1.35em; color: var(--heading); font-family: var(--mono); }
.op-stat span { color: var(--muted); font-size: 0.85em; }
.op-stat-warn b { color: var(--warn); }
.op-stat-danger b { color: var(--danger); }
.op-toggle { cursor: pointer; user-select: none; }
.op-caret { display: inline-block; width: 12px; color: var(--muted); transition: transform 0.12s; }
.op-chain.collapsed .op-caret { transform: rotate(-90deg); }
.op-chain.collapsed > .table-scroll { display: none; }
.op-chain.collapsed > .block-head { border-bottom: 0; }
.op-fw { table-layout: fixed; min-width: 1020px; }
.op-fw td { overflow-wrap: anywhere; }
.op-fw .op-w-num { width: 70px; }
.op-fw .op-w-desc { width: 22%; }
.op-fw .op-w-act { width: 90px; }
.op-fw .op-w-proto { width: 80px; }
.op-fw .op-w-pk { width: 120px; }
.op-fw .op-w-by { width: 100px; }
.op-fw .op-w-share { width: 56px; }
.op-fw .op-w-delta { width: 80px; }
.op-fw .op-w-last { width: 96px; }
.op-fw .op-w-actions { width: 34px; }
.op-hit { position: relative; }
.op-bar { position: absolute; left: 10px; right: 10px; bottom: 3px; height: 3px; background: var(--row-line); border-radius: 2px; }
.op-bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.op-grid tr.op-zero td { color: var(--muted); }
.op-grid tr.op-zero .act { opacity: 0.55; }
.op-hide-zero tr.op-zero:not(.op-pinned) { display: none; }
.op-cond { font-size: 0.92em; }
.op-cond-text { font-family: var(--mono); color: var(--muted); }
.op-jump { font-family: var(--mono); }
.op-delta { color: var(--ok); font-family: var(--mono); font-size: 0.92em; }
.op-no-delta .op-delta-col { display: none; }
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.loading-content {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 18px 26px;
    text-align: center;
    color: var(--text);
}
.spinner {
    width: 28px;
    height: 28px;
    margin: 0 auto 10px;
    border: 3px solid var(--line-strong);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ */
/* Admin settings                                                      */
/* ------------------------------------------------------------------ */
.admin-settings, .snapshot-manage { max-width: 1200px; }
.admin-settings > .section-title, .snapshot-manage > .section-title { font-size: 1.45em; margin-bottom: 10px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 14px; align-items: start; }
.settings-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 12px 14px;
}
.settings-card > .subsection-title:first-child { margin-top: 0; }
.settings-description { color: var(--muted); margin-bottom: 8px; }
.info-note { font-size: 0.88em; margin-top: 8px; }
.backup-list { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 10px; }
.backup-list-title { font-size: 1em; margin-bottom: 8px; }
.info-grid { border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 10px; }
.info-item {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 10px;
    padding: 5px 10px;
    border-bottom: 1px solid var(--row-line);
}
.info-item:last-child { border-bottom: 0; }
.info-label { color: var(--muted); font-size: 0.88em; }
.info-value { font-family: var(--mono); font-size: 0.92em; }
.schedule-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 14px; align-items: end; }
.schedule-form > .schedule-check, .schedule-form > .btn { grid-column: 1 / -1; }
.schedule-check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.schedule-field { display: flex; flex-direction: column; gap: 3px; }
.schedule-field label { font-size: 0.88em; color: var(--muted); }
.schedule-field select, .schedule-field input {
    font: inherit;
    height: 28px;
    padding: 0 8px;
    border: 1px solid var(--input-line);
    border-radius: var(--r);
    background: var(--input-bg);
    color: var(--text);
}
.fcv-form { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--row-line); }
.fcv-confirm { align-items: flex-start; }
.fcv-confirm input { margin-top: 2px; }
.backup-files { border: 1px solid var(--line); border-radius: var(--r); max-height: 240px; overflow: auto; }
.backup-file { font-family: var(--mono); font-size: 0.9em; padding: 3px 10px; border-bottom: 1px solid var(--row-line); }
.backup-file:last-child { border-bottom: 0; }

/* Snapshot management: one form per row, laid out as a table */
.snapshots-table {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r);
    margin-bottom: 12px;
}
.table-header, .snapshot-row {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 5px 10px;
    border-bottom: 1px solid var(--row-line);
}
.snapshot-row:last-child { border-bottom: 0; }
.snapshot-row:hover { background: var(--hover); }
.snapshot-row.is-new { background: var(--info-bg); box-shadow: inset 3px 0 0 var(--accent); }
.table-header {
    background: var(--th-bg);
    border-bottom-color: var(--line);
    font-size: 0.78em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--th);
}
.snapshot-name { font-family: var(--mono); }
.row-cell.row-actions { display: flex; gap: 6px; justify-content: flex-end; width: auto; }
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* Configurations page: rename a config in place */
.rename summary { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; list-style: none; }
.rename summary::-webkit-details-marker { display: none; }
.rename-icon { color: var(--muted); font-size: 0.95em; opacity: 0.6; }
.rename summary:hover .rename-icon, .rename summary:focus-visible .rename-icon, .rename[open] .rename-icon { opacity: 1; }
.rename summary:hover .rename-icon { color: var(--text); }
.rename-form { display: flex; gap: 6px; margin-top: 6px; }
.rename-form .input { max-width: 260px; height: 24px; }
.export { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--row-line); }
/* Config import: its own full-width block below the grid, SSH and paste side by side */
.import-intro { margin: 0 0 12px; max-width: 110ch; }
.import-ways { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 14px 28px; }
.import-way > .field-label { display: block; margin-bottom: 8px; font-weight: 600; color: var(--text); }
/* Responsibility notice and statement */
.legal-notice { margin: 8px 0; font-size: 0.88em; color: var(--muted); }
.legal-notice summary { cursor: pointer; list-style: none; }
.legal-notice summary::-webkit-details-marker { display: none; }
.legal-more { color: var(--link); margin-left: 4px; white-space: nowrap; }
.legal-notice[open] .legal-more { display: none; }
.legal {
    margin-top: 6px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-left: 3px solid var(--warn);
    border-radius: var(--r);
    background: var(--panel-head);
    color: var(--text);
    font-size: 0.95em;
}
.legal p + p { margin-top: 6px; }
.quick-start-ack span { font-size: 0.92em; }
.quick-start-ack { align-items: flex-start; }
.quick-start-ack input { margin-top: 2px; }

/* Getting started */
.quick-start { margin-bottom: 22px; }
.quick-start-body { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 20px; align-items: start; }
.quick-start-fields { display: flex; flex-direction: column; gap: 8px; }
.quick-start-fields .field { margin: 0; }
.quick-start-fields .btn { align-self: flex-start; margin-top: 4px; }
.quick-start-explain p { margin-bottom: 6px; }
.quick-start-table { margin-bottom: 8px; border: 1px solid var(--line); }
.quick-start-table td { padding: 3px 10px; }
@media (max-width: 900px) { .quick-start-body { grid-template-columns: 1fr; } }
.start-choose { margin-bottom: 22px; }
.start-steps-head h3 { color: var(--heading); }
.steps {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 10px;
    counter-reset: step;
}
.step {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-top: 3px solid var(--line-strong);
    border-radius: var(--r);
    padding: 10px 12px;
    min-width: 0;
}
.step-done { border-top-color: var(--ok); }
.step-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.step-head h4 { font-size: 1em; }
.step-head .pill-off { margin-left: 0; }
.step-num {
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    flex: none;
    border-radius: 50%;
    border: 1px solid var(--line-strong);
    color: var(--muted);
    font-family: var(--mono);
    font-size: 0.85em;
    font-weight: 700;
}
.step-done .step-num { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.step-help { color: var(--muted); font-size: 0.9em; flex: 1; }
.step-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap; }
.step-status { font-size: 0.85em; color: var(--muted); }
.step-done .step-status { color: var(--ok); }
.step-links { display: flex; gap: 4px; margin-left: auto; }
.steps-locked .step { opacity: 0.6; }
.nav-start { margin-bottom: 2px; font-weight: 600; }
@media (max-width: 1300px) { .steps { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 700px) { .steps { grid-template-columns: 1fr; } }

.error-page { max-width: 40rem; margin: 4rem auto; text-align: center; }
.error-page h1 { font-size: 1.8em; margin-bottom: 6px; }

/* ------------------------------------------------------------------ */
/* Snapshot diff window (difflib HtmlDiff output)                      */
/* ------------------------------------------------------------------ */
.full-width-container { padding: 16px 20px 40px; }
.full-width-content > .section-title { font-size: 1.45em; }
.diff-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 10px; color: var(--muted); font-size: 0.92em; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-color {
    display: inline-grid;
    place-items: center;
    width: 18px;
    height: 18px;
    font-family: var(--mono);
    font-weight: 700;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--panel);
}
.legend-color.added { color: var(--ok); background: var(--ok-bg); }
.legend-color.removed { color: var(--danger); background: var(--danger-bg); }
.legend-color.jump { color: var(--info); background: var(--info-bg); }
.diff-toolbar { display: flex; gap: 6px; margin-bottom: 10px; }
.diff-html-content {
    background: var(--code-bg);
    border: 1px solid var(--line);
    border-radius: var(--r);
    overflow: auto;
}
.diff-html-content table { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 0.9em; }
.diff-html-content th, .diff-html-content td { padding: 1px 8px; vertical-align: top; white-space: pre-wrap; word-break: break-all; }
.diff-html-content th { background: var(--th-bg); color: var(--th); font-family: var(--font); font-weight: 600; border-bottom: 1px solid var(--line); }
.diff-html-content .diff_header { color: var(--muted); background: var(--panel-head); text-align: right; border-right: 1px solid var(--line); }
.diff-html-content .diff_add { color: var(--ok); background: var(--ok-bg); }
.diff-html-content .diff_sub { color: var(--danger); background: var(--danger-bg); }
.diff-html-content .diff_chg { color: var(--warn); background: var(--warn-bg); }
.diff-html-content td.diff_next { background: var(--panel-head); text-align: center; }
.diff-html-content td.diff_next, .diff-html-content .diff_header { width: 1%; white-space: nowrap; word-break: normal; }
.diff-html-content td.diff_next a { color: var(--info); }
.diff-html-content td.diff_next a:focus { outline: 2px solid var(--focus); }

/* ------------------------------------------------------------------ */
/* Alerts (flash messages)                                             */
/* ------------------------------------------------------------------ */
.flash-messages { margin-bottom: 12px; }
.alert {
    padding: 7px 12px;
    margin-bottom: 6px;
    border: 1px solid var(--line);
    border-left: 3px solid var(--info);
    border-radius: var(--r);
    background: var(--panel);
    color: var(--text);
}
.alert-success { border-left-color: var(--ok); background: var(--ok-bg); }
.alert-warning { border-left-color: var(--warn); background: var(--warn-bg); }
.alert-danger { border-left-color: var(--danger); background: var(--danger-bg); }
.alert-key, .alert-info { border-left-color: var(--info); background: var(--info-bg); }

/* ------------------------------------------------------------------ */
/* Code output                                                         */
/* ------------------------------------------------------------------ */
.configuration {
    font-family: var(--mono);
    font-size: 0.92em;
    line-height: 1.5;
    background: var(--code-bg);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 10px 14px;
    overflow: auto;
    white-space: pre;
}

/* ------------------------------------------------------------------ */
/* Visualize (static/visualize.js)                                     */
/* ------------------------------------------------------------------ */
.viz-tabs { margin-bottom: 10px; }
.viz-tabs .tab { cursor: pointer; background: none; border-top: 0; border-left: 0; border-right: 0; font: inherit; }
.viz-bar { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin-bottom: 10px; }
.viz-cap { margin: 0; color: var(--muted); flex: 1; min-width: 240px; }
.viz-types { flex-wrap: wrap; }
.viz-types button .iftype { font-weight: inherit; }
.viz-types[hidden] { display: none; }
.viz-fold { display: inline-flex; gap: 6px; }
.viz-fold[hidden] { display: none; }
.viz .fold { cursor: pointer; }
.viz .fold-hit { fill: transparent; }
.viz .fold:hover .fold-hit, .viz .fold:focus-visible .fold-hit { fill: var(--hover); }
.viz .fold:focus { outline: none; }
.viz .fold:focus-visible .fold-hit { stroke: var(--focus); stroke-width: 2; }
.viz .fold-caret { fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.viz .fold:hover .fold-caret, .viz .fold:focus-visible .fold-caret { stroke: var(--text); }
.viz-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 12px; align-items: start; }
.viz-stage { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: auto; min-height: 320px; }
/* Scale down to the stage on narrower screens; never up. */
.viz-stage svg { display: block; max-width: 100%; height: auto; }
/* Fit to width off: full size, the stage scrolls. */
.viz-stage.actual svg { max-width: none; }
.viz-empty { padding: 24px; margin: 0; }
.viz-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 8px 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.85em; }
.viz-legend:empty { display: none; }
.viz-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 2px; vertical-align: -2px; margin-right: 5px; }
.viz-legend i.line, .viz-legend i.dash { height: 0; border-top: 2px solid; border-radius: 0; vertical-align: 3px; width: 18px; }
.viz-legend i.dash { border-top-style: dashed; }
.viz-panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; position: sticky; top: 12px; max-height: calc(100vh - 120px); overflow: auto; }
.viz-panel h3 { margin: 0 0 4px; font-size: 1.05em; color: var(--heading); }
.viz-panel p { margin: 6px 0; }
.viz-panel .kind { color: var(--muted); font-size: 0.8em; text-transform: uppercase; letter-spacing: 0.05em; }
.viz-panel table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 0.88em; }
.viz-panel td { border-top: 1px solid var(--row-line); padding: 3px 4px; vertical-align: top; }
.viz-panel td.n { font-family: var(--mono); color: var(--muted); width: 28px; }
.viz-panel ul, .viz-panel ol { margin: 6px 0 0; padding-left: 18px; }
.viz-panel .sec { margin-top: 10px; font-weight: 600; color: var(--heading); font-size: 0.9em; }
.viz-panel .btn { margin-top: 10px; }
.viz-warn { color: var(--warn); }

.viz text { fill: var(--text); font-family: var(--font); font-size: 12px; }
.viz text.mono { font-family: var(--mono); font-size: 11px; }
.viz text.muted { fill: var(--muted); }
.viz text.small { font-size: 10px; }
.viz text.head { font-weight: 700; fill: var(--heading); }
.viz text.ref { fill: var(--ref); }
.viz text.warn { fill: var(--warn); font-weight: 700; font-size: 10px; }
.viz text.halo { paint-order: stroke; stroke: var(--panel); stroke-width: 4px; stroke-linejoin: round; }
.viz .box { fill: var(--panel); stroke: var(--line-strong); stroke-width: 1; }
.viz .box.grp { stroke: var(--ref); }
.viz .box-head { fill: var(--panel-head); }
.viz .row-hit { fill: transparent; }
.viz .row-hit:hover, .viz .sel > .row-hit { fill: var(--hover); }
.viz [data-node] { cursor: pointer; transition: opacity 0.15s; }
.viz .disabled { opacity: 0.45; }
.viz .e { fill: none; stroke: var(--line-strong); stroke-width: 1.6; transition: opacity 0.15s; }
.viz .e-bound { stroke: var(--muted); }
.viz .e-jump { stroke: var(--accent); }
.viz .e-uses { stroke: var(--ref); stroke-width: 1.2; }
.viz .e-offload { stroke: var(--info); stroke-dasharray: 6 4; }
.viz .e-ft { stroke: var(--info); stroke-dasharray: 2 4; stroke-width: 1.2; }
.viz .e-dis { stroke-dasharray: 2 4; opacity: 0.4; }
.viz .dim { opacity: 0.1 !important; }
.viz .hot { stroke-width: 2.6; }
.viz .badge text { font-size: 9px; font-weight: 700; letter-spacing: 0.04em; fill: var(--info); }
.viz .badge rect { fill: var(--info-bg); }
.viz .b-accept rect, .viz .b-continue rect { fill: var(--ok-bg); }
.viz .b-accept text, .viz .b-continue text { fill: var(--ok); }
.viz .b-drop rect { fill: var(--danger-bg); }
.viz .b-drop text { fill: var(--danger); }
.viz .b-reject rect { fill: var(--warn-bg); }
.viz .b-reject text { fill: var(--warn); }
.viz .b-jump rect { fill: var(--chip-bg); }
.viz .b-jump text { fill: var(--accent); }
.viz .orphan .box, .viz .orphan .shape, .viz .missing .box, .viz .missing .shape { stroke: var(--warn); stroke-dasharray: 5 3; stroke-width: 1.5; }
.viz .ft .box { stroke: var(--info); }
.viz .dot { pointer-events: none; filter: drop-shadow(0 0 3px currentColor); }
/* A chain row flashes when a packet lands on it. */
.viz [data-row] > .row-hit { transition: fill 0.4s ease-out, fill-opacity 0.4s ease-out; }
.viz [data-row].hit > .row-hit { fill: var(--focus); fill-opacity: 0.28; transition: none; }
.viz.no-anim .dots { display: none; }
.viz .shape { stroke-width: 1.5; }
.viz .k-if .shape { fill: var(--panel); stroke-width: 2; }
.viz .k-hook .shape { fill: var(--chip-bg); stroke: var(--accent); }
.viz .k-chain .shape { fill: var(--panel-head); stroke: var(--line-strong); }
.viz .k-group .shape { fill: var(--panel); stroke: var(--ref); }
.viz .k-ft .shape { fill: var(--info-bg); stroke: var(--info); }
.viz .band { transition: opacity 0.15s, fill-opacity 0.15s; fill-opacity: 0.32; }
.viz .band:hover { fill-opacity: 0.6; }

.zm-wrap { overflow: auto; }
.zm { border-collapse: separate; border-spacing: 4px; margin: 12px; }
.zm th { font-weight: 600; color: var(--heading); padding: 4px 8px; text-align: left; white-space: nowrap; }
.zm th .muted { font-weight: 400; display: block; font-size: 0.82em; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.zm thead th { text-align: center; vertical-align: bottom; }
.zm th.corner { color: var(--muted); font-weight: 400; font-size: 0.82em; text-align: right; }
.zchip { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.zm td { min-width: 140px; height: 66px; vertical-align: top; padding: 6px 8px; border-radius: var(--r); border: 1px solid var(--line); cursor: pointer; font-size: 0.88em; transition: opacity 0.15s, box-shadow 0.15s; }
.zm td:hover, .zm td.sel, .zm td:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--focus); }
.zm td.self { background: repeating-linear-gradient(45deg, transparent 0 6px, var(--row-line) 6px 7px); cursor: default; box-shadow: none; }
.zm td b { display: block; font-size: 0.86em; text-transform: uppercase; letter-spacing: 0.05em; }
.zm td .ch { font-family: var(--mono); font-size: 0.88em; color: var(--muted); }
.zm td .ex { color: var(--warn); font-size: 0.82em; }
.zm td .fast { color: var(--info); font-size: 0.82em; }
.zm td.dim { opacity: 0.25; }
.zm .v-open { background: var(--ok-bg); }
.zm .v-open b { color: var(--ok); }
.zm .v-limited { background: var(--info-bg); }
.zm .v-limited b { color: var(--info); }
.zm .v-replies { background: var(--chip-bg); }
.zm .v-replies b { color: var(--muted); }
.zm .v-blocked { background: var(--danger-bg); }
.zm .v-blocked b { color: var(--danger); }
.zm .v-unknown b { color: var(--warn); }

/* Visualize log hits overlay (Graylog): hit labels and zone cell lines. */
.viz text.hits { fill: var(--accent); font-weight: 600; }
.viz text.hits.zero { fill: var(--muted); font-weight: 400; }
.viz-hits { height: 26px; width: auto; margin-left: 4px; }
.zm td .obs { margin-top: 4px; font-size: 0.82em; font-family: var(--mono); color: var(--text); }
.zm td .obs.muted { color: var(--muted); }
.zm td .obs.obs-warn { color: var(--warn); font-weight: 600; }
.viz-panel td.hits-cell { text-align: right; white-space: nowrap; font-family: var(--mono); font-size: 0.9em; }

/* Add set commands preview (templates/set_merge_preview.html). */
.set-merge-diff { margin: 0; padding: 10px 12px; max-height: 480px; overflow: auto; background: var(--input-bg); border: 1px solid var(--line); border-radius: var(--r); font-size: 0.88em; line-height: 1.55; white-space: pre-wrap; }
.set-merge-diff .add { color: var(--ok); }
.set-merge-diff .del { color: var(--danger); }

/* Logs page (templates/logs.html): filter bar and the log line table. */
.logs-filter-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; }
.logs-filter-row .field { display: flex; flex-direction: column; gap: 4px; min-width: 140px; }
.logs-filter-row .form-input, .logs-filter-row .form-select { width: 100%; }
.logs-filter-row .logs-port { min-width: 80px; width: 90px; }
.logs-filter-actions { display: flex; gap: 8px; margin-left: auto; }
.logs-top { margin-bottom: 14px; }
.logs-lines td { vertical-align: top; }

@media print {
    .topbar, .nav, .foot, .viz-tabs, .viz-bar, .viz-panel, .page-actions { display: none !important; }
    .shell { display: block; }
    .viz-wrap { display: block; }
    .viz-stage { overflow: visible; border: 0; }
    .viz-stage svg { max-width: 100%; height: auto; }
    .viz .dots { display: none; }
}

/* ------------------------------------------------------------------ */
/* Legacy helpers still referenced by templates                        */
/* ------------------------------------------------------------------ */
.link, .docs_link { color: var(--link); }
.docs_link { font-weight: 600; }

/* ------------------------------------------------------------------ */
/* Responsive                                                          */
/* ------------------------------------------------------------------ */
@media (max-width: 900px) {
    .table-header { display: none; }
    .snapshot-row, .schedule-form { grid-template-columns: 1fr; }
    .push-grid { grid-template-columns: 1fr; }
    .tabs-container, .basic-config-grid { grid-template-columns: 1fr; }
    .basic-config-grid .full-width, .basic-config-grid .form-group:last-child { grid-column: auto; }
    .shell { grid-template-columns: minmax(0, 1fr); }
    .nav { border-right: 0; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; padding: 6px; }
    .nav-group { width: 100%; padding: 6px 10px 2px; margin-top: 4px; }
    .nav-item { border-left: 0; border-radius: var(--r); padding: 4px 10px; }
    .brand { min-width: 0; }
    .brand-sub, .cfg-label { display: none; }
    .tiles { grid-template-columns: 1fr; }
    .viz-wrap { grid-template-columns: minmax(0, 1fr); }
    .viz-panel { position: static; }
    .main { padding: 12px; }
}
