/* Switch Port Map styles. Colors are theme variables: light on :root, dark below. */
:root {
  color-scheme: light;
  --bg: #f6f7f9; --card: #fff; --ink: #1d2330; --muted: #677085; --line: #d9dde5;
  --accent: #e8a24a; --accent-soft: #f6dfbf; --focus: #3b6fd8; --bad: #c8412f; --good: #2f7d4f;
  --input: #fff; --soft: #eef0f4; --derived: #f0f2f5; --hover: #fbf6ee; --bad-soft: #fdecea; --track: #eceef2;
  --dirty: #a2640f; --accent-ink: #7a4a10; --overlay: rgba(29, 35, 48, .55);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14171c; --card: #1c2027; --ink: #e6e9ef; --muted: #9aa3b5; --line: #323946;
  --accent: #e8a24a; --accent-soft: #4a3820; --focus: #7aa5ff; --bad: #ff8a75; --good: #62c991;
  --input: #232831; --soft: #262c36; --derived: #20252d; --hover: #2b2721; --bad-soft: #3d2420; --track: #323946;
  --dirty: #f0b25a; --accent-ink: #f3c98a; --overlay: rgba(0, 0, 0, .6);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #14171c; --card: #1c2027; --ink: #e6e9ef; --muted: #9aa3b5; --line: #323946;
    --accent: #e8a24a; --accent-soft: #4a3820; --focus: #7aa5ff; --bad: #ff8a75; --good: #62c991;
    --input: #232831; --soft: #262c36; --derived: #20252d; --hover: #2b2721; --bad-soft: #3d2420; --track: #323946;
    --dirty: #f0b25a; --accent-ink: #f3c98a; --overlay: rgba(0, 0, 0, .6);
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink);
       font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a { color: var(--focus); text-decoration: none; }
a:hover { text-decoration: underline; }
.top { background: var(--card); border-bottom: 1px solid var(--line); padding: 12px 16px; position: sticky; top: 0; z-index: 5; }
.top .inner { max-width: 960px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: baseline; }
.top .spacer { flex: 1; }
.brand { font-weight: 700; color: var(--ink); }
#crumbs { color: var(--muted); }
#crumbs .sep { margin: 0 6px; }
#account { color: var(--muted); font-size: 13px; }
button.link { border: 0; background: none; padding: 0; color: var(--focus); font: inherit; cursor: pointer; }
button.link:hover { text-decoration: underline; }
main { max-width: 960px; margin: 0 auto; padding: 20px 16px 96px; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0; }
.muted { color: var(--muted); }
.pagehead { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.pagehead .spacer { flex: 1; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
a.site { display: block; color: inherit; margin: 0; transition: border-color .15s; }
a.site:hover { border-color: var(--accent); text-decoration: none; }
.sitecode { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 4px 12px; cursor: pointer; font: inherit; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--card); }
.idfhead { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.idfhead .spacer { flex: 1; }
table { border-collapse: collapse; width: 100%; }
.tablewrap { overflow-x: auto; }
table.list th, table.list td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list th { color: var(--muted); font-weight: 600; font-size: 12px; }
table.list tbody tr { cursor: pointer; }
table.list tbody tr:hover { background: var(--hover); }
.host { font-family: ui-monospace, Menlo, monospace; font-weight: 600; }
.bar { display: inline-block; width: 60px; height: 6px; background: var(--track); border-radius: 3px; vertical-align: middle; margin-right: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }

.fields { display: grid; grid-template-columns: 160px 1fr; gap: 8px 12px; align-items: center; }
.fields label { font-weight: 600; text-align: right; }
input, select { font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; width: 100%; background: var(--input); color: inherit; }
input:focus, select:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; }
.req { background: var(--accent-soft); }
.derived { background: var(--derived); color: var(--muted); }
input.invalid { border-color: var(--bad); background: var(--bad-soft); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .spacer { flex: 1; }
button, .btn { font: inherit; padding: 7px 12px; border-radius: 6px; border: 1px solid var(--line); background: var(--input); color: var(--ink); cursor: pointer; display: inline-block; }
button:hover, .btn:hover { border-color: var(--muted); text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.danger { color: var(--bad); }
button:disabled { opacity: .6; cursor: default; }
.stats { color: var(--muted); font-size: 13px; }
.status { font-size: 13px; color: var(--muted); }
.status.dirty { color: var(--dirty); font-weight: 600; }
.status.ok { color: var(--good); }
.status.err { color: var(--bad); font-weight: 600; }
table.ports th, table.ports td { border: 1px solid var(--line); padding: 0; }
table.ports th { background: var(--soft); padding: 8px; text-align: center; }
td.port { padding: 6px 10px; font-family: ui-monospace, Menlo, monospace; white-space: nowrap; width: 1%; }
td input, td select { border: 0; border-radius: 0; }
td.vlan { width: 90px; }
td.prof { padding: 6px 10px; font-family: ui-monospace, Menlo, monospace; color: var(--muted); white-space: nowrap; }
table.no-prof .prof { display: none; }
tr.filled td.port { font-weight: 600; }
.note { font-size: 12px; color: var(--muted); margin-top: 6px; }

.uform { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; align-items: end; margin-top: 12px; }
.uform label { display: grid; gap: 4px; font-weight: 600; font-size: 13px; }
.uform .check { display: flex; gap: 6px; align-items: center; font-weight: 400; }
.uform .check input { width: auto; }
.uform .row { display: flex; gap: 8px; }
table.users tbody tr { cursor: default; }
table.users tbody tr:hover { background: none; }
table.users td { vertical-align: middle; }
.uname { font-weight: 600; }
.ufull { color: var(--muted); font-size: 12px; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--soft); }
.badge.admin { background: var(--accent-soft); color: var(--accent-ink); }
.badge.temp { background: var(--bad-soft); color: var(--bad); }
.actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.actions button { padding: 4px 10px; font-size: 13px; }
.tempbox { margin-top: 12px; padding: 12px 14px; border-radius: 8px; background: var(--hover); border: 1px solid var(--accent); }
.tempbox code { font-size: 17px; font-weight: 700; padding: 2px 8px; background: var(--input); border-radius: 4px; user-select: all; }

.leave { position: fixed; left: 0; right: 0; bottom: 0; background: var(--ink); color: var(--card); z-index: 10;
         padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); }
.leave .inner { max-width: 960px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.leave .spacer { flex: 1; }

.auth { position: fixed; inset: 0; background: var(--overlay); z-index: 20; display: grid; place-items: center; padding: 16px; }
.authcard { width: 100%; max-width: 380px; margin: 0; display: grid; gap: 12px; }
.authcard label { display: grid; gap: 4px; font-weight: 600; }
.authcard .row { display: flex; gap: 8px; }
.authcard .status:empty { display: none; }

@media (max-width: 560px) {
  .fields { grid-template-columns: 1fr; }
  .fields label { text-align: left; }
}
.tech-view .not-tech, .tech-view .vlan, .tech-view .prof { display: none !important; }
.siteform { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; align-items: end; }
.siteform label { display: grid; gap: 4px; font-weight: 600; font-size: 13px; }
.siteform .row { display: flex; gap: 8px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.filters select, .filters input { width: auto; flex: 1 1 160px; }
table.log td { white-space: normal; vertical-align: top; }
table.log td.nowrap { white-space: nowrap; }
table.log ul { margin: 0; padding-left: 16px; font-size: 13px; }
table.log .more { font-size: 12px; }
.act { font-weight: 600; }
.act.bad { color: var(--bad); }
.siteform .wide { grid-column: span 2; }
@media (max-width: 560px) { .siteform .wide { grid-column: auto; } }
.sitename { color: var(--muted); margin: -4px 0 6px; }

@media print {
  :root:not([data-print]), :root[data-theme] {
    --ink: #000; --muted: #444; --line: #ccc; --card: #fff; --input: #fff; --soft: #eee; --derived: #fff; --bg: #fff;
  }
  body { background: #fff; }
  .top, .toolbar, .no-print, .leave, .auth { display: none !important; }
  .card { border: 0; padding: 0; }
  input, select { border: 0; appearance: none; -webkit-appearance: none; background: none !important; padding: 2px 4px; }
}
