/*
 * Xera Shield UI foundation.
 *
 * This is deliberately plain, browser-native CSS. The application used to load
 * a generated Tailwind bundle alongside the mission-control UI, which left the
 * cascade split between two design systems. Keep shared primitives and the small
 * layout vocabulary here; page-specific visuals live in dashboard.css.
 */

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html, body { min-height: 100%; margin: 0; }
  body, h1, h2, h3, p { margin: 0; }
  button, input, select, textarea { font: inherit; }
  button, summary { color: inherit; }
  button { border: 0; }
  a { color: inherit; text-decoration: none; }
  img, svg { display: block; }
}

@layer base {
  :root {
    /* Neutrals */
    --bg: #0b0f14;
    --surface: #11161d;
    --surface-2: #161c25;
    --surface-3: #1c2430;
    --border: #1e2630;
    --border-strong: #2a3440;
    --text: #e5eaf0;
    --text-2: #8b96a5;
    --text-3: #5b6675;
    /* Accent (overridden inline from DB) */
    --brand: #34d399;
    /* Status */
    --ok: #34d399;
    --bad: #f87171;
    --info: #38bdf8;

    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", "Noto Sans", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
        monospace;
  }

  html {
    color-scheme: dark;
  }

  body {
    background-color: var(--bg);
    background-image:
        radial-gradient(1100px 540px at 78% -10%, color-mix(in oklab, var(--brand) 7%, transparent), transparent 60%),
        radial-gradient(900px 520px at -12% 18%, color-mix(in oklab, var(--info) 5%, transparent), transparent 62%),
        radial-gradient(700px 700px at 110% 105%, color-mix(in oklab, var(--brand) 4%, transparent), transparent 60%);
    background-attachment: fixed;
    color: var(--text);
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }

  ::selection {
    background: color-mix(in oklab, var(--brand) 30%, transparent);
    color: #fff;
  }

  ::-webkit-scrollbar {
    width: 12px;
    height: 12px;
  }
  ::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 8px;
    border: 3px solid var(--bg);
  }
  ::-webkit-scrollbar-thumb:hover {
    background: #35404e;
  }
  ::-webkit-scrollbar-track {
    background: transparent;
  }

  :focus-visible {
    outline: 2px solid color-mix(in oklab, var(--brand) 55%, transparent);
    outline-offset: 2px;
  }
}

@layer components {
  /* ---- Buttons ---- */
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border-radius: 0.6rem;
    padding: 0.5rem 0.9rem;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.25rem;
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.15s ease, border-color 0.15s ease,
        color 0.15s ease, box-shadow 0.15s ease, transform 0.08s ease;
  }
  .btn:focus-visible {
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--brand) 35%, transparent);
  }
  .btn:active {
    transform: translateY(1px);
  }
  .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }

  .btn-sm {
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
  }

  .btn-primary {
    background: var(--brand);
    color: #04100b;
    box-shadow:
        0 1px 0 color-mix(in oklab, #fff 22%, transparent) inset,
        0 3px 10px -4px color-mix(in oklab, var(--brand) 55%, transparent);
  }
  .btn-primary:hover {
    background: color-mix(in oklab, var(--brand) 88%, #fff 12%);
  }

  .btn-secondary {
    background: var(--surface-2);
    border-color: var(--border-strong);
    color: var(--text);
  }
  .btn-secondary:hover {
    background: var(--surface-3);
    border-color: color-mix(in oklab, var(--brand) 40%, var(--border-strong));
  }

  .btn-ghost {
    background: transparent;
    border-color: var(--border-strong);
    color: var(--text-2);
  }
  .btn-ghost:hover {
    background: var(--surface-2);
    color: var(--text);
  }

  .btn-danger {
    background: color-mix(in oklab, var(--bad) 14%, transparent);
    color: var(--bad);
  }
  .btn-danger:hover {
    background: color-mix(in oklab, var(--bad) 22%, transparent);
  }

  /* ---- Forms ---- */
  .input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border-strong);
    border-radius: 0.6rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: var(--text);
    caret-color: var(--brand);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
  }
  .input::placeholder {
    color: var(--text-3);
  }
  .input:hover {
    border-color: #3a4654;
  }
  .input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--brand) 20%, transparent);
  }
  select.input {
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%238b96a5' stroke-width='2'><path d='M3 5l3 3 3-3'/></svg>");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
  }
  textarea.input {
    resize: vertical;
  }
  .label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: var(--text-2);
  }
  .hint {
    font-size: 0.75rem;
    color: var(--text-3);
  }

  /* ---- Surfaces ---- */
  .card {
    background: linear-gradient(180deg, color-mix(in oklab, #ffffff 3%, var(--surface)) 0%, var(--surface) 55%);
    border: 1px solid var(--border);
    border-radius: 0.9rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
  }
  .hover-card {
    transition: border-color 0.15s ease, background-color 0.15s ease,
        transform 0.15s ease, box-shadow 0.15s ease;
  }
  .hover-card:hover {
    border-color: var(--border-strong);
    background: var(--surface-2);
    transform: translateY(-1px);
    box-shadow: 0 10px 24px -12px rgba(0, 0, 0, 0.55);
  }

  /* ---- Navigation ---- */
  .nav-link {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    border-radius: 0.6rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-2);
    transition: background-color 0.15s ease, color 0.15s ease;
  }
  .nav-link:hover {
    background: var(--surface-2);
    color: var(--text);
  }
  .nav-link-active {
    background: color-mix(in oklab, var(--brand) 14%, transparent);
    color: var(--brand);
    font-weight: 600;
    box-shadow: inset 3px 0 0 0 var(--brand);
  }
  .nav-link-active:hover {
    background: color-mix(in oklab, var(--brand) 18%, transparent);
    color: var(--brand);
  }

  /* ---- Badges ---- */
  .badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border-radius: 999px;
    padding: 0.15rem 0.6rem;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
  }
  .badge-online {
    background: color-mix(in oklab, var(--ok) 14%, transparent);
    color: var(--ok);
  }
  .badge-offline {
    background: color-mix(in oklab, var(--bad) 14%, transparent);
    color: var(--bad);
  }
  .badge-proxy {
    background: color-mix(in oklab, var(--info) 14%, transparent);
    color: var(--info);
  }
  .badge-neutral {
    background: var(--surface-3);
    color: var(--text-2);
  }
  .badge-brand {
    background: color-mix(in oklab, var(--brand) 14%, transparent);
    color: var(--brand);
  }
  .badge-opts {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-2);
  }
  .status-dot {
    display: inline-block;
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 999px;
    flex: none;
  }
  .status-dot-online { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in oklab, var(--ok) 25%, transparent); }
  .status-dot-offline { background: var(--bad); box-shadow: 0 0 0 3px color-mix(in oklab, var(--bad) 25%, transparent); }

  /* ---- Alerts ---- */
  .alert-danger {
    background: color-mix(in oklab, var(--bad) 12%, transparent);
    border: 1px solid color-mix(in oklab, var(--bad) 30%, transparent);
    color: color-mix(in oklab, var(--bad) 85%, #fff);
    border-radius: 0.5rem;
    padding: 0.6rem 0.8rem;
    font-size: 0.85rem;
  }
  .alert-success {
    background: color-mix(in oklab, var(--ok) 12%, transparent);
    border: 1px solid color-mix(in oklab, var(--ok) 30%, transparent);
    color: var(--ok);
    border-radius: 0.5rem;
    padding: 0.6rem 0.8rem;
    font-size: 0.85rem;
  }
  .alert-info {
    background: color-mix(in oklab, var(--info) 12%, transparent);
    border: 1px solid color-mix(in oklab, var(--info) 30%, transparent);
    color: var(--info);
    border-radius: 0.5rem;
    padding: 0.6rem 0.8rem;
    font-size: 0.85rem;
  }

  /* ---- Dialogs ---- */
  .modal {
    position: fixed;
    inset: 0;
    margin: auto;
    width: 100%;
    max-width: 30rem;
    max-height: min(90vh, 36rem);
    overflow: auto;
    padding: 0;
    border: none;
    border-radius: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: 0 0 0 1px var(--border), 0 28px 70px -12px rgba(0, 0, 0, 0.75);
    color: var(--text);
  }
  .modal::backdrop {
    background: rgba(3, 6, 9, 0.75);
    backdrop-filter: blur(3px);
  }
  .modal[open] {
    animation: modal-pop 0.16s ease-out;
  }
  @keyframes modal-pop {
    from {
      opacity: 0;
      transform: translateY(10px) scale(0.98);
    }
    to {
      opacity: 1;
      transform: translateY(0) scale(1);
    }
  }

  /* Modal inner layout */
  .modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.15rem 1.4rem;
    border-bottom: 1px solid var(--border);
  }
  .modal-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.05rem;
    font-weight: 650;
    color: var(--text);
  }
  .modal-body {
    padding: 1.35rem 1.4rem;
  }
  .modal-foot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.6rem;
    padding: 1rem 1.4rem;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: 0 0 1rem 1rem;
  }
  .modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 0.5rem;
    color: var(--text-3);
    transition: background-color 0.15s ease, color 0.15s ease;
  }
  .modal-close:hover {
    background: var(--surface-3);
    color: var(--text);
  }

  /* ---- Typography helpers ---- */
  .page-title {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.15;
    color: var(--text);
  }
  .page-sub {
    font-size: 0.85rem;
    color: var(--text-3);
  }
  .mono {
    font-family: var(--font-mono);
  }
  .tabular {
    font-variant-numeric: tabular-nums;
  }
  .accent-text { color: var(--brand); }
  .accent-link {
    color: var(--brand);
    text-decoration: none;
    font-weight: 600;
  }
  .accent-link:hover {
    text-decoration: underline;
    text-underline-offset: 2px;
  }
}

/* ---- Tables ---- */
@layer components {
  .table-shell {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 0.9rem;
    overflow: hidden;
    background: var(--surface);
  }
  .table-shell table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
  }
  .table-shell thead {
    background: linear-gradient(180deg, var(--surface-3) 0%, var(--surface-2) 100%);
  }
  .table-shell th {
    text-align: left;
    padding: 0.6rem 1rem;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-3);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
  }
  .table-shell td {
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
  }
  .table-shell tbody tr:last-child td {
    border-bottom: none;
  }
  .table-shell tbody tr {
    transition: background-color 0.1s ease;
  }
  .table-shell tbody tr:hover {
    background: var(--surface-2);
  }
}

/* ---- Sidebar ambient glow ---- */
#sidebar {
  background:
      radial-gradient(560px 240px at 50% -50%, color-mix(in oklab, var(--brand) 9%, transparent), transparent 72%),
      var(--surface);
}

/* ---- Live-refresh swap transition ---- */
.htmx-swapping {
  opacity: 0;
  transition: opacity 0.12s ease-out;
}
@media (prefers-reduced-motion: reduce) {
  .htmx-swapping {
    transition: none;
  }
  .modal[open] {
    animation: none;
  }
  .hover-card:hover {
    transform: none;
  }
}

/* Minimal layout vocabulary used by the server-rendered templates. These are
   intentionally owned by this UI stylesheet rather than generated by Tailwind. */
@layer utilities {
  .fixed { position: fixed; } .relative { position: relative; }
  .inset-x-0 { left: 0; right: 0; } .inset-y-0 { top: 0; bottom: 0; }
  .left-0 { left: 0; } .top-0 { top: 0; } .top-14 { top: 3.5rem; }
  .z-30 { z-index: 30; } .z-40 { z-index: 40; }
  .hidden { display: none; } .block { display: block; } .inline { display: inline; }
  .flex { display: flex; } .inline-flex { display: inline-flex; } .grid { display: grid; }
  .grid-cols-1 { grid-template-columns: minmax(0, 1fr); }
  .grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .flex-1 { flex: 1 1 0%; } .flex-none, .shrink-0 { flex: none; }
  .flex-col { flex-direction: column; } .flex-wrap { flex-wrap: wrap; }
  .items-center { align-items: center; } .items-end { align-items: flex-end; }
  .items-baseline { align-items: baseline; } .justify-center { justify-content: center; }
  .justify-between { justify-content: space-between; } .justify-end { justify-content: flex-end; }
  .gap-1 { gap: .25rem; } .gap-1\.5 { gap: .375rem; } .gap-2 { gap: .5rem; }
  .gap-3 { gap: .75rem; } .gap-4 { gap: 1rem; } .gap-5 { gap: 1.25rem; }
  .space-y-1 > :not([hidden]) ~ :not([hidden]) { margin-top: .25rem; }
  .space-y-3 > :not([hidden]) ~ :not([hidden]) { margin-top: .75rem; }
  .space-y-4 > :not([hidden]) ~ :not([hidden]) { margin-top: 1rem; }
  .min-h-screen { min-height: 100vh; } .min-w-0 { min-width: 0; }
  .min-w-\[10rem\] { min-width: 10rem; } .min-w-\[12rem\] { min-width: 12rem; }
  .max-h-80 { max-height: 20rem; } .w-full { width: 100%; }
  .w-2\.5 { width: .625rem; } .h-2\.5 { height: .625rem; }
  .w-3\.5 { width: .875rem; } .h-3\.5 { height: .875rem; }
  .w-4 { width: 1rem; } .h-4 { height: 1rem; } .w-5 { width: 1.25rem; } .h-5 { height: 1.25rem; }
  .w-7 { width: 1.75rem; } .h-7 { height: 1.75rem; }
  .w-12 { width: 3rem; } .h-12 { height: 3rem; } .w-14 { width: 3.5rem; } .h-14 { height: 3.5rem; }
  .w-64 { width: 16rem; } .max-w-sm { max-width: 24rem; } .max-w-6xl { max-width: 72rem; }
  .overflow-hidden { overflow: hidden; } .overflow-x-auto { overflow-x: auto; } .overflow-y-auto { overflow-y: auto; }
  .truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .break-all { word-break: break-all; }
  .m-0 { margin: 0; } .mx-auto { margin-inline: auto; } .ml-2 { margin-left: .5rem; }
  .mt-0\.5 { margin-top: .125rem; } .mt-1 { margin-top: .25rem; } .mt-1\.5 { margin-top: .375rem; }
  .mt-2 { margin-top: .5rem; } .mt-3 { margin-top: .75rem; } .mt-4 { margin-top: 1rem; } .mt-5 { margin-top: 1.25rem; }
  .mb-1 { margin-bottom: .25rem; } .mb-1\.5 { margin-bottom: .375rem; } .mb-2 { margin-bottom: .5rem; }
  .mb-3 { margin-bottom: .75rem; } .mb-4 { margin-bottom: 1rem; } .mb-5 { margin-bottom: 1.25rem; }
  .mb-6 { margin-bottom: 1.5rem; } .mb-8 { margin-bottom: 2rem; }
  .p-3 { padding: .75rem; } .p-4 { padding: 1rem; } .p-5 { padding: 1.25rem; } .p-7 { padding: 1.75rem; }
  .px-2 { padding-inline: .5rem; } .px-3 { padding-inline: .75rem; } .px-4 { padding-inline: 1rem; } .px-6 { padding-inline: 1.5rem; }
  .py-2 { padding-block: .5rem; } .py-3 { padding-block: .75rem; } .py-6 { padding-block: 1.5rem; }
  .pb-1 { padding-bottom: .25rem; } .pb-4 { padding-bottom: 1rem; } .pb-8 { padding-bottom: 2rem; } .pb-16 { padding-bottom: 4rem; }
  .pt-0 { padding-top: 0; } .pt-2 { padding-top: .5rem; } .pt-14 { padding-top: 3.5rem; }
  .rounded-lg { border-radius: .5rem; } .rounded-xl { border-radius: .75rem; } .rounded-full { border-radius: 999px; }
  .border { border: 1px solid var(--border); } .border-b { border-bottom: 1px solid var(--border); }
  .border-r { border-right: 1px solid var(--border); }
  .border-\[var\(--border\)\] { border-color: var(--border); }
  .border-\[var\(--border-strong\)\] { border-color: var(--border-strong); }
  .bg-\[var\(--surface\)\] { background: var(--surface); }
  .bg-\[var\(--surface-2\)\] { background: var(--surface-2); }
  .bg-\[var\(--brand\)\]\/15 { background: color-mix(in oklab, var(--brand) 15%, transparent); }
  .object-contain { object-fit: contain; }
  .text-center { text-align: center; } .text-left { text-align: left; }
  .text-\[11px\] { font-size: 11px; } .text-xs { font-size: .75rem; } .text-sm { font-size: .875rem; }
  .text-base { font-size: 1rem; } .text-lg { font-size: 1.125rem; } .text-xl { font-size: 1.25rem; }
  .text-2xl { font-size: 1.5rem; } .text-3xl { font-size: 1.875rem; }
  .font-medium { font-weight: 500; } .font-semibold { font-weight: 600; } .font-bold { font-weight: 700; }
  .uppercase { text-transform: uppercase; } .tracking-wider { letter-spacing: .05em; }
  .leading-relaxed { line-height: 1.625; }
  .text-white { color: #fff; } .text-\[var\(--text\)\] { color: var(--text); }
  .text-\[var\(--text-2\)\] { color: var(--text-2); } .text-\[var\(--text-3\)\] { color: var(--text-3); }
  .text-\[var\(--brand\)\] { color: var(--brand); }
  .transition-colors { transition: color .15s ease, background-color .15s ease, border-color .15s ease; }
  .cursor-pointer { cursor: pointer; }
  .hover\:text-white:hover { color: #fff; } .file\:hidden::file-selector-button { display: none; }
  @media (min-width: 640px) { .sm\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
  @media (min-width: 768px) {
    .md\:flex { display: flex; } .md\:hidden { display: none; }
    .md\:ml-64 { margin-left: 16rem; } .md\:px-8 { padding-inline: 2rem; }
    .md\:py-8 { padding-block: 2rem; } .md\:pb-8 { padding-bottom: 2rem; } .md\:pt-0 { padding-top: 0; }
  }
  @media (min-width: 1024px) { .lg\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
}
