/* =============================================================================
   BlueSilica app theme  -  the Infralytix "Iron + Amber Copper" theme, for every BlueSilica app.

   Source of the tokens: tb-infralytix-repo/branding/infralytix/themes/infralytix-theme.css (the `--ix-*` values in the light block
   are copied from it). Only the THEME is shared. Logos are not: Infralytix keeps its logo, BlueSilica AI keeps its own.
   Fonts are self-hosted (fonts/), so on-premises systems without internet render the same.

   Use:  <link rel="stylesheet" href="theme/theme.css">   then your page CSS (layout only).  See README.md.
   Light is the default. <html data-theme="dark"> is dark; <html data-theme="system"> follows the device. theme.js sets it and
   draws the Light / Dark / System switch (place <span data-theme-switch></span>).
   ============================================================================= */

@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("fonts/inter-latin-wght-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/jetbrains-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("fonts/jetbrains-mono-latin-500-normal.woff2") format("woff2"); }

/* ── Design tokens: light ───────────────────────────────────────────────────── */
:root {
  color-scheme: light;
  /* Primary: Amber Copper (fill). Dark text ON amber (5.9:1); white on amber is only 3.2:1 and must not be used. */
  --ix-primary:          #D97706;
  --ix-primary-dark:     #B45309;
  --ix-primary-light:    #F59E0B;
  --ix-primary-lighter:  #FCD34D;
  --ix-primary-subtle:   #FFFBEB;
  --ix-primary-text:     #1C0F00;
  /* Amber used AS TEXT on a surface (links, small headings): dark amber on light (5.0:1), light amber on dark (9:1) */
  --ix-primary-ink:      #B45309;
  /* Accent: Steel */
  --ix-accent:           #475569;
  --ix-accent-dark:      #334155;
  --ix-accent-light:     #64748B;
  --ix-accent-subtle:    #F8FAFC;
  /* Semantic fills (dots, bars) */
  --ix-success:          #22C55E;
  --ix-warning:          #F97316;
  --ix-error:            #EF4444;
  --ix-info:             #38BDF8;
  /* Semantic text on a surface (>= 4.5:1) and soft tints behind it */
  --ix-success-text:     #166534;   --ix-success-tint: rgba(34, 197, 94, 0.14);
  --ix-warning-text:     #92400E;   --ix-warning-tint: rgba(217, 119, 6, 0.14);
  --ix-error-text:       #B91C1C;   --ix-error-tint:   rgba(239, 68, 68, 0.12);
  --ix-info-text:        #0369A1;   --ix-info-tint:    rgba(56, 189, 248, 0.16);
  /* Surfaces */
  --ix-bg:               #F1F5F9;
  --ix-bg-alt:           #E2E8F0;
  --ix-surface:          #FFFFFF;
  --ix-surface-raised:   #F8FAFC;
  --ix-border:           #CBD5E1;
  --ix-border-light:     #E2E8F0;
  --ix-divider:          rgba(15, 23, 42, 0.08);
  /* Iron shell (the sidebar in Infralytix; the top bar in our top-navigation apps) */
  --ix-sidebar-bg:       #0D0D0D;
  --ix-sidebar-bg2:      #111111;
  --ix-sidebar-active:   #D97706;
  --ix-sidebar-hover:    rgba(217, 119, 6, 0.10);
  --ix-sidebar-text:     #94A3B8;
  --ix-sidebar-text-act: #1C0F00;
  --ix-sidebar-border:   rgba(255, 255, 255, 0.05);
  /* Text */
  --ix-text:             #0F172A;
  --ix-text-secondary:   #475569;
  --ix-text-muted:       #94A3B8;      /* decoration and disabled only: 2.6:1 on white, too weak for text people must read */
  --ix-text-on-primary:  #1C0F00;
  --ix-text-on-accent:   #FFFFFF;
  /* Typography */
  --ix-font-ui:          'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --ix-font-data:        'JetBrains Mono', 'Fira Code', 'Roboto Mono', ui-monospace, Consolas, monospace;
  --ix-font-size-base:   14px;
  --ix-line-height:      1.5;
  /* Shape and elevation */
  --ix-radius-sm:        4px;
  --ix-radius:           8px;
  --ix-radius-lg:        12px;
  --ix-radius-xl:        16px;
  --ix-shadow-sm:        0 1px 2px rgba(15, 23, 42, 0.05);
  --ix-shadow:           0 1px 3px rgba(15, 23, 42, 0.10), 0 1px 2px rgba(15, 23, 42, 0.06);
  --ix-shadow-md:        0 4px 6px rgba(15, 23, 42, 0.07), 0 2px 4px rgba(15, 23, 42, 0.06);
  --ix-shadow-lg:        0 10px 15px rgba(15, 23, 42, 0.08), 0 4px 6px rgba(15, 23, 42, 0.05);
  --ix-login-bg:         linear-gradient(160deg, #0D0D0D 0%, #1A0F00 50%, #2C1800 100%);
}

/* ── Design tokens: dark ─────────────────────────────────────────────────────── */
/* Light is the default. Dark is chosen with <html data-theme="dark">; <html data-theme="system"> follows the device (theme.js sets the attribute).
   Dark is a layered scale so the parts stay distinct: iron bar (darkest) < page < card < raised, with outlined cards and 3:1 input borders. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --ix-bg: #1B2028;  --ix-bg-alt: #232A34;  --ix-surface: #262D38;  --ix-surface-raised: #313A48;
  --ix-border: #6B778A;  --ix-border-light: #3D4756;  --ix-divider: rgba(255, 255, 255, 0.10);
  --ix-primary-subtle: rgba(217, 119, 6, 0.18);  --ix-primary-ink: #F59E0B;
  --ix-accent-subtle: #2A313C;
  --ix-sidebar-bg: #0A0B0D;  --ix-sidebar-text: #A7B2C3;  --ix-sidebar-border: rgba(255, 255, 255, 0.10);
  --ix-success-text: #4ADE80;  --ix-warning-text: #FBBF24;  --ix-error-text: #FCA5A5;  --ix-info-text: #7DD3FC;
  --ix-success-tint: rgba(34, 197, 94, 0.20);  --ix-warning-tint: rgba(245, 158, 11, 0.20);
  --ix-error-tint: rgba(248, 113, 113, 0.20);  --ix-info-tint: rgba(56, 189, 248, 0.20);
  --ix-text: #E8EBF0;  --ix-text-secondary: #B0BAC8;  --ix-text-muted: #7C889A;
  --ix-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);  --ix-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
  --ix-shadow-md: 0 4px 8px rgba(0, 0, 0, 0.5);  --ix-shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.6);
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    color-scheme: dark;
    --ix-bg: #1B2028;  --ix-bg-alt: #232A34;  --ix-surface: #262D38;  --ix-surface-raised: #313A48;
    --ix-border: #6B778A;  --ix-border-light: #3D4756;  --ix-divider: rgba(255, 255, 255, 0.10);
    --ix-primary-subtle: rgba(217, 119, 6, 0.18);  --ix-primary-ink: #F59E0B;
    --ix-accent-subtle: #2A313C;
    --ix-sidebar-bg: #0A0B0D;  --ix-sidebar-text: #A7B2C3;  --ix-sidebar-border: rgba(255, 255, 255, 0.10);
    --ix-success-text: #4ADE80;  --ix-warning-text: #FBBF24;  --ix-error-text: #FCA5A5;  --ix-info-text: #7DD3FC;
    --ix-success-tint: rgba(34, 197, 94, 0.20);  --ix-warning-tint: rgba(245, 158, 11, 0.20);
    --ix-error-tint: rgba(248, 113, 113, 0.20);  --ix-info-tint: rgba(56, 189, 248, 0.20);
    --ix-text: #E8EBF0;  --ix-text-secondary: #B0BAC8;  --ix-text-muted: #7C889A;
    --ix-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);  --ix-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
    --ix-shadow-md: 0 4px 8px rgba(0, 0, 0, 0.5);  --ix-shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.6);
  }
}

/* ── The vocabulary our pages use (short names that point at the tokens above) ── */
:root {
  --bg: var(--ix-bg);               --card: var(--ix-surface);        --raised: var(--ix-surface-raised);
  --fg: var(--ix-text);             --muted: var(--ix-text-secondary);
  --line: var(--ix-border-light);   --line-strong: var(--ix-border);
  --brand: var(--ix-primary);       --brand-fg: var(--ix-primary-text);   --brand-text: var(--ix-primary-ink);
  --sel: var(--ix-primary-subtle);  --soft: var(--ix-primary-subtle);
  --ok: var(--ix-success-text);     --bad: var(--ix-error-text);      --warn: var(--ix-warning-text);   --info: var(--ix-info-text);
  --font-ui: var(--ix-font-ui);     --font-data: var(--ix-font-data);
}

/* ── Base ───────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: var(--ix-font-size-base)/var(--ix-line-height) var(--ix-font-ui);
       -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.02em; color: var(--fg); }
h1 { font-size: 16px; margin: 0; } h2 { font-size: 15px; margin: 0 0 8px; }
h3 { font-size: 14px; margin: 0 0 6px; }
h3.label { font-size: 11px; margin: 16px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
a { color: var(--brand-text); }
.muted { color: var(--muted); } .small { font-size: 12px; }
.mono, code, pre, .num { font-family: var(--font-data); letter-spacing: 0; }
pre { margin: 0; padding: 10px; background: var(--raised); border: 1px solid var(--line); border-radius: var(--ix-radius); overflow: auto;
      font-size: 12px; line-height: 1.45; }
::selection { background: var(--ix-primary-lighter); color: var(--ix-primary-text); }
*:focus-visible { outline: 2px solid var(--ix-primary); outline-offset: 2px; }
::-webkit-scrollbar { width: 6px; height: 6px; } ::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--ix-border); border-radius: 10px; } ::-webkit-scrollbar-thumb:hover { background: var(--ix-primary-lighter); }
hr { border: 0; border-top: 1px solid var(--ix-divider); }

/* ── App shell: iron top bar, amber active item (the Infralytix sidebar look, for top-navigation apps) ── */
.app-header { background: var(--ix-sidebar-bg); color: var(--ix-sidebar-text); border-bottom: 1px solid var(--ix-sidebar-border);
              border-top: 3px solid var(--ix-primary); padding: 8px 16px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
[data-theme="dark"] .app-header { border-bottom-color: rgba(255,255,255,.14); }
@media (prefers-color-scheme: dark) { [data-theme="system"] .app-header { border-bottom-color: rgba(255,255,255,.14); } }
.app-header h1 { color: #fff; font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.app-header .muted, .app-header .small { color: var(--ix-sidebar-text); }
.app-header nav { display: flex; gap: 4px; flex-wrap: wrap; }
.app-header nav button { border: 0; background: none; padding: 6px 12px; border-radius: var(--ix-radius-sm); color: var(--ix-sidebar-text); font: inherit; cursor: pointer;
                         transition: background .15s ease, color .15s ease; }
.app-header nav button:hover { background: var(--ix-sidebar-hover); color: var(--ix-primary-light); }
.app-header nav button.on { background: var(--ix-sidebar-active); color: var(--ix-sidebar-text-act); font-weight: 600; }
.app-header button.link { color: var(--ix-primary-light); }
.app-header button { border-color: rgba(255,255,255,.14); background: transparent; color: #E2E8F0; }
.app-header button.primary { background: var(--ix-primary); border-color: var(--ix-primary); color: var(--ix-primary-text); }
.app-header input, .app-header select { background: #1A1A1A; border-color: #333; color: #E2E8F0; }
.app-header .pill.brand { background: var(--ix-primary); color: var(--ix-primary-text); }

/* ── Surfaces ───────────────────────────────────────────────────────────────── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--ix-radius); box-shadow: var(--ix-shadow-sm); padding: 14px; margin-bottom: 12px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 12px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--ix-radius); box-shadow: var(--ix-shadow-sm); padding: 12px 14px; }
.tile b { display: block; font-size: 26px; line-height: 1.2; font-weight: 600; letter-spacing: -0.02em; }
.tile span { color: var(--muted); font-size: 12px; }
.empty { padding: 28px 10px; text-align: center; color: var(--muted); }
.summary { background: var(--sel); border-radius: var(--ix-radius); padding: 10px 12px; font-size: 13px; border-left: 3px solid var(--ix-primary); }
.bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }

/* ── Controls ───────────────────────────────────────────────────────────────── */
input, select, button, textarea { font: inherit; padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: var(--ix-radius-sm);
                                  background: var(--card); color: var(--fg); }
input::placeholder, textarea::placeholder { color: var(--ix-text-muted); }
input:focus, select:focus, textarea:focus { border-color: var(--ix-primary); outline: 2px solid var(--ix-primary); outline-offset: 0; }
button { cursor: pointer; transition: background .15s ease, border-color .15s ease; }
button:hover:not(:disabled) { border-color: var(--ix-primary); }
button.primary { background: var(--ix-primary); border-color: var(--ix-primary); color: var(--ix-primary-text); font-weight: 600; }
button.primary:hover:not(:disabled) { background: var(--ix-primary-dark); border-color: var(--ix-primary-dark); color: #fff; }
button.on { background: var(--ix-primary); border-color: var(--ix-primary); color: var(--ix-primary-text); font-weight: 600; }
button.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
button.danger:hover:not(:disabled) { background: var(--ix-error-tint); }
button.link { border: 0; background: none; color: var(--brand-text); padding: 2px 6px; }
button.link:hover:not(:disabled) { text-decoration: underline; }
button:disabled { opacity: .5; cursor: default; }
label { color: var(--muted); }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--ix-radius); overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: var(--card); padding: 8px 16px; }
.seg button.on { background: var(--ix-primary); color: var(--ix-primary-text); font-weight: 600; }
.hint { font-size: 12px; color: var(--muted); }
.err { color: var(--bad); min-height: 1.3em; font-size: 13px; }
details > summary { cursor: pointer; color: var(--brand-text); font-size: 13px; }

/* ── Forms ──────────────────────────────────────────────────────────────────── */
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 4px; font-size: 12px; font-weight: 500; }
.form input, .form select, .form textarea { width: 100%; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 640px) { .row2 { grid-template-columns: 1fr; } }
.acts { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 4px; }

/* ── Tables: amber rule under the header, as in Infralytix ──────────────────── */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
thead th, th { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); white-space: nowrap; }
thead tr { background: var(--raised); } thead th { border-bottom: 2px solid var(--ix-primary); }
tbody tr.click { cursor: pointer; } tbody tr.click:hover td, tbody tr:hover td { background: var(--sel); }

/* ── Status pills and tags: soft tint with readable text (not white on a solid colour) ── */
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap;
        background: rgba(100, 116, 139, 0.16); color: var(--muted); }
.pill.ok { background: var(--ix-success-tint); color: var(--ok); }
.pill.bad { background: var(--ix-error-tint); color: var(--bad); }
.pill.warn { background: var(--ix-warning-tint); color: var(--warn); }
.pill.info { background: var(--ix-info-tint); color: var(--info); }
.pill.brand { background: var(--ix-primary); color: var(--ix-primary-text); }
.tag { display: inline-block; background: var(--sel); color: var(--brand-text); border-radius: var(--ix-radius-sm); padding: 1px 7px; font-size: 12px; margin: 1px 2px 1px 0; }

/* ── Account menu: one button in the bar that opens a short list (name, role, then actions) ── */
.menu { position: relative; }
.menu-list { position: absolute; right: 0; top: calc(100% + 6px); min-width: 190px; display: grid; padding: 4px; z-index: 20;
             background: var(--card); color: var(--fg); border: 1px solid var(--line-strong); border-radius: var(--ix-radius); box-shadow: var(--ix-shadow-lg); }
.app-header .menu-list button, .menu-list button { border: 0; background: none; text-align: left; padding: 8px 10px; border-radius: var(--ix-radius-sm); color: var(--fg); font-weight: 400; }
.app-header .menu-list button:hover, .menu-list button:hover:not(:disabled) { background: var(--sel); }
.menu-list hr { margin: 4px 0; width: 100%; }
.app-header .menu > button { color: #E2E8F0; }

/* ── Light / Dark / System switch (built by theme.js into any element with data-theme-switch) ── */
.theme-switch { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--line-strong); border-radius: 99px; background: var(--card); }
.theme-switch button { border: 0; border-radius: 99px; padding: 3px 10px; font-size: 12px; background: transparent; color: var(--muted); }
.theme-switch button:hover:not(:disabled) { color: var(--fg); }
.theme-switch button[aria-pressed="true"] { background: var(--ix-primary); color: var(--ix-primary-text); font-weight: 600; }
.app-header .theme-switch, .login-page .theme-switch { background: transparent; border-color: rgba(255,255,255,.22); }
.app-header .theme-switch button, .login-page .theme-switch button { color: #A7B2C3; background: transparent; border: 0; }
.app-header .theme-switch button:hover, .login-page .theme-switch button:hover { color: #fff; }
.app-header .theme-switch button[aria-pressed="true"], .login-page .theme-switch button[aria-pressed="true"] { background: var(--ix-primary); color: var(--ix-primary-text); }
.theme-corner { position: fixed; top: 12px; right: 12px; z-index: 5; }

/* ── Dialog, toast ──────────────────────────────────────────────────────────── */
dialog { border: 1px solid var(--line); border-radius: var(--ix-radius-lg); background: var(--card); color: var(--fg); padding: 18px;
         box-shadow: var(--ix-shadow-lg); }
dialog::backdrop { background: rgba(13, 13, 13, .55); }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--ix-sidebar-bg); color: #F1F5F9; padding: 9px 16px;
         border-radius: var(--ix-radius); border-left: 3px solid var(--ix-primary); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 30; }
.toast.on { opacity: 1; }

/* ── Login card (iron + amber background, as in Infralytix) ─────────────────── */
.login-page { min-height: 100vh; display: grid; place-items: center; background: var(--ix-login-bg); padding: 16px; }
.login { width: min(380px, 100%); border-top: 3px solid var(--ix-primary); box-shadow: var(--ix-shadow-lg); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
