:root {
  --bg: #f4f5f2;
  --card: #ffffff;
  --text: #1a1f1d;
  --muted: #5d6662;
  --line: #dfe3df;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --input: #fbfcfb;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --free: repeating-linear-gradient(45deg, #e7ebe7 0 6px, #f3f5f3 6px 12px);
  --shadow: 0 1px 2px rgb(0 0 0 / .05), 0 4px 16px rgb(0 0 0 / .04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111513;
    --card: #1a201d;
    --text: #e6ebe8;
    --muted: #97a29d;
    --line: #2d3531;
    --accent: #2dd4bf;
    --accent-ink: #062320;
    --input: #141917;
    --danger: #ff8a80;
    --danger-bg: #3a1d1b;
    --free: repeating-linear-gradient(45deg, #222a26 0 6px, #1a201d 6px 12px);
    --shadow: none;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "IBM Plex Sans", system-ui, sans-serif;
}
.mono, code, td.mono { font-family: "IBM Plex Mono", ui-monospace, monospace; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

.top { padding: 40px 0 24px; }
.top h1 { margin: 0 0 6px; font-size: 30px; letter-spacing: -.02em; }
.top h1::before {
  content: ""; display: inline-block; width: 14px; height: 14px; margin-right: 10px;
  border-radius: 3px; background: var(--accent); vertical-align: 2px;
}
.lead { margin: 0; color: var(--muted); max-width: 640px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 14px; font-size: 17px; }
.card-head { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); font-weight: 500; }
input, select {
  font: inherit; font-size: 15px; color: var(--text); background: var(--input);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; min-width: 0;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input.invalid { border-color: var(--danger); }
.note { margin: 12px 0 0; font-size: 13px; color: var(--muted); }

.btn {
  font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 8px; padding: 7px 12px;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.icon { padding: 6px 10px; color: var(--muted); }

.vlan-list { display: flex; flex-direction: column; gap: 8px; }
.vlan-row { display: grid; grid-template-columns: 12px 90px 1fr 120px auto; gap: 8px; align-items: center; }
.vlan-row .swatch { width: 12px; height: 32px; border-radius: 3px; }
.vlan-head { font-size: 12px; color: var(--muted); font-weight: 500; }
.empty { color: var(--muted); font-size: 14px; padding: 6px 0; }

.errors:empty { display: none; }
.errors { background: var(--danger-bg); color: var(--danger); border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; font-size: 14px; }
.errors p { margin: 0; }
.errors p + p { margin-top: 4px; }

.summary { display: flex; flex-wrap: wrap; gap: 24px; margin-bottom: 14px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 20px; font-weight: 600; font-family: "IBM Plex Mono", monospace; }

.bar { display: flex; height: 34px; border-radius: 8px; overflow: hidden; background: var(--free); border: 1px solid var(--line); }
.bar span {
  display: flex; align-items: center; justify-content: center; min-width: 2px;
  font-size: 11px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden;
  border-right: 1px solid var(--card);
}
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 10px 0 16px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 8px 12px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--line); }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--input); position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td .tag { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 8px; }

#free h3 { font-size: 14px; margin: 18px 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-family: "IBM Plex Mono", monospace; font-size: 13px; padding: 3px 8px; border: 1px dashed var(--line); border-radius: 6px; color: var(--muted); }

.config { margin: 0; padding: 14px; background: var(--input); border: 1px solid var(--line); border-radius: 8px; font-size: 13px; overflow-x: auto; max-height: 360px; }

.foot { color: var(--muted); font-size: 13px; padding-bottom: 40px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 8px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

[hidden] { display: none !important; }

@media (max-width: 600px) {
  .top { padding: 24px 0 16px; }
  .top h1 { font-size: 24px; }
  .card { padding: 16px; }
  .vlan-row { grid-template-columns: 8px 70px 1fr 80px auto; gap: 6px; }
}
