/* AS197658 peering portal.
   Palette taken from fibre patch cables: single-mode yellow, OM3 aqua,
   on cool rack-grey. Signal colours map to Cachet states. */
:root {
  --bg: #eef1f4;
  --surface: #ffffff;
  --ink: #1d2430;
  --muted: #5b6675;
  --line: #d5dbe2;
  --aqua: #00707c;
  --aqua-soft: #e0f1f2;
  --fiber: #f2c500;
  --ok: #2e7d4f;
  --warn: #9a5b00;
  --bad: #b42318;
  --radius-s: 4px;
  --radius-m: 8px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 var(--font); font-feature-settings: "tnum" 1;
}
a { color: var(--aqua); text-underline-offset: 2px; }
a:hover { color: var(--ink); }
:focus-visible { outline: 3px solid var(--fiber); outline-offset: 2px; }
h1 { font-size: 1.9rem; line-height: 1.2; margin: 0 0 .6rem; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .4rem; }
p { margin: 0 0 .8rem; }
code { font-family: var(--mono); font-size: .88em; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 1.25rem; }
.mt { margin-top: 2.25rem; }
.sub { display: block; color: var(--muted); font-size: .85rem; font-weight: 400; }
.nowrap { white-space: nowrap; }
.lead { font-size: 1.1rem; color: var(--muted); max-width: 62ch; }
.hint { color: var(--muted); font-size: .9rem; max-width: 60ch; margin-top: 1rem; }

/* Header */
.top { background: var(--ink); color: #fff; }
.top-inner { display: flex; align-items: center; gap: 2rem; min-height: 60px; flex-wrap: wrap; }
.brand { color: #fff; text-decoration: none; display: flex; align-items: baseline; gap: .5rem; }
.brand-asn { font-weight: 700; font-size: 1.1rem; padding-left: .6rem; border-left: 4px solid var(--fiber); }
.brand-name { color: #b9c3cf; }
.nav { display: flex; gap: 1.25rem; flex: 1; }
.nav a { color: #d7dde5; text-decoration: none; }
.nav a:hover { color: #fff; text-decoration: underline; }
.nav-admin { color: var(--fiber) !important; }
.who { display: flex; align-items: center; gap: .75rem; color: #b9c3cf; font-size: .9rem; }
.who form { margin: 0; }
.who .link-btn { color: #d7dde5; }

/* Network status strip */
.netstatus { display: block; text-decoration: none; color: var(--ink); background: var(--surface);
  border-bottom: 1px solid var(--line); font-size: .9rem; }
.netstatus-inner { display: flex; align-items: center; gap: .6rem; min-height: 38px; flex-wrap: wrap; }
.netstatus-inc { color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.lvl-ok .dot { background: var(--ok); }
.lvl-degraded .dot { background: var(--fiber); }
.lvl-partial .dot { background: var(--warn); }
.lvl-major .dot { background: var(--bad); }
.netstatus.lvl-partial, .netstatus.lvl-major { background: #fff4e5; }
.netstatus.lvl-major { background: #fdecea; color: var(--bad); font-weight: 600; }

.main { padding-top: 2rem; padding-bottom: 3rem; min-height: 60vh; }
.foot { display: flex; gap: 1.5rem; flex-wrap: wrap; padding-top: 1.5rem; padding-bottom: 2rem;
  border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; }

/* Flash */
.flash { padding: .75rem 1rem; border-radius: var(--radius-s); margin-bottom: 1rem;
  background: var(--aqua-soft); border-left: 4px solid var(--aqua); }
.flash-error { background: #fdecea; border-left-color: var(--bad); }
.flash-ok { background: #e7f3ec; border-left-color: var(--ok); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: .4rem; font: inherit; font-weight: 600;
  padding: .55rem 1rem; border-radius: var(--radius-s); border: 1px solid var(--ink);
  background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--bg); color: var(--ink); }
.btn-primary { background: var(--aqua); border-color: var(--aqua); color: #fff; }
.btn-primary:hover { background: #005860; color: #fff; }
.btn-lg { padding: .8rem 1.4rem; font-size: 1.05rem; }
.btn-sm { padding: .3rem .7rem; font-size: .85rem; }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--aqua);
  cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.link-btn.danger { color: var(--bad); }

/* Landing */
.hero { padding: 2rem 0 2.5rem; }
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); font-weight: 800; letter-spacing: -.02em; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 1.1rem 1.25rem; }
.panel p:last-child { margin-bottom: 0; }
.panel-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.panel-row p { margin: 0; max-width: 60ch; }
.empty { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius-m); padding: 1.5rem; }

/* Network page */
.asn { font-family: var(--mono); font-weight: 700; }
.nethead h1 .asn { color: var(--aqua); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .9rem 1.5rem;
  margin: 1rem 0 2rem; padding: 1rem 1.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); }
.facts dt { font-size: .8rem; color: var(--muted); }
.facts dd { margin: 0; word-break: break-word; }
.facts dd code { display: block; }
.facts-wide { grid-template-columns: 1fr; margin-top: 0; }
.netlist { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.netlist li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s); padding: .7rem 1rem; }
.netlist a { text-decoration: none; }

/* Exchange "ports": the signature element, a patch cable per shared IX */
.ports { list-style: none; padding: 0; margin: 0; display: grid; gap: .6rem; }
.port { display: grid; grid-template-columns: minmax(180px, 1.2fr) 2fr auto; gap: 1rem; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: .9rem 1.1rem .9rem 1.4rem; position: relative; }
.port::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px;
  background: var(--fiber); border-radius: var(--radius-s) 0 0 var(--radius-s); }
.port-requested::before { background: var(--aqua); }
.port-ips { display: grid; gap: .25rem; font-size: .9rem; }
.port-ips div { display: flex; gap: .8rem; flex-wrap: wrap; align-items: baseline; }
.port-ips .lbl { width: 2.2rem; color: var(--muted); font-size: .8rem; }
.port-act { justify-self: end; }

/* Dialog */
.dialog { border: 0; border-radius: var(--radius-m); padding: 0; width: min(560px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem); box-shadow: 0 24px 60px rgba(29, 36, 48, .35); color: var(--ink); }
.dialog::backdrop { background: rgba(29, 36, 48, .55); }
.dialog[open] { animation: dlg-in .16s ease-out; }
@keyframes dlg-in { from { opacity: 0; transform: translateY(8px); } }
.dialog .form { padding: 1.25rem 1.5rem 1.5rem; }
.dialog-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  border-bottom: 1px solid var(--line); margin: -1.25rem -1.5rem 1rem; padding: 1rem 1.5rem; }
.dialog-head h2 { margin: 0; }
.dialog-foot { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
  border-top: 1px solid var(--line); margin: 1.25rem -1.5rem -1.5rem; padding: 1rem 1.5rem; background: var(--bg); }
.dlg-ix code { margin-right: .75rem; }

/* Forms */
.form fieldset { border: 0; padding: 0; margin: 0 0 1.1rem; }
.form legend { font-weight: 700; margin-bottom: .5rem; }
.field { display: block; margin-bottom: .9rem; font-weight: 600; font-size: .92rem; }
.field .sub { display: inline; margin-left: .3rem; }
.field input, .field select, .field textarea, .search input {
  display: block; width: 100%; margin-top: .3rem; font: inherit; font-weight: 400; color: var(--ink);
  padding: .5rem .65rem; border: 1px solid #b8c1cc; border-radius: var(--radius-s); background: #fff; }
.field textarea { resize: vertical; }
.field.inline { display: inline-block; margin: 0; }
.field.inline select { display: inline-block; width: auto; }
.choice { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.choice label { cursor: pointer; }
.choice-stack { flex-direction: column; gap: .6rem; }
.choice-stack .sub { margin-left: 1.6rem; }
.check { display: flex; gap: .5rem; align-items: flex-start; font-size: .9rem; margin-bottom: .6rem; }
.check input { margin-top: .3rem; }
.row { display: flex; gap: .75rem; align-items: flex-end; flex-wrap: wrap; }
[hidden] { display: none !important; }

/* Tables */
.table-scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); }
.tickets { width: 100%; border-collapse: collapse; font-size: .93rem; }
.tickets th { text-align: left; font-size: .8rem; color: var(--muted); font-weight: 600; padding: .6rem .9rem; border-bottom: 1px solid var(--line); }
.tickets td { padding: .65rem .9rem; border-bottom: 1px solid var(--bg); vertical-align: top; }
.tickets tr:last-child td { border-bottom: 0; }
.tickets td a { font-weight: 600; font-family: var(--mono); }

/* Status badges */
.badge { display: inline-block; font-size: .78rem; font-weight: 600; padding: .12rem .5rem; border-radius: 999px;
  background: var(--bg); color: var(--ink); border: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
.st-new { background: #fff7cc; border-color: #e6c200; }
.st-in_progress, .st-provisioning { background: var(--aqua-soft); border-color: #9fd3d8; color: #004f57; }
.st-waiting_peer { background: #fff1dd; border-color: #f0c07a; color: var(--warn); }
.st-active { background: #e7f3ec; border-color: #a8d5b9; color: var(--ok); }
.st-rejected { background: #fdecea; border-color: #f2b8b2; color: var(--bad); }
.st-closed, .st-cancelled { color: var(--muted); }

/* Ticket view */
.tickethead { margin-bottom: 1.5rem; }
.tickethead h1 { font-size: 1.5rem; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 2rem; align-items: start; }
.col-side > * + * { margin-top: 1rem; }
.thread { list-style: none; padding: 0; margin: 0 0 1.5rem; display: grid; gap: .75rem; }
.msg { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: .8rem 1rem; }
.msg.first { margin-bottom: .75rem; }
.msg header { display: flex; gap: .6rem; align-items: baseline; margin-bottom: .35rem; flex-wrap: wrap; }
.msg time, .ev time { color: var(--muted); font-size: .8rem; margin-left: auto; }
.msg .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.staff { border-left: 4px solid var(--aqua); }
.msg.internal { background: #fffbe6; border-style: dashed; }
.ev { display: flex; gap: .75rem; font-size: .85rem; color: var(--muted); padding: 0 .25rem; }
.ev.internal { font-style: italic; }
.reply { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 1rem; }
.withdraw { margin-top: 1rem; }
.links { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .9rem; }
details.panel summary { cursor: pointer; font-weight: 600; }
details.panel[open] summary { margin-bottom: .8rem; }
code.block, .wrapcode { display: block; white-space: pre-wrap; word-break: break-all; }
.codebox { position: relative; }
.codebox pre { background: var(--ink); color: #e8edf2; padding: 1rem 1.1rem; border-radius: var(--radius-m);
  overflow-x: auto; font: .85rem/1.5 var(--mono); margin: 0; }
.codebox .btn { position: absolute; top: .6rem; right: .6rem; background: #2d3848; color: #fff; border-color: #445166; }

/* Admin toolbar */
.toolbar { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; align-items: center; }
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; }
.tabs a { padding: .35rem .7rem; border-radius: var(--radius-s); text-decoration: none; color: var(--ink); font-size: .9rem; }
.tabs a[aria-current] { background: var(--ink); color: #fff; }
.tabs .count { color: var(--muted); font-size: .8rem; }
.tabs a[aria-current] .count { color: #b9c3cf; }
.search input { margin: 0; min-width: 240px; }

/* Status page */
.components { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); }
.components li { display: flex; align-items: center; gap: .75rem; padding: .7rem 1rem; border-bottom: 1px solid var(--bg); }
.components li:last-child { border-bottom: 0; }
.c-name { flex: 1; }
.c-state { color: var(--muted); font-size: .9rem; }
.incident { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--warn);
  border-radius: var(--radius-s); padding: .9rem 1.1rem; margin-bottom: .75rem; }

@media (max-width: 860px) {
  .cols { grid-template-columns: 1fr; }
  .port { grid-template-columns: 1fr; }
  .port-act { justify-self: start; }
  .top-inner { gap: .75rem 1.5rem; padding-top: .6rem; padding-bottom: .6rem; }
}
@media (prefers-reduced-motion: reduce) {
  .dialog[open] { animation: none; }
}
