* { box-sizing: border-box; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--font-heading); font-weight: 700; margin: 0; color: var(--ink); }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.05rem; }
.admin-shell { display: flex; min-height: 100vh; }
.admin-nav {
  width: 232px; flex: 0 0 auto; background: var(--bg-dark); color: rgba(255, 255, 255, .78);
  padding: var(--space-6) var(--space-5); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.admin-nav .brand {
  display: flex; align-items: center; gap: var(--space-2); color: #fff;
  font-family: var(--font-heading); font-weight: 700; font-size: 1.05rem;
  padding-bottom: var(--space-5); margin-bottom: var(--space-5);
  border-bottom: 1px solid rgba(255, 255, 255, .1);
}
.admin-nav .brand img { width: 26px; height: 26px; }
.admin-nav .nav-label {
  font-family: var(--font-mono); font-size: .68rem; letter-spacing: .08em; text-transform: uppercase;
  color: rgba(255, 255, 255, .38); margin-bottom: var(--space-3); padding-inline: var(--space-3);
}
.admin-nav ul { list-style: none; margin: 0 0 var(--space-6); padding: 0; display: flex; flex-direction: column; gap: 2px; }
.admin-nav a {
  color: rgba(255, 255, 255, .72); padding: .6em var(--space-3); border-radius: var(--radius-sm);
  display: block; font-weight: 600; font-size: .92rem; border-left: 3px solid transparent;
  transition: background .12s ease, color .12s ease;
}
.admin-nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.admin-nav a.active {
  background: rgba(110, 231, 216, .1); color: #fff; border-left-color: var(--mint); text-decoration: none;
}
.admin-nav-footer {
  margin-top: auto; padding-top: var(--space-5); border-top: 1px solid rgba(255, 255, 255, .1);
  display: flex; flex-direction: column; gap: var(--space-2);
}
.admin-nav .role-tag {
  font-family: var(--font-mono); font-size: .68rem; letter-spacing: .04em; color: var(--mint); text-transform: uppercase;
}
.admin-nav-footer a { color: rgba(255, 255, 255, .6); padding: 0; font-weight: 600; font-size: .88rem; }
.admin-nav-footer a:hover { color: #fff; }
.admin-main { flex: 1 1 auto; padding: var(--space-8) var(--space-7); max-width: 1280px; min-width: 0; }
.admin-page-eyebrow {
  font-family: var(--font-mono); font-size: .78rem; font-weight: 500;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-faint); margin-bottom: var(--space-2); display: block;
}
.admin-topbar { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: var(--space-7); gap: var(--space-4); flex-wrap: wrap; }
.admin-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: var(--space-6); margin-bottom: var(--space-5);
  max-width: 100%;
}
.admin-card h2 {
  padding-bottom: var(--space-4); margin-bottom: var(--space-5); border-bottom: 1px solid var(--border);
}
.admin-card > h2:first-child,
.admin-card > .admin-toolbar:first-child + h2 { margin-top: 0; }
.admin-card--danger { border-color: rgba(217, 45, 32, .3); }
.admin-card--danger h2 { color: var(--warn); border-bottom-color: rgba(217, 45, 32, .2); }
.admin-table-wrap { overflow-x: auto; margin: 0 calc(var(--space-6) * -1); padding-inline: var(--space-6); }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td {
  text-align: left; padding: .8em var(--space-3); border-bottom: 1px solid var(--border);
  font-size: .88rem; white-space: nowrap;
}
.admin-table td:first-child, .admin-table th:first-child { padding-left: 0; }
.admin-table td:last-child, .admin-table th:last-child { padding-right: 0; }
.admin-table th {
  color: var(--ink-faint); font-weight: 600; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em;
}
.admin-table tbody tr:hover { background: var(--bg-alt); }
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table-action-col {
  position: sticky; right: 0; background: #fff;
  box-shadow: -8px 0 8px -8px rgba(16, 26, 51, .12);
}
.admin-table tbody tr:hover .admin-table-action-col { background: var(--bg-alt); }
.admin-table th a { color: inherit; display: inline-flex; align-items: center; gap: 4px; }
.admin-table th a:hover { color: var(--blue); text-decoration: none; }
.admin-table th a.active { color: var(--blue); }
.admin-form { display: flex; flex-direction: column; gap: var(--space-4); max-width: 420px; }
.admin-field { display: flex; flex-direction: column; gap: var(--space-2); }
.admin-field label { font-weight: 600; font-size: .85rem; }
.admin-field input, .admin-field select, .admin-field textarea {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .6em .8em; font: inherit;
  color: var(--ink); background: #fff;
}
.admin-field input:focus, .admin-field select:focus, .admin-field textarea:focus {
  outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.admin-hint { font-size: .8rem; color: var(--ink-faint); }
.admin-toolbar { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; margin-bottom: var(--space-5); }
.admin-toolbar input[type="text"], .admin-toolbar input[type="search"], .admin-toolbar select {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .6em .9em; font: inherit;
  height: 2.5em;
}
.admin-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  font-family: var(--font-heading); font-weight: 600; font-size: .92rem; border: none; border-radius: var(--radius-full);
  padding: .7em 1.4em; height: 2.5em; cursor: pointer; background: var(--blue); color: #fff; width: fit-content;
  transition: background .12s ease;
}
.admin-btn:hover { background: var(--navy); }
.admin-btn--ghost { background: #fff; color: var(--ink); border: 1px solid var(--border); }
.admin-btn--ghost:hover { border-color: var(--blue); color: var(--blue); background: #fff; }
.admin-btn--danger { background: var(--warn); color: #fff; box-shadow: none; }
.admin-btn--danger:hover { filter: brightness(1.1); box-shadow: var(--shadow-sm); }
.admin-row-actions { display: flex; gap: var(--space-3); align-items: center; }
.admin-link-btn {
  background: none; border: none; padding: 0; cursor: pointer; font: inherit;
  color: var(--blue); font-weight: 600; font-size: .82rem; white-space: nowrap;
}
.admin-link-btn:hover { text-decoration: underline; }
.admin-link-btn--danger { color: var(--warn); }
.admin-alert { border-radius: var(--radius-sm); padding: var(--space-3) var(--space-4); font-size: .88rem; margin-bottom: var(--space-4); font-weight: 600; }
.admin-alert--error { background: var(--warn-bg); color: var(--warn); }
.admin-alert--success { background: var(--ok-bg); color: var(--ok); }
.admin-tag {
  font-family: var(--font-mono); font-size: .7rem; padding: .2em .65em; border-radius: var(--radius-full);
  background: var(--bg-alt); color: var(--ink-soft); white-space: nowrap; display: inline-block;
}
.admin-tag--super { background: rgba(37, 99, 235, .12); color: var(--blue); }
.admin-tag--tenant { background: var(--ok-bg); color: var(--ok); }
.admin-tag--plan-starter { background: var(--bg-alt); color: var(--ink-soft); }
.admin-tag--plan-standard { background: rgba(37, 99, 235, .12); color: var(--blue); }
.admin-tag--plan-enterprise { background: var(--navy); color: #fff; }
.admin-tag--fallback { background: rgba(110, 231, 216, .18); color: var(--navy); margin-left: var(--space-2); }
.admin-snippet {
  background: var(--bg-dark); color: #d7e0f5; font-family: var(--font-mono); font-size: .82rem;
  padding: var(--space-4); border-radius: var(--radius-sm); overflow-x: auto; white-space: pre;
  line-height: 1.6;
}
.admin-auth-page {
  min-height: 100vh; display: grid; place-items: center; background: var(--navy);
}
.admin-auth-card {
  background: #fff; border-radius: var(--radius-lg); padding: var(--space-8); width: 100%;
  max-width: 380px; box-shadow: var(--shadow-lg);
}
.admin-auth-card .brand { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-5); font-family: var(--font-heading); font-weight: 700; }
.admin-auth-card .brand img { width: 30px; height: 30px; }
.admin-stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); }
.admin-stat { background: var(--bg-alt); border-radius: var(--radius-sm); padding: var(--space-4); }
.admin-stat .value { font-family: var(--font-heading); font-size: 1.7rem; font-weight: 700; color: var(--navy); }
.admin-stat .label { font-size: .78rem; color: var(--ink-faint); margin-top: 2px; }
.admin-checkbox-list {
  display: flex; flex-direction: column; gap: var(--space-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--space-3);
  max-height: 220px; overflow-y: auto;
}
.admin-checkbox-row { display: flex; align-items: center; gap: var(--space-2); font-size: .92rem; font-weight: 400; }
.admin-checkbox-row input { flex: 0 0 auto; }
.admin-chip-input {
  display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center;
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--space-2);
}
.admin-chip-input:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.admin-chip-input input {
  flex: 1 1 160px; border: none; padding: .4em .2em; font: inherit; min-width: 160px;
}
.admin-chip-input input:focus { outline: none; }
.admin-chip {
  display: inline-flex; align-items: center; gap: .4em; background: var(--bg-alt); color: var(--ink);
  border-radius: var(--radius-full); padding: .35em .5em .35em .9em; font-size: .85rem; white-space: nowrap;
}
.admin-chip__remove {
  background: none; border: none; cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 .3em;
  color: var(--ink-faint); border-radius: 50%;
}
.admin-chip__remove:hover { color: var(--warn); }
.admin-chip-input--autocomplete { position: relative; }
.admin-autocomplete {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: #fff;
  border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
  z-index: 10; max-height: 190px; overflow-y: auto;
}
.admin-autocomplete button {
  display: block; width: 100%; text-align: left; background: none; border: none; cursor: pointer;
  padding: .5em .8em; font: inherit; font-size: .88rem; color: var(--ink);
}
.admin-autocomplete button:hover { background: var(--bg-alt); }
.admin-tag-filter-bar { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-5); }
.admin-tag-filter {
  font-size: .82rem; padding: .35em .9em; border-radius: var(--radius-full); background: var(--bg-alt);
  color: var(--ink-soft); text-decoration: none; border: 1px solid transparent; cursor: pointer; font-family: inherit;
}
.admin-tag-filter:hover { border-color: var(--blue); color: var(--blue); }
.admin-tag-filter.active { background: var(--blue); color: #fff; }
.admin-row-tags { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: .4em; }
.admin-meter-label { display: flex; justify-content: space-between; font-size: .82rem; color: var(--ink-soft); margin-bottom: var(--space-2); }
.admin-meter-track { height: 10px; border-radius: var(--radius-full); background: var(--bg-alt); overflow: hidden; }
.admin-meter-fill { height: 100%; border-radius: var(--radius-full); background: var(--blue); }
.admin-meter-fill--warn { background: var(--warn); }
.admin-bar-chart { display: flex; align-items: flex-end; gap: 3px; height: 72px; }
.admin-bar-chart .bar { flex: 1 1 0; max-width: 24px; background: var(--blue); border-radius: 4px 4px 0 0; min-height: 2px; }
.admin-bar-chart-axis { display: flex; justify-content: space-between; font-size: .72rem; color: var(--ink-faint); margin-top: var(--space-2); }
.admin-breakdown-bar { display: flex; height: 14px; border-radius: var(--radius-full); overflow: hidden; background: var(--bg-alt); }
.admin-breakdown-bar .segment { height: 100%; }
.admin-breakdown-bar .segment:not(:last-child) { margin-right: 2px; }
.admin-breakdown-legend { display: flex; flex-wrap: wrap; gap: var(--space-4); margin-top: var(--space-3); font-size: .82rem; }
.admin-breakdown-legend .item { display: flex; align-items: center; gap: var(--space-2); color: var(--ink-soft); }
.admin-breakdown-legend .swatch { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.admin-domain-row { display: flex; align-items: center; justify-content: space-between; padding: .7em 0; border-bottom: 1px solid var(--border); font-size: .92rem; }
.admin-domain-row:last-child { border-bottom: none; }
.admin-domain-row button {
  background: none; border: none; color: var(--warn); cursor: pointer; font-size: .82rem; font-weight: 600; padding: 0;
}
.admin-domain-row button:hover { text-decoration: underline; }
