/* DVeMesh design system — shared tokens and primitives (auth pages keep auth.css) */

:root {
  --bg: #07090d;
  --bg-elev: #0c1016;
  --surface: #10151c;
  --surface-2: #161d26;
  --surface-raised: #1a222c;
  --border: #253040;
  --border-strong: #334155;
  --text: #e8eef6;
  --text-dim: #9aa8b8;
  --text-mute: #6d7b8c;
  --accent: #4fd1c5;
  --accent-2: #6ea8ff;
  --accent-dim: rgba(79, 209, 197, 0.14);
  --warn: #e6b84d;
  --danger: #e85d6a;
  --ok: #3dcf7a;
  --pending: #d4a017;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  --radius: 12px;
  --radius-sm: 8px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --font: "Segoe UI", "Helvetica Neue", ui-sans-serif, system-ui, sans-serif;
  --mono: "SF Mono", "Cascadia Code", "JetBrains Mono", ui-monospace, monospace;
  --nav: 56px;
  --sidebar: 232px;
  --rail: 64px;
  --bottom-nav: 56px;
  --dm-bg: var(--bg);
  --dm-surface: var(--surface);
  --dm-surface-raised: var(--surface-raised);
  --dm-border: var(--border);
  --dm-text: var(--text);
  --dm-text-muted: var(--text-dim);
  --dm-accent: var(--accent);
  --dm-success: var(--ok);
  --dm-warning: var(--warn);
  --dm-danger: var(--danger);
  --dm-radius: var(--radius);
}

[data-theme="light"] {
  --bg: #f4f6f8;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --surface-raised: #ffffff;
  --border: #d5dde6;
  --border-strong: #b7c2cf;
  --text: #121820;
  --text-dim: #4b5866;
  --text-mute: #6b7785;
  --accent-dim: rgba(15, 118, 110, 0.1);
  --shadow: 0 10px 28px rgba(16, 24, 40, 0.08);
}

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

html, body { margin: 0; min-height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 15px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid rgba(79, 209, 197, 0.55);
  outline-offset: 2px;
}

.skip {
  position: absolute;
  left: -999px;
  top: 8px;
}
.skip:focus {
  left: 8px;
  background: var(--surface);
  padding: 8px 12px;
  border: 1px solid var(--border);
  z-index: 80;
}

.mono { font-family: var(--mono); font-size: 0.86em; }

.ico {
  width: 18px;
  height: 18px;
  display: inline-flex;
  flex-shrink: 0;
}
.ico svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.site-header, .app-header {
  height: var(--nav);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 var(--space-5);
  border-bottom: 1px solid var(--border);
  background: rgba(8, 11, 16, 0.86);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 30;
}

[data-theme="light"] .site-header,
[data-theme="light"] .app-header {
  background: rgba(255, 255, 255, 0.9);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 650;
  letter-spacing: 0.02em;
  text-decoration: none;
  min-height: 44px;
}
.brand:hover { text-decoration: none; }
.brand img { width: 28px; height: 28px; }

.nav { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.nav a, .nav button.link, button.link {
  color: var(--text-dim);
  padding: 8px 10px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  text-decoration: none;
  background: none;
  border: 0;
  font: inherit;
  cursor: pointer;
}
.nav a:hover, .nav a.active, .nav button.link:hover {
  color: var(--text);
  background: var(--surface-2);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
  transition: filter 140ms ease, border-color 140ms ease, background 140ms ease;
}
.btn:hover { border-color: var(--border-strong); text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(79, 209, 197, 0.22);
}
.btn-primary { background: var(--accent); color: #06221f; }
.btn-primary:hover { filter: brightness(1.05); border-color: transparent; }
.btn-danger { background: rgba(232, 93, 106, 0.16); color: #ffb4bb; border-color: rgba(232, 93, 106, 0.35); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn.is-loading { position: relative; pointer-events: none; }
.btn.is-loading::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: dm-spin 0.7s linear infinite;
}

@keyframes dm-spin { to { transform: rotate(360deg); } }

.input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid #2a3646;
  background: #0b1016;
  color: var(--text);
  font: inherit;
}
[data-theme="light"] .input,
[data-theme="light"] select,
[data-theme="light"] textarea {
  border-color: var(--border);
  background: #fff;
}
textarea { min-height: 96px; resize: vertical; }
.input:hover, select:hover, textarea:hover { border-color: #3d4d62; }
.input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 209, 197, 0.16);
}
label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; font-weight: 600; }
.field { margin-bottom: 14px; }
.hint { color: var(--text-mute); font-size: 13px; margin-top: 6px; }

.card {
  background: rgba(16, 21, 28, 0.92);
  border: 1px solid rgba(55, 71, 90, 0.65);
  border-radius: var(--radius);
  padding: var(--space-5);
}
[data-theme="light"] .card {
  background: var(--surface);
  border-color: var(--border);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.02em;
  background: var(--surface-2);
  color: var(--text-dim);
  text-transform: uppercase;
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge-online { background: rgba(61, 207, 122, 0.14); color: var(--ok); }
.badge-offline { background: rgba(107, 115, 128, 0.18); color: var(--text-dim); }
.badge-pending { background: rgba(212, 160, 23, 0.16); color: var(--pending); }
.badge-revoked { background: rgba(232, 93, 106, 0.16); color: var(--danger); }
.badge-soon { background: rgba(110, 168, 255, 0.12); color: var(--accent-2); }
.badge-soon::before { display: none; }

.alert {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: var(--surface-2);
}
.alert-error { border-color: rgba(232, 93, 106, 0.4); color: #ffc2c8; }
.alert-ok { border-color: rgba(61, 207, 122, 0.35); color: #b7f0cc; }
.alert-warn { border-color: rgba(230, 184, 77, 0.4); color: #f3d48a; }

.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); }
th { color: var(--text-mute); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
tr:hover td { background: rgba(255, 255, 255, 0.02); }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab {
  background: none;
  border: 0;
  color: var(--text-dim);
  padding: 10px 12px;
  min-height: 44px;
  font: inherit;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab[aria-selected="true"] { color: var(--text); border-color: var(--accent); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal {
  width: min(480px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.modal h2 { margin: 0 0 8px; font-size: 18px; }
.modal p { margin: 0 0 16px; color: var(--text-dim); }

.empty, .error-state, .loading {
  padding: 36px 16px;
  text-align: center;
  color: var(--text-dim);
}
.empty h3, .error-state h3 { margin: 0 0 8px; color: var(--text); font-size: 18px; }
.empty p, .error-state p { margin: 0 0 16px; }

.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 12px;
}
.stat { padding: 16px 18px; }
.stat strong { display: block; font-size: 28px; line-height: 1.1; letter-spacing: -0.03em; }
.stat span { color: var(--text-mute); font-size: 13px; }

.footer {
  border-top: 1px solid var(--border);
  padding: 28px var(--space-5);
  color: var(--text-mute);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 70;
  display: grid;
  gap: 8px;
  width: min(360px, calc(100% - 24px));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(16, 21, 28, 0.96);
  color: var(--text);
  box-shadow: var(--shadow);
}
.toast-ok { border-color: rgba(61, 207, 122, 0.35); }
.toast-warn { border-color: rgba(230, 184, 77, 0.4); }
.toast-error { border-color: rgba(232, 93, 106, 0.4); }
.toast button {
  background: none;
  border: 0;
  color: var(--text-mute);
  cursor: pointer;
  min-width: 32px;
  min-height: 32px;
  font: inherit;
}

.skeleton { display: grid; gap: 10px; }
.skeleton span {
  display: block;
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(90deg, #141a22, #1c2430, #141a22);
  background-size: 200% 100%;
  animation: dm-shimmer 1.2s ease-in-out infinite;
}
.skeleton span.lg { height: 28px; width: 40%; }
.skeleton span.md { width: 72%; }
.skeleton span.sm { width: 48%; }

@keyframes dm-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.dl {
  display: grid;
  grid-template-columns: minmax(120px, 180px) 1fr;
  gap: 8px 16px;
  margin: 0;
}
.dl dt { color: var(--text-mute); font-size: 13px; }
.dl dd { margin: 0; word-break: break-word; }

.page-lede {
  margin: 4px 0 0;
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 400;
}

.object-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.object-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-decoration: none;
  color: inherit;
  min-height: 120px;
  transition: border-color 140ms ease;
}
.object-card:hover {
  text-decoration: none;
  border-color: var(--border-strong);
}
.object-card h3 { margin: 0; font-size: 16px; letter-spacing: -0.02em; }
.object-card .meta { color: var(--text-mute); font-size: 13px; display: flex; gap: 12px; flex-wrap: wrap; }
.object-card .cidr { font-family: var(--mono); color: var(--accent); font-size: 13px; }
.object-card .open { margin-top: auto; color: var(--accent); font-size: 13px; font-weight: 600; }

.timeline { display: grid; gap: 0; }
.timeline-item {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.timeline-item:last-child { border-bottom: 0; }
.timeline-dot {
  width: 8px;
  height: 8px;
  margin-top: 7px;
  border-radius: 50%;
  background: var(--accent);
}
.timeline-item strong { display: block; }
.timeline-item small { color: var(--text-mute); }

.section-block { margin-top: 28px; }
.section-block h2 { margin: 0 0 12px; font-size: 16px; letter-spacing: -0.02em; color: var(--text-dim); font-weight: 650; }

.icon-btn {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }

@media (max-width: 767px) {
  .site-header, .app-header { padding: 0 12px; }
  .nav a { padding: 8px; }
  table { min-width: 520px; }
  .dl { grid-template-columns: 1fr; gap: 2px 0; }
  .toasts { right: 12px; left: 12px; width: auto; bottom: calc(var(--bottom-nav) + 12px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
