/* Keep IT Simple – client configuration portal.
   Colour scheme matches the KIS Network Manager: deep navy / slate, dark-red primary actions,
   outlined status pills. Brand reds: #D72727 / #9C1C1F.
   <html data-theme="dark|light"> selects the palette. Dark is the default. */
:root, html[data-theme="dark"] {
  color-scheme: dark;
  --red: #D72727; --brand: #7F1D1D; --brand-line: #B91C1C; --brand-hover: #991B1B; --brand-ink: #FDE8E8;
  --heading: #F1F5F9; --link: #F87171;
  --bg: #0B1120; --card: #0F172A; --raised: #131C30; --ink: #E2E8F0; --muted: #94A3B8; --line: #1E293B; --line-soft: #172033;
  --input-bg: #0D1526; --input-line: #334155; --input-focus: #64748B;
  --topbar: #070C18; --subbar: #0B1222; --nav-active: #1E293B; --savebar: rgba(11, 17, 32, .96);
  --thead-ink: #CBD5E1; --row-alt: #111A2D; --rowlabel: #0F172A; --hover: #162036;
  --chip: #1E293B; --chip-ink: #CBD5E1;
  --ro: #111827; --ro-ink: #8391A7;
  --ok: #4ADE80; --ok-line: #15803D; --warn: #FACC15; --warn-line: #CA8A04; --warn-bg: rgba(202, 138, 4, .12); --err: #F87171; --err-line: #B91C1C;
  --msg-success-bg: rgba(21, 128, 61, .14); --msg-success-ink: #86EFAC;
  --msg-error-bg: rgba(185, 28, 28, .16); --msg-error-ink: #FCA5A5;
  --msg-warning-bg: rgba(202, 138, 4, .14); --msg-warning-ink: #FDE68A;
  --msg-info-bg: rgba(59, 130, 246, .14); --msg-info-ink: #BFDBFE; --info-line: #2563EB;
  --code: #1E293B; --old: #FCA5A5; --new: #86EFAC; --flag: #EAB308;
}
html[data-theme="light"] {
  color-scheme: light;
  --red: #D72727; --brand: #9C1C1F; --brand-line: #9C1C1F; --brand-hover: #B91C1C; --brand-ink: #fff;
  --heading: #0F172A; --link: #B91C1C;
  --bg: #F1F5F9; --card: #FFFFFF; --raised: #F8FAFC; --ink: #0F172A; --muted: #64748B; --line: #E2E8F0; --line-soft: #EEF2F6;
  --input-bg: #FFFFFF; --input-line: #CBD5E1; --input-focus: #64748B;
  --topbar: #FFFFFF; --subbar: #F8FAFC; --nav-active: #E2E8F0; --savebar: rgba(241, 245, 249, .96);
  --thead-ink: #334155; --row-alt: #F8FAFC; --rowlabel: #FFFFFF; --hover: #F1F5F9;
  --chip: #E2E8F0; --chip-ink: #334155;
  --ro: #F1F5F9; --ro-ink: #64748B;
  --ok: #15803D; --ok-line: #16A34A; --warn: #A16207; --warn-line: #CA8A04; --warn-bg: #FEF9C3; --err: #B91C1C; --err-line: #DC2626;
  --msg-success-bg: #F0FDF4; --msg-success-ink: #166534;
  --msg-error-bg: #FEF2F2; --msg-error-ink: #991B1B;
  --msg-warning-bg: #FEFCE8; --msg-warning-ink: #854D0E;
  --msg-info-bg: #EFF6FF; --msg-info-ink: #1E40AF; --info-line: #2563EB;
  --code: #E2E8F0; --old: #B91C1C; --new: #15803D; --flag: #EAB308;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Arial, Helvetica, sans-serif; color: var(--ink); background: var(--bg);
  min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--link); }
h1 { font-size: 22px; margin: 0 0 4px; color: var(--heading); font-weight: 700; }
h2 { font-size: 17px; margin: 0 0 10px; color: var(--heading); font-weight: 700; }
h3 { font-size: 14px; margin: 0 0 8px; color: var(--heading); }
code { background: var(--code); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .right { text-align: right; }

/* ---------------------------------------------------------------- top bar */
.stickytop { position: sticky; top: 0; z-index: 20; }
.topbar { display: flex; align-items: center; gap: 28px; background: var(--topbar); border-bottom: 1px solid var(--line);
  padding: 10px 24px; }
/* configuration header + page tabs, kept on screen with the top bar */
.subhead { background: var(--bg); border-bottom: 2px solid var(--red); box-shadow: 0 8px 14px -12px rgba(0, 0, 0, .6); }
.subhead-inner { max-width: 1240px; margin: 0 auto; padding: 14px 24px 0; }
.subhead-inner.wide { max-width: 1640px; }
.subhead .confighead { margin-bottom: 8px; }
.subhead .tabs { margin-bottom: 0; border-bottom: 0; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; font-weight: 700; color: var(--heading); font-size: 16px; }
.brand img { height: 30px; width: 42px; object-fit: contain; background: #fff; border-radius: 8px; padding: 4px 5px; box-sizing: content-box; }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a { text-decoration: none; color: var(--ink); font-weight: 600; padding: 7px 12px; border-radius: 8px; }
.topbar nav a:hover { background: var(--nav-active); }
.usermenu { display: flex; align-items: center; gap: 12px; }
.usermenu form { margin: 0; }
.usermenu > a { color: var(--heading); font-weight: 700; text-decoration: none; }
.linkbtn { background: none; border: 1px solid var(--line); color: var(--ink); cursor: pointer; font: inherit; font-weight: 600; padding: 5px 10px; border-radius: 8px; }
.linkbtn:hover { border-color: var(--input-focus); }
.badge-kis { border: 1px solid var(--input-line); color: var(--muted); font-size: 11px; padding: 0 6px; border-radius: 6px; font-weight: 700; }
.themetoggle { background: none; border: 1px solid var(--line); color: var(--ink); border-radius: 8px; padding: 5px 10px; cursor: pointer; font: inherit; font-size: 12px; font-weight: 600; }
.themetoggle:hover { border-color: var(--input-focus); }
.themecorner { position: fixed; top: 12px; right: 16px; margin: 0; }

.container { width: 100%; max-width: 1240px; margin: 0 auto; padding: 22px 24px; flex: 1; }
.container.wide { max-width: 1640px; }
/* footer pinned to the bottom of the window; the save bar sits just above it (--footer-h is measured by app.js) */
:root { --footer-h: 33px; }
.footer { display: flex; justify-content: space-between; gap: 16px; color: var(--muted); font-size: 12px; padding: 8px 24px; border-top: 1px solid var(--line);
  position: sticky; bottom: 0; z-index: 20; background: var(--topbar); }

/* ---------------------------------------------------------------- layout */
.pagehead { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px 22px; margin-bottom: 18px; }
.card.narrow { max-width: 640px; }
.card > h2:first-child, .card > h3:first-child { padding-bottom: 10px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.cardhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.cardhead h2 { margin: 0; }
.cols { display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-start; }
.cols > .card { flex: 1 1 380px; }
.cols > .card.side { flex: 0 1 340px; }
.cols > .card.grow { flex: 3 1 520px; }

/* ---------------------------------------------------------------- buttons */
.btn { display: inline-block; border: 1px solid var(--input-line); background: transparent; color: var(--ink); padding: 6px 14px;
  border-radius: 8px; text-decoration: none; cursor: pointer; font: inherit; font-weight: 700; }
.btn:hover { border-color: var(--input-focus); background: var(--hover); }
.btn-primary { background: var(--brand); border-color: var(--brand-line); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--red); }
.btn-small { padding: 2px 8px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-danger { background: var(--brand); border-color: var(--err-line); color: var(--brand-ink); }
.btn-danger:hover { background: var(--brand-hover); }
.btn-danger-outline { color: var(--err); border-color: var(--err-line); }
.btn-danger-outline:hover { background: var(--msg-error-bg); }
.iconbtn { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 14px; }
.iconbtn:hover { color: var(--err); }
.actions { margin-top: 16px; display: flex; gap: 8px; }
form.inline { display: inline; margin: 0; }
.inlineform { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }

/* ---------------------------------------------------------------- inputs */
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=url], select, textarea {
  width: 100%; padding: 5px 8px; border: 1px solid var(--input-line); border-radius: 8px; font: inherit; background: var(--input-bg); color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--input-focus); box-shadow: 0 0 0 3px rgba(148, 163, 184, .18); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .65; }
select { appearance: none; -webkit-appearance: none; padding-right: 26px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 13px) 52%, calc(100% - 8px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
.formrow { margin-bottom: 14px; }
.formrow label { display: block; font-weight: 600; margin-bottom: 5px; }
.formrow-check label { font-weight: 600; display: flex; gap: 8px; align-items: center; }
.formrow-check input { width: auto; }
.help { color: var(--muted); font-size: 12px; margin-top: 4px; }
.error { color: var(--err); font-size: 12px; margin-top: 4px; font-weight: 600; }
.req { color: var(--red); }
.kistag { display: inline-block; margin-left: 5px; font-size: 10px; font-weight: 700; letter-spacing: .3px; color: var(--muted);
  border: 1px solid var(--input-line); border-radius: 5px; padding: 0 4px; vertical-align: 1px; }
.ro { padding: 5px 8px; border-radius: 8px; background: var(--ro); color: var(--ro-ink); border: 1px solid var(--line); min-height: 30px; }
.ro.computed { background: transparent; border: 1px dashed var(--input-line); color: var(--muted); }
/* problems: yellow border (issues, server validation, live browser checks) */
.invalid, .flagged, .ipbad, .jsbad { border: 2px solid var(--flag) !important; }
.jserror, .jswarn, .jssubnet, .jsdup { font-size: 12px; margin-top: 4px; font-weight: 600; color: var(--warn); }
.jserror { color: var(--err); }

/* ---------------------------------------------------------------- messages */
.messages { margin-bottom: 16px; }
.msg { padding: 10px 14px; border-radius: 10px; margin-bottom: 8px; border: 1px solid; }
.msg-success { background: var(--msg-success-bg); border-color: var(--ok-line); color: var(--msg-success-ink); }
.msg-error { background: var(--msg-error-bg); border-color: var(--err-line); color: var(--msg-error-ink); }
.msg-warning { background: var(--msg-warning-bg); border-color: var(--warn-line); color: var(--msg-warning-ink); }
.msg-info { background: var(--msg-info-bg); border-color: var(--info-line); color: var(--msg-info-ink); }

/* ---------------------------------------------------------------- tables */
table.grid { width: 100%; border-collapse: collapse; }
table.grid th, table.grid td { border-bottom: 1px solid var(--line-soft); padding: 9px 10px; text-align: left; vertical-align: top; }
table.grid thead th { background: var(--card); color: var(--thead-ink); font-size: 13px; font-weight: 700; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 1; }
table.grid tbody tr:nth-child(even) > td, table.grid tbody tr:nth-child(even) > th { background: var(--row-alt); }
table.grid tbody tr:hover > td { background: var(--hover); }
table.grid.compact td, table.grid.compact th { padding: 6px 10px; }
/* top-aligned so a message under one field never shifts the rest of the row */
table.entry td { padding: 5px 6px; vertical-align: top; }
table.entry td > .iconbtn { margin-top: 8px; }
table.entry td > .switch { margin-top: 4px; }
table.entry .rowlabel { font-weight: 600; min-width: 200px; font-size: 13px; vertical-align: top; padding-top: 12px; }
tr.inactive td, tr.inactive th { opacity: .45; }
.tablewrap { overflow-x: auto; margin-bottom: 10px; }
td.w-xs { min-width: 70px; } td.w-sm { min-width: 120px; } td.w-md { min-width: 160px; } td.w-lg { min-width: 240px; }
td.w-xs input { max-width: 110px; }
td.old { color: var(--old); } td.new { color: var(--new); }
table.grid td a:not(.btn):not(.chip) { color: var(--heading); text-decoration: none; font-weight: 600; }
table.grid td a:not(.btn):not(.chip):hover { color: var(--link); text-decoration: underline; }

/* ---------------------------------------------------------------- pills & chips */
.chip { display: inline-block; background: var(--chip); color: var(--chip-ink); padding: 2px 9px; border-radius: 999px; margin: 0 4px 4px 0;
  text-decoration: none; font-size: 12px; font-weight: 600; }
.status { font-size: 12px; font-weight: 600; padding: 1px 9px; border-radius: 999px; border: 1px solid var(--input-line); color: var(--muted);
  background: transparent; vertical-align: middle; white-space: nowrap; }
.status-active, .status-ready, .status-built { color: var(--ok); border-color: var(--ok-line); }
.status-invited, .status-review, .status-collecting { color: var(--warn); border-color: var(--warn-line); }
.status-disabled, .status-archived { color: var(--muted); border-color: var(--input-line); }
.filters { display: flex; gap: 8px; margin-bottom: 14px; }
.filters select { width: auto; min-width: 180px; }

/* ---------------------------------------------------------------- configuration pages */
.confighead { margin-bottom: 12px; }
.crumbs { font-size: 13px; margin-bottom: 2px; }
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--red); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 8px 13px; text-decoration: none; color: var(--ink); font-weight: 600; border-radius: 8px 8px 0 0; }
.tabs a:hover { background: var(--hover); }
.tabs a.active { background: var(--brand); color: #fff; }
.tabs a.has-issues { box-shadow: inset 0 -3px 0 var(--warn-line); }
.tabbadge { display: inline-block; margin-left: 4px; padding: 0 7px; border-radius: 999px; font-size: 11px; font-weight: 700; line-height: 17px;
  color: var(--warn); border: 1px solid var(--warn-line); background: var(--warn-bg); }
.tabs a.active .tabbadge { background: #FACC15; color: #1E1B12; border-color: #FACC15; }
.sectiondesc { color: var(--muted); margin: 0 0 14px; }
.legend { font-size: 12px; color: var(--muted); margin-bottom: 12px; display: flex; gap: 6px; align-items: center; }
.kvgrid { display: grid; grid-template-columns: minmax(220px, 320px) 1fr; gap: 10px 18px; align-items: start; max-width: 1000px; }
.kvlabel { font-weight: 600; padding-top: 6px; }
.savebar { position: sticky; bottom: var(--footer-h); background: var(--savebar); border-top: 1px solid var(--line); padding: 6px 0; display: flex; gap: 8px;
  align-items: center; z-index: 5; backdrop-filter: blur(4px); }
.savebar .spacer { flex: 1; }
.issues { margin: 0; padding-left: 18px; }
.issues li { margin-bottom: 4px; }
.issue-warning::marker { content: "⚠ "; color: var(--warn); }
.issue-info::marker { content: "ℹ "; }
.issuesbox { border-left: 4px solid var(--warn-line); }
.issuecount { color: var(--warn); border: 1px solid var(--warn-line); font-weight: 700; padding: 0 8px; border-radius: 999px; font-size: 12px; }
.ok { color: var(--ok); font-weight: 700; }
.bar { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin-bottom: 14px; }
.bar.small { height: 6px; margin: 7px 0 0; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, #D72727, #9C1C1F); border-radius: 999px; }
.blockhead { margin: 24px 0 12px; font-size: 18px; color: var(--heading); border-bottom: 1px solid var(--line); padding-bottom: 6px; }
ul.plain { list-style: none; padding: 0; margin: 0 0 10px; font-size: 13px; }
ul.plain li { padding: 4px 0; border-bottom: 1px solid var(--line-soft); }
.dangercard { border-left: 4px solid var(--err-line); }

/* ---------------------------------------------------------------- sign-in pages */
main.auth { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 16px; }
.authcard { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 30px 32px; width: 100%; max-width: 410px; }
.authlogo { height: 56px; display: block; margin: 0 auto 14px; background: #fff; border-radius: 12px; padding: 8px 10px; box-sizing: content-box; }
.authcard h1 { text-align: center; }
.authcard > p.muted { text-align: center; }
.authlinks { text-align: center; margin-top: 16px; font-size: 13px; }

/* ---------------------------------------------------------------- on/off switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; position: relative; }
.switch input[type=checkbox] { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .slider { position: relative; width: 42px; height: 24px; border-radius: 12px; background: var(--input-line);
  transition: background .15s; flex: none; }
.switch .slider::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; transition: transform .15s; }
.switch input:checked + .slider { background: var(--brand); }
.switch input:checked + .slider::after { transform: translateX(18px); }
.switch input:focus-visible + .slider { outline: 2px solid var(--link); outline-offset: 2px; }
.switch .switchlabel { font-weight: 600; }
.switch.flagged { padding: 3px 10px 3px 3px; border-radius: 16px; }

/* fields switched off by an On/Off switch (enabled_by) */
.gated-off { opacity: .45; }
.gated-off .req { visibility: hidden; }
input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; }

/* ---------------------------------------------------------------- dialogs */
.dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--ink); padding: 22px 24px;
  width: min(560px, calc(100vw - 32px)); box-shadow: 0 24px 60px rgba(0, 0, 0, .5); }
.dialog::backdrop { background: rgba(2, 6, 23, .65); }
.dialoghead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.dialoghead h2 { margin: 0; }
.dialog input[type=text] { width: 100%; }
.dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.typechoices { display: grid; gap: 8px; margin: 12px 0 16px; }
.typechoice { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--input-line); border-radius: 10px; padding: 12px 14px; cursor: pointer; }
.typechoice:hover { background: var(--hover); }
.typechoice:has(input:checked) { border-color: var(--red); box-shadow: inset 0 0 0 1px var(--red); }
.typechoice input { margin-top: 3px; accent-color: var(--red); }
.typechoice > span { display: flex; flex-direction: column; gap: 2px; }
.dialog .kvlabel { display: block; margin-bottom: 6px; }

/* save / status messages on configuration pages: right of the title, so nothing below moves */
.confighead { display: flex; align-items: flex-start; gap: 24px; }
.confighead-main { flex: 1; min-width: 0; }
.headmessages { max-width: 46%; display: flex; flex-direction: column; gap: 6px; transition: opacity .6s; }
.headmessages .msg { margin: 0; padding: 7px 12px; font-size: 13px; }
.headmessages.fading { opacity: 0; }

/* configuration pages: the save bar is the last thing on the page, flush with the footer, so it never moves
   when you reach the bottom (and short pages keep it at the bottom of the window too) */
main.container:has(> form.configform) { padding-bottom: 0; display: flex; flex-direction: column; }
form.configform { flex: 1; display: flex; flex-direction: column; }
form.configform > .savebar { margin-top: auto; }

/* subnet an address belongs to, shown under the field for reference */
.ipwrap { display: flex; align-items: center; gap: 8px; }
.ipwrap > input { flex: 1 1 auto; min-width: 124px; }
.subnetref { flex: none; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.subnetref:empty { display: none; }
.ipwrap > .subnetref:empty { display: inline-block; visibility: hidden; }
td.w-xxs { min-width: 58px; width: 64px; }
td.w-xxs input { max-width: 72px; }
th.w-xxs, th.w-xs { white-space: nowrap; }
/* every IP address field: exactly wide enough for 255.255.255.255 */
input[data-type="ip"] { width: calc(13ch + 20px); min-width: 0; max-width: none; flex: none; }
td.w-ip { width: 1%; }
th.w-ip { white-space: nowrap; }
/* constrained columns (numbers, IPs, short choices, switches) take only the width they need;
   the spare width goes to the name / text columns instead of opening gaps between fields */
table.entry td.w-xxs, table.entry td.w-xs, table.entry td.w-sm, table.entry td.w-ip,
table.entry th.w-xxs, table.entry th.w-xs, table.entry th.w-sm, table.entry th.w-ip { width: 1%; }
table.entry td { padding-left: 4px; padding-right: 4px; }
/* a message under a field wraps to the field's width instead of widening its column */
table.entry td > .jswarn, table.entry td > .jserr, table.entry td > .jssubnet, table.entry td > .jsdup, table.entry td > .error { width: 0; min-width: 100%; }
/* short choice lists size to their longest option so nothing is cut off */
table.entry td.w-sm select, table.entry td.w-xs select, table.entry td.w-xxs select { width: auto; min-width: 100%; }
/* read-only / calculated values stay on one line; hover shows the full value */
.ro { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Save greyed out until something changes; the next button keeps one width for both of its labels */
.btn:disabled { opacity: .4; cursor: not-allowed; filter: grayscale(.4); }
.swaplabel { display: inline-grid; }
.swaplabel > span { grid-area: 1 / 1; text-align: center; }
[data-continue] .when-dirty, [data-continue].is-dirty .when-clean { visibility: hidden; }
[data-continue].is-dirty .when-dirty { visibility: visible; }
/* reference values (gateway, DNS, NTP …): smaller text like the subnet beside an IP */
.ro.ro-small { font-size: 12px; color: var(--muted); min-height: 30px; line-height: 18px; }
.ro.ro-small:empty::after { content: "—"; }
/* reference columns with a set width (e.g. DNS / NTP beside an appliance) */
table.entry td.w-ref, table.entry th.w-ref { width: 230px; min-width: 230px; max-width: 230px; }

/* ---- always-short columns (numbers, VLANs, prefixes, IPs, choices, switches) fit their content and header ---- */
table.entry td.fit, table.entry th.fit { width: 1%; min-width: 0; }
table.entry td.fit select { width: auto; min-width: 0; max-width: none; }
table.entry td.fit input:not([data-type="ip"]) { min-width: 0; }
table.entry th .thlabel { white-space: nowrap; }
table.entry th .kistag { white-space: nowrap; }
/* in tables a switch's position says On/Off on its own; multi-word headers of short columns may use two lines */
table.entry td .switch .switchlabel { display: none; }
table.entry th.fit .thlabel { white-space: normal; }

/* ---- no sideways scrolling: text columns may shrink (values end in "…", full value on hover) ---- */
td.w-md { min-width: 110px; } td.w-lg { min-width: 150px; } td.w-sm { min-width: 90px; }
table.entry td.w-ref, table.entry th.w-ref { width: 230px; min-width: 110px; max-width: 230px; }
table.entry td.w-md .ro, table.entry td.w-lg .ro, table.entry td.w-ref .ro, table.entry td.w-sm .ro { width: 0; min-width: 100%; }
table.entry td.w-md input, table.entry td.w-lg input, table.entry td.w-sm input:not([style]) { min-width: 0; }
/* a subnet that is the same on every row is shown once, under the header */
.subnetref.in-header { display: none !important; }
th .thsubnet { display: block; font-size: 11px; font-weight: 500; color: var(--muted); white-space: nowrap; margin-top: 2px; }

/* IP ranges (e.g. DHCP range) get a fixed width wide enough for a typical range; the
   flexible text columns (such as Network name) give up the space. */
table.entry td.w-range, table.entry th.w-range { width: 155px; min-width: 155px; }

/* "Copied" bubble after right-clicking a field */
.copytip { position: fixed; z-index: 1000; pointer-events: none; padding: 3px 8px; border-radius: 6px; font-size: 12px; font-weight: 600;
  background: var(--card); color: var(--ok); border: 1px solid var(--ok-line); box-shadow: 0 4px 12px rgba(0,0,0,.25);
  opacity: 0; transform: translateY(4px); transition: opacity .15s, transform .15s; }
.copytip.bad { color: var(--err); border-color: var(--err-line); }
.copytip.show { opacity: 1; transform: none; }

/* calculated lists (e.g. an Edge cluster's members) wrap instead of cutting off */
table.entry td .ro.ro-wrap, .ro.ro-wrap { white-space: normal; overflow: visible; text-overflow: clip; height: auto; overflow-wrap: anywhere; padding-top: 5px; padding-bottom: 5px; }

/* pick list field + dialog (e.g. an Edge cluster's Edge nodes) */
.picklist { display: block; }
.pickbtn { display: block; width: 100%; text-align: left; font: inherit; font-size: 12px; line-height: 18px; color: var(--ink); cursor: pointer;
  background: var(--input-bg); border: 1px solid var(--input-line); border-radius: 8px; padding: 5px 8px; min-height: 30px; overflow-wrap: anywhere; }
.pickbtn:hover { border-color: var(--input-focus); }
.pickbtn.flagged { border-color: var(--warn-line); background: var(--warn-bg); }
.pickempty { color: var(--muted); font-style: italic; }
.pickdlg { width: min(860px, 94vw); }
.pickhelp { margin: 2px 0 12px; font-size: 13px; }
.pickpanes { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: stretch; }
.pickpane { border: 1px solid var(--line); border-radius: 10px; display: flex; flex-direction: column; min-width: 0; }
.pickhead { display: flex; align-items: center; gap: 8px; padding: 9px 12px; font-weight: 600; border-bottom: 1px solid var(--line); cursor: pointer; }
.picksearch { margin: 8px 10px; width: auto !important; }
.pickbox { list-style: none; margin: 0; padding: 0 0 6px; height: 300px; overflow-y: auto; border-top: 1px solid var(--line); }
.pickbox li label { display: flex; align-items: center; gap: 12px; padding: 7px 12px; border-bottom: 1px solid var(--line); cursor: pointer; user-select: none; }
.pickbox li label:hover { background: var(--ro); }
.pickbox input[type=checkbox] { align-self: center; }
.pickitem { display: flex; flex-direction: column; min-width: 0; }
.picknm { font-weight: 500; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.pickdesc { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pickin { font-size: 11px; font-weight: 600; color: var(--muted); border: 1px solid var(--input-line); border-radius: 6px; padding: 0 6px; }
.pickmove { display: flex; flex-direction: column; justify-content: center; gap: 10px; }
.pickmove .iconbtn { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); font-size: 20px; line-height: 1; }
.pickdlg .actions { display: flex; align-items: center; gap: 8px; margin-top: 16px; }
.pickdlg .actions .grow { flex: 1; }
.pickmove .iconbtn:hover { color: var(--ink); border-color: var(--input-focus); }

/* Summary values copy on right-click */
table[data-copy-cells] tbody td:not(.muted):not(:empty):hover { background: var(--ro); cursor: copy; }
table[data-copy-cells] .cv { border-radius: 3px; }
table[data-copy-cells] .cv:hover { background: var(--nav-active); outline: 1px solid var(--input-focus); outline-offset: 1px; }

/* Summary: Save as PDF button at the right of the config title */
.headactions { margin-left: auto; align-self: center; display: flex; gap: 8px; }

.pdfconfirm { width: min(560px, 94vw); }
.pdfconfirm table.gaps { width: 100%; margin-top: 6px; }
.pdfconfirm table.gaps td:not(:first-child), .pdfconfirm table.gaps th:not(:first-child) { text-align: center; width: 1%; white-space: nowrap; padding-left: 16px; }

/* several IPs in one field: dialog */
.ipdlg { width: min(520px, 94vw); }
.ipdlg .iphelp { margin: 2px 0 14px; font-size: 13px; }
.ipdlg .iplist { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.ipdlg .iprow { display: flex; align-items: center; gap: 8px; }
.ipdlg .iprow input { width: calc(13ch + 20px) !important; flex: none; }
.ipdlg .iprow input.ipwarn { border-color: var(--warn-line); background: var(--warn-bg); }
.ipdlg .ipmsg { font-size: 12px; color: var(--warn); }
[data-col-gate][hidden] { display: none; }

/* sub-tabs (Firewall page) */
.subtabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 14px; border-bottom: 1px solid var(--line); }
.subtab { font: inherit; font-weight: 600; font-size: 14px; color: var(--muted); background: none; border: 1px solid transparent; border-bottom: 0;
  border-radius: 8px 8px 0 0; padding: 8px 14px; cursor: pointer; margin-bottom: -1px; }
.subtab:hover { color: var(--ink); }
.subtab.active { color: var(--ink); background: var(--card); border-color: var(--line); }
.fwhead { margin: 16px 0 6px; font-size: 15px; }
table.fwdc { width: 100%; }
table.fwdc th { width: 260px; text-align: left; font-weight: 500; }
table.fwrules td.fw-port, table.fwrules td.fw-protocol, table.fwrules th.fw-port, table.fwrules th.fw-protocol { text-align: center; white-space: nowrap; width: 1%; }
table.fwrules td.fw-from, table.fwrules td.fw-to { min-width: 180px; }
table.fwrules td.fw-purpose { min-width: 260px; }
table.fwrules td.fw-na { color: var(--muted); }

/* Copy from vSphere config */
.importdlg { width: min(760px, 94vw); }
.importdlg .importsources { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 12px; }
.importdlg .importdirty { color: var(--warn); font-weight: 600; }
.importdlg .importconflicts-head { color: var(--warn); font-weight: 600; margin-bottom: 6px; }
.importdlg .importconflicts { max-height: 320px; overflow-y: auto; }

.importdlg .actions { display: flex; align-items: center; gap: 8px; }
.importdlg .actions .grow { flex: 1; }
.importdlg .importhelp { line-height: 1.6; }

/* several fields in one cell: dialog */
.partsdlg { width: min(560px, 94vw); }
.partsdlg .partsgrid { grid-template-columns: 200px 1fr; margin-bottom: 8px; }
.partsdlg .actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.partsdlg .actions .grow { flex: 1; }
.importdlg .importsummary { margin: 6px 0 10px; padding-left: 18px; line-height: 1.6; }
.importdlg .importmsg { color: var(--warn); font-weight: 600; }
.importdlg .importsources label { display: flex; align-items: center; gap: 8px; }

/* "Deployed to" cells stay on one line (the full text is in the tooltip and the dialog) */
.pickbtn[data-parts-open] { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Firewall: what each address group is, above the addresses */
table.fwrules .fwgroup { display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; white-space: nowrap; }

/* ---------------------------------------------------------------- help panel (? in the top bar) */
.helpbtn { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line); background: none; color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; line-height: 1; padding: 0; }
.helpbtn:hover, .helpbtn[aria-expanded="true"] { border-color: var(--input-focus); background: var(--nav-active); }
.helpscrim { position: fixed; inset: 0; z-index: 90; background: rgba(2, 6, 23, .35); opacity: 0; visibility: hidden; transition: opacity .2s, visibility .2s; }
.helppanel { position: fixed; top: 0; right: 0; bottom: 0; z-index: 91; width: min(460px, 92vw); display: flex; flex-direction: column;
  background: var(--card); border-left: 1px solid var(--line); box-shadow: -12px 0 32px rgba(0, 0, 0, .35);
  transform: translateX(100%); visibility: hidden; transition: transform .22s ease, visibility .22s; outline: none; }
body.help-open .helppanel { transform: none; visibility: visible; }
body.help-open .helpscrim { opacity: 1; visibility: visible; }
.helphead { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.helphead h2 { margin: 0; font-size: 18px; color: var(--heading); }
.helphead .iconbtn { font-size: 16px; }
.helpbody { padding: 4px 20px 24px; overflow-y: auto; font-size: 14px; line-height: 1.5; }
.helpbody p { margin: 10px 0; }
.helpbody h3 { margin: 20px 0 6px; font-size: 15px; color: var(--heading); }
.helpfields { margin: 6px 0 0; }
.helpfields dt { font-weight: 600; color: var(--heading); margin-top: 10px; }
.helpfields dd { margin: 2px 0 0; color: var(--muted); }
.helpflag { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; padding: 1px 6px;
  border-radius: 6px; vertical-align: 1px; background: var(--chip); color: var(--chip-ink); }
.helpflag-required { background: var(--msg-error-bg); color: var(--err); }
.helplist { margin: 6px 0 0; padding-left: 18px; }
.helplist li { margin: 4px 0; }
.actions .pushright { margin-left: auto; }
.card .importconflicts-head { color: var(--warn); font-weight: 600; margin: 16px 0 8px; }
.formrow label.radio { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.formrow label.radio input { width: auto; margin: 0; }
.card.importcard { max-width: 880px; }
