/* ===================================================================
   App chrome — extends the vendored blueprint tokens (styles/tokens.css)
   into the operator UI's own dark, operational surface treatment.
   See the origincloud-operator-design skill for the full rationale.
   =================================================================== */
:root {
  --ink: #101318;
  --surface-0: #14171d;
  --surface-1: #191d24;
  --surface-2: #20242c;
  --surface-3: #262b34;

  --text: #ede9e0;
  --text-soft: #b7b3a8;
  --text-muted: #7c8089;

  --radius: 4px;
  --radius-sm: 3px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 28px -14px rgba(0, 0, 0, 0.6);

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", Consolas, monospace;
}

* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--sans);
}

svg.icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ===================== BRAND ===================== */
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.01em;
  padding-right: 14px;
  margin-right: 2px;
  border-right: 1px solid var(--line);
}
.brand .mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 1.5px solid var(--text);
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
}
.brand .product {
  color: var(--text-muted);
  font-weight: 500;
}
.brand .product::before {
  content: "/";
  margin: 0 6px;
  color: var(--text-muted);
}

/* ===================== BUTTONS ===================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease, opacity 0.12s ease;
}
.btn svg.icon {
  width: 15px;
  height: 15px;
}
.btn-primary {
  background: var(--copper);
  color: #221206;
}
.btn-primary:hover {
  background: #ef8a4e;
}
.btn-secondary {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--text);
}
.btn-secondary:hover {
  background: var(--surface-2);
  border-color: var(--line-bright);
}
.btn-ghost {
  background: transparent;
  color: var(--text-soft);
}
.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}
.btn-danger-ghost {
  background: transparent;
  color: var(--coral);
  border-color: rgba(217, 88, 75, 0.3);
}
.btn-danger-ghost:hover {
  background: var(--coral-soft);
}
.btn-danger {
  /* Reuses --ink (already a token) for on-coral text and derives the
     hover shade with color-mix() instead of hand-typing a new hex. */
  background: var(--coral);
  color: var(--ink);
  border-color: transparent;
}
.btn-danger:hover {
  background: color-mix(in srgb, var(--coral) 82%, white);
}
.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ===================== PANEL / CARD ===================== */
.panel {
  position: relative;
  background: var(--surface-1);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
}
.panel::before,
.panel::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  pointer-events: none;
}
.panel::before {
  top: -1px;
  left: -1px;
  border-top: 2px solid var(--line-bright);
  border-left: 2px solid var(--line-bright);
}
.panel::after {
  bottom: -1px;
  right: -1px;
  border-bottom: 2px solid var(--line-bright);
  border-right: 2px solid var(--line-bright);
}
.panel-pad {
  padding: 20px 22px;
}
.panel-title {
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 4px;
}
.panel-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 16px;
}

/* ===================== AUTH SCREEN ===================== */
.auth-screen {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  background-image: linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 56px 56px;
}
.auth-card {
  width: 340px;
  padding: 28px 26px;
  text-align: center;
}

/* ===================== APP SHELL ===================== */
.app {
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: 52px 1fr;
  grid-template-areas: "topbar topbar" "sidebar main";
  height: 100vh;
}
.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  background: var(--surface-0);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 20;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-soft);
  cursor: pointer;
}
.icon-btn:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
  color: var(--text);
}

.sidebar {
  grid-area: sidebar;
  background: var(--surface-0);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 12px 10px;
}
.nav-scroll {
  flex: 1;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  margin-bottom: 1px;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  font-size: 13px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background 0.12s ease, color 0.12s ease;
}
.nav-item svg.icon {
  color: var(--text-muted);
}
.nav-item:hover {
  background: var(--surface-1);
  color: var(--text);
}
.nav-item.active {
  background: var(--copper-soft);
  color: var(--text);
  border-left-color: var(--copper);
  font-weight: 600;
}
.nav-item.active svg.icon {
  color: var(--copper);
}

.main {
  grid-area: main;
  overflow-y: auto;
  background: var(--ink);
}

/* ===================== BREADCRUMB ===================== */
.topline {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 28px;
  font-size: 12.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--line);
}
.topline a {
  color: var(--text-muted);
}
.topline a:hover {
  color: var(--blue);
}
.topline .sep {
  opacity: 0.5;
}

/* ===================== PAGE CHROME ===================== */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 28px 18px;
  flex-wrap: wrap;
}
.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.page-header p {
  margin: 0;
  color: var(--text-muted);
  font-size: 13.5px;
  max-width: 620px;
}
.page-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.view-body {
  padding: 0 28px 40px;
}

/* ===================== BADGE: preview-data notice ===================== */
.preview-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 28px 18px;
  padding: 8px 12px;
  border: 1px solid var(--gold-soft);
  background: var(--gold-soft);
  border-radius: var(--radius);
  color: var(--gold);
  font-size: 12.5px;
  font-family: var(--mono);
}

/* ===================== BADGE: status ===================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 3px 9px 3px 7px;
  border-radius: 100px;
  text-transform: uppercase;
}
.badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(109, 178, 142, 0.55);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(109, 178, 142, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(109, 178, 142, 0);
  }
}
.badge.healthy {
  background: var(--sage-soft);
  color: var(--sage);
}
.badge.healthy .dot {
  background: var(--sage);
  animation: pulse 2.4s ease-in-out infinite;
}
.badge.degraded {
  background: var(--gold-soft);
  color: var(--gold);
}
.badge.degraded .dot {
  background: var(--gold);
  animation: pulse 1.6s ease-in-out infinite;
}
.badge.down {
  background: var(--coral-soft);
  color: var(--coral);
}
.badge.down .dot {
  background: var(--coral);
}
.badge.unknown {
  background: rgba(124, 128, 137, 0.14);
  color: var(--text-muted);
}
.badge.unknown .dot {
  background: var(--text-muted);
}

/* ===================== STAT TILES ===================== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
@media (max-width: 1200px) {
  .stat-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (max-width: 700px) {
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
.stat-tile {
  display: block;
  padding: 16px 18px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}
.stat-tile .lbl {
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.stat-tile .val {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.stat-tile .delta {
  margin-top: 6px;
  font-size: 12px;
  font-family: var(--mono);
  display: flex;
  align-items: center;
  gap: 4px;
}
.stat-tile .delta.up {
  color: var(--sage);
}
.stat-tile .delta.down {
  color: var(--coral);
}
.stat-tile .delta.flat {
  color: var(--text-muted);
}

/* ===================== METER (capacity utilization) ===================== */
.meter {
  height: 6px;
  border-radius: 100px;
  background: var(--surface-2);
  overflow: hidden;
  margin: 10px 0 6px;
}
.meter-fill {
  height: 100%;
  background: var(--copper);
  border-radius: 100px;
}

/* ===================== TABLES ===================== */
.table-wrap {
  overflow-x: auto;
}
table.dtable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.dtable th {
  text-align: left;
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}
table.dtable td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.dtable tbody tr:last-child td {
  border-bottom: none;
}
td.num,
th.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
.cell-primary {
  font-weight: 600;
}
.cell-sub {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 1px;
}
.copyable-id {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
}
.copyable-id-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 260px;
}
.copyable-id-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.12s ease, background 0.12s ease, color 0.12s ease;
}
.copyable-id-btn svg.icon {
  width: 13px;
  height: 13px;
}
.copyable-id-btn:hover {
  opacity: 1;
  background: var(--surface-2);
  color: var(--text);
}
.copyable-id-btn .copyable-id-check {
  color: var(--sage);
}

/* ===================== ERROR NOTE ===================== */
.error-note {
  color: var(--coral);
  font-size: 12.5px;
  margin: 0 0 12px;
}
.error-note-card {
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid rgba(217, 88, 75, 0.3);
  background: var(--coral-soft);
  max-width: 460px;
}
.error-note-headline {
  color: var(--text);
  font-size: 13px;
  margin: 0 0 8px;
}
.error-note-details {
  margin-bottom: 10px;
}
.error-note-details summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 12px;
  user-select: none;
}
.error-note-details summary:hover {
  color: var(--text-soft);
}
.error-note-details p {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 11.5px;
  word-break: break-word;
}

/* ===================== TOAST ===================== */
.toast-stack {
  position: fixed;
  top: 68px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}
.toast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--surface-1);
  box-shadow: var(--shadow);
  font-size: 13px;
  color: var(--text);
  animation: toast-in 0.15s ease;
}
.toast-success {
  border-left: 3px solid var(--sage);
}
.toast-error {
  border-left: 3px solid var(--coral);
}
.toast-dismiss {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0 2px;
}
.toast-dismiss:hover {
  color: var(--text);
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===================== MODAL ===================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 11, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: modal-fade-in 0.12s ease;
}
.modal-panel {
  width: 100%;
  max-width: 380px;
  margin: 16px;
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--surface-1);
  box-shadow: var(--shadow);
}
.modal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.modal-message {
  font-size: 13px;
  color: var(--text-soft);
  margin: 0 0 18px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
@keyframes modal-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ===================== EMPTY STATE ===================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 64px 24px;
  color: var(--text-muted);
}
.empty-state .ic {
  width: 52px;
  height: 52px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
}
.empty-state .ic svg.icon {
  width: 24px;
  height: 24px;
  color: var(--text-soft);
}
.empty-state h3 {
  margin: 0 0 6px;
  color: var(--text);
  font-size: 15px;
}
.empty-state p {
  margin: 0 0 18px;
  max-width: 380px;
  font-size: 13px;
}

/* ===================== TABLE SKELETON ===================== */
.skel-bar {
  height: 12px;
  width: 70%;
  max-width: 160px;
  border-radius: 3px;
  background: var(--surface-2);
  animation: skel-pulse 1.4s ease-in-out infinite;
}
.skel-row td:first-child .skel-bar {
  width: 85%;
  max-width: 220px;
}
@keyframes skel-pulse {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
}

.row-menu {
  width: 34px;
  text-align: right;
}

/* ===================== FORMS ===================== */
.form-group {
  margin-bottom: 18px;
}
.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 6px;
}
.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 5px;
}
.form-control {
  width: 100%;
  padding: 8px 11px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-family: var(--sans);
  outline: none;
}
.form-control:focus {
  border-color: var(--copper);
}
.form-control-invalid {
  border-color: var(--coral);
}
.field-error {
  font-size: 12px;
  color: var(--coral);
  margin: 5px 0 0;
}
select.form-control {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%237c8089' stroke-width='1.4' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 30px;
}

.create-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 22px;
  align-items: start;
}
@media (max-width: 980px) {
  .create-layout {
    grid-template-columns: 1fr;
  }
}
