/* Shared components, built only from tokens.css. */

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--text-md);
  line-height: 1.45;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.95em;
  font-variant-numeric: tabular-nums;
}

.muted { color: var(--text-muted); }

/* Item types: each differs in shape and line, as well as colour. */
.item {
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border: 1.5px solid;
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
}
.item .mono { font-weight: 400; }

/* Node: square corners, the heaviest line. */
.item-node {
  background: var(--node-fill);
  border-color: var(--node-line);
  border-width: 2px;
  border-radius: 0;
  color: var(--node-text);
}
/* SubNode: rounded corners and a thin line, as it belongs to a Node. */
.item-subnode {
  background: var(--subnode-fill);
  border-color: var(--subnode-line);
  border-width: 1px;
  border-radius: var(--radius-md);
  color: var(--subnode-text);
}
/* Interface: a capsule, as it is a flow between things. */
.item-interface {
  background: var(--interface-fill);
  border-color: var(--interface-line);
  border-radius: var(--radius-pill);
  color: var(--interface-text);
}
/* External keeps the shape of its type and adds a dashed line and a label. */
.item-external {
  background: var(--external-fill);
  border-color: var(--external-line);
  border-style: dashed;
  color: var(--external-text);
}
.external-mark {
  display: inline-block;
  padding: 0 0.4em;
  border-radius: var(--radius-sm);
  background: var(--external-line);
  color: var(--on-external);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: 0.1em;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* PAN: a name and a level, so colour is never the only signal. */
.pan {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 1px var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
}
.pan-level { display: inline-flex; gap: 2px; }
.pan-level i {
  display: block;
  width: 4px;
  height: 10px;
  border: 1px solid currentColor;
}
.pan-level i.on { background: currentColor; }
.pan-clear { background: var(--pan-clear-bg); color: var(--pan-clear-fg); }
.pan-masked { background: var(--pan-masked-bg); color: var(--pan-masked-fg); }
.pan-truncated { background: var(--pan-truncated-bg); color: var(--pan-truncated-fg); }
.pan-hashed { background: var(--pan-hashed-bg); color: var(--pan-hashed-fg); }
.pan-encrypted { background: var(--pan-encrypted-bg); color: var(--pan-encrypted-fg); }
.pan-off {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-weight: 400;
}

/* Status */
.status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
  font-weight: 500;
}
.status svg { width: 12px; height: 12px; fill: currentColor; }
.status-running { color: var(--success); }
.status-retired { color: var(--text-muted); }

/* Controls */
.button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 32px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}
.button:hover { background: var(--surface-sunken); }
.button-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.button-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.button-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--on-danger);
}
.button-danger:hover { background: var(--danger); filter: brightness(0.92); }
.button:disabled {
  background: var(--surface-sunken);
  border-color: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
}

.field { display: grid; gap: var(--space-1); }
.field label { font-size: var(--text-sm); font-weight: 500; }
.field .hint { font-size: var(--text-xs); color: var(--text-muted); }
.field .problem { font-size: var(--text-xs); color: var(--danger); font-weight: 500; }
.input {
  min-height: 32px;
  width: 100%;
  padding: 0 var(--space-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.input[aria-invalid="true"] { border-color: var(--danger); border-width: 2px; }

/* A switch shows its state in position and in words. */
.switch { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track {
  position: relative;
  width: 32px;
  height: 18px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
}
.switch .track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-muted);
}
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track::after { left: 16px; background: var(--on-accent); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Alerts */
.alert {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-left: 3px solid;
  font-size: var(--text-sm);
}
.alert-warning { background: var(--warning-bg); border-color: var(--warning); }
.alert-danger { background: var(--danger-bg); border-color: var(--danger); }
.alert-success { background: var(--success-bg); border-color: var(--success); }
.alert-info { background: var(--accent-soft); border-color: var(--accent); }

/* Tables are dense: this is a working tool. */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th, .table td {
  padding: var(--space-1) var(--space-3);
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}
.table thead th {
  position: sticky;
  top: 0;
  background: var(--surface-sunken);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 600;
}
.table .group-start { border-left: 1px solid var(--border); }
.table tbody tr:hover { background: var(--accent-soft); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.cell-external { background: var(--external-fill); color: var(--external-text); }
.table td.cell-external-start { box-shadow: inset 3px 0 0 var(--external-line); }