/* ============================================================
   RAE Applications — "Engineered Product"
   Refined, content-forward: lets the app screenshots lead. Keeps the
   industrial DNA (amber accent, monogram system) without the CRT costume.
   Type: Archivo (display) · IBM Plex Sans (body) · IBM Plex Mono (labels).
   ============================================================ */

:root {
    --bg:        #0e1217;
    --bg-2:      #141a22;
    --panel:     #171d27;
    --panel-2:   #1d2631;
    --ink:       #e9edf3;
    --muted:     #93a0b1;
    --faint:     #62707f;
    --line:      #28313d;
    --line-soft: #202833;

    --accent:    #f0641e;
    --accent-2:  #ff8a4c;
    --accent-soft: rgba(240,100,30,.16);
    --cyan:      #3bb6d6;
    --online:    #3ddc97;

    --grid:      rgba(255,255,255,.022);
    --radius:    14px;
    --shadow:    0 1px 2px rgba(0,0,0,.30), 0 12px 30px rgba(0,0,0,.34);
    --shadow-hi: 0 4px 10px rgba(0,0,0,.34), 0 26px 52px rgba(0,0,0,.5);

    --font-display: 'Archivo', 'Segoe UI', system-ui, sans-serif;
    --font-body: 'IBM Plex Sans', 'Segoe UI', system-ui, sans-serif;
    --font-mono: 'IBM Plex Mono', 'Cascadia Code', Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0; min-height: 100%;
    font-family: var(--font-body); color: var(--ink);
    background-color: var(--bg);
    background-image:
        linear-gradient(var(--grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid) 1px, transparent 1px);
    background-size: 30px 30px; background-attachment: fixed;
    -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
::selection { background: var(--accent); color: #1a1206; }

/* ---------------- top bar (clean product chrome) ---------------- */
.topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 28px; background: rgba(14,18,23,.85); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}
.topbar .left { display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 11px; }

/* Prominent "back to the RAE Portal" button (the landing site that links people here). */
.btn-portal {
    display: inline-flex; align-items: center; gap: 7px;
    font-family: var(--font-body); font-size: 13px; font-weight: 700;
    background: var(--accent); color: #1a1206; border: 1px solid transparent;
    border-radius: 9px; padding: 8px 15px; transition: background .15s;
}
.btn-portal:hover { background: var(--accent-2); color: #1a1206; }
.btn-portal .arr { font-size: 14px; line-height: 1; }
.brand .mark {
    width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center;
    background: var(--accent); color: #1a1206; font-family: var(--font-mono); font-weight: 700; font-size: 13px;
}
.brand .wordmark { font-family: var(--font-display); font-weight: 800; font-size: 15px; letter-spacing: .04em; color: var(--ink); text-transform: uppercase; }
.brand .wordmark span { color: var(--muted); font-weight: 600; }
.topbar .right { display: flex; align-items: center; gap: 12px; }

.btn-request {
    font-family: var(--font-body); font-size: 13px; font-weight: 600;
    background: transparent; color: var(--ink); border: 1px solid var(--line);
    border-radius: 9px; padding: 8px 15px; cursor: pointer; transition: border-color .15s, color .15s; display: inline-block;
}
.btn-request:hover { border-color: var(--accent); color: var(--accent); }
.user-pill { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.user-pill .led { width: 7px; height: 7px; border-radius: 50%; background: var(--online); }
.sys-status { display: none; }  /* retired with the HUD chrome */

.theme-toggle {
    width: 34px; height: 34px; border-radius: 8px; cursor: pointer;
    background: transparent; border: 1px solid var(--line); color: var(--muted);
    display: grid; place-items: center; font-size: 15px; line-height: 1; transition: border-color .14s, color .14s;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-ico::before { content: "\2600"; }
[data-theme="light"] .theme-ico::before { content: "\263E"; }

/* ---------------- hero ---------------- */
.hero { display: flex; flex-direction: column; align-items: center; gap: 15px; padding: 50px 16px 6px; }
.hero .logo { font-family: var(--font-display); font-weight: 800; font-size: clamp(30px, 5vw, 46px); letter-spacing: -.015em; color: var(--ink); line-height: 1; }
.hero .logo .rae { color: var(--accent); }
.hero .logo em { font-style: normal; font-weight: 500; color: var(--ink); }
.hero .logo::after { content: ""; display: block; height: 3px; width: 48px; margin: 13px auto 0; background: var(--accent); border-radius: 2px; }
.hero .tagline { font-family: var(--font-mono); font-size: 11px; letter-spacing: .26em; text-transform: uppercase; color: var(--faint); margin-top: -3px; }
.hero h1.tag-title { margin: 4px 0 0; font-family: var(--font-mono); font-weight: 500; font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }

/* ---------------- search ---------------- */
.search-wrap { position: relative; width: min(560px, 92%); display: flex; align-items: center; }
.search-wrap .prompt { position: absolute; left: 16px; display: grid; color: var(--faint); pointer-events: none; }
.search {
    width: 100%; font-family: var(--font-body); font-size: 15px; color: var(--ink); caret-color: var(--accent);
    padding: 13px 18px 13px 44px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
    box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s;
}
.search::placeholder { color: var(--faint); }
.search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

/* ---------------- tag chips ---------------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 940px; margin: 20px auto 30px; padding: 0 16px; }
.chip {
    font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .07em; text-transform: uppercase;
    padding: 7px 14px; border-radius: 8px; background: transparent; border: 1px solid var(--line); color: var(--muted);
    cursor: pointer; transition: color .14s, border-color .14s, background .14s;
}
.chip:hover { color: var(--ink); border-color: var(--muted); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #1a1206; }

/* ---------------- card grid (screenshot-forward, uniform tiles) ---------------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; max-width: 1200px; margin: 0 auto 56px; padding: 0 24px; }

.card {
    position: relative; overflow: hidden; cursor: pointer;
    display: flex; flex-direction: column; text-align: left;
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: transform .18s cubic-bezier(.2,.7,.3,1), box-shadow .2s, border-color .2s;
    animation: cardIn .5s cubic-bezier(.2,.7,.3,1) both;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hi); border-color: #3a4654; }
/* Transparent full-card link: the whole card is a real anchor (single-click launch, no pop-up block).
   Sits below the pin (z-index 3) so the favorite toggle stays clickable. */
.card .card-launch { position: absolute; inset: 0; z-index: 1; }
.card:has(.card-launch:focus-visible) { border-color: var(--accent); }   /* keyboard focus only */

/* uniform media area — screenshot OR gradient monogram panel */
.card .media { position: relative; height: 150px; overflow: hidden; background: var(--bg-2); border-bottom: 1px solid var(--line); }
.card .media img { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; transition: transform .3s ease; }
.card:hover .media img { transform: scale(1.05); }
.card .media.mono { display: grid; place-items: center; }
.card .media.mono.is-download { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.card .media.mono.is-web { background: linear-gradient(135deg, var(--cyan), #1f7e98); }
.card .media .mono-big { font-family: var(--font-mono); font-weight: 700; font-size: 38px; letter-spacing: .04em; color: rgba(20,12,6,.82); }
.card .media .online {
    position: absolute; top: 9px; right: 10px; display: inline-flex; align-items: center; gap: 5px;
    font-family: var(--font-mono); font-size: 9px; letter-spacing: .1em; text-transform: uppercase; color: #e6edf4;
    background: rgba(8,11,16,.6); border: 1px solid rgba(255,255,255,.12); padding: 3px 7px; border-radius: 6px; backdrop-filter: blur(4px);
}
.card .media .online .led { width: 6px; height: 6px; border-radius: 50%; background: var(--online); }
.card .media .online.degraded .led { background: #ffc53d; box-shadow: 0 0 6px rgba(255,197,61,.6); }
.card .media .online.degraded { color: #ffe08a; }
.card .media .online.down .led { background: #ff6b5e; box-shadow: 0 0 6px rgba(255,107,94,.6); }
.card .media .online.unknown .led { background: #93a0b1; }
.card .media .online.unknown { color: #b7c2cf; }

.card .body { display: flex; flex-direction: column; gap: 7px; padding: 14px 16px 15px; flex: 1; }
.card .name { font-family: var(--font-display); font-weight: 700; font-size: 16px; line-height: 1.2; color: var(--ink); }
.card .desc { font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.card .meta { display: flex; align-items: center; gap: 8px; margin-top: auto; flex-wrap: wrap; }
.card .tags { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.card .tag { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); background: var(--bg-2); border: 1px solid var(--line); border-radius: 5px; padding: 3px 7px; }
.card .type { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.card .badge-popular { display: inline-flex; align-items: center; gap: 4px; font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.card .pin { position: absolute; top: 10px; left: 10px; z-index: 3; border: none; background: rgba(8,11,16,.55); border-radius: 6px; cursor: pointer; color: #cfd8e2; font-size: 14px; line-height: 1; padding: 4px 6px; transition: color .12s; backdrop-filter: blur(4px); }
.card .pin:hover { color: var(--accent); }
.card .pin.pinned { color: var(--accent); }

@keyframes cardIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.grid .card:nth-child(1){animation-delay:.02s}  .grid .card:nth-child(2){animation-delay:.06s}
.grid .card:nth-child(3){animation-delay:.10s}  .grid .card:nth-child(4){animation-delay:.14s}
.grid .card:nth-child(5){animation-delay:.18s}  .grid .card:nth-child(6){animation-delay:.22s}
.grid .card:nth-child(7){animation-delay:.26s}  .grid .card:nth-child(8){animation-delay:.30s}
.grid .card:nth-child(9){animation-delay:.34s}  .grid .card:nth-child(10){animation-delay:.38s}
.grid .card:nth-child(11){animation-delay:.42s} .grid .card:nth-child(12){animation-delay:.46s}
@media (prefers-reduced-motion: reduce) { .card { animation: none; } }

/* ---------------- app tile size (Serious): S · M · L segmented control ---------------- */
/* Uses the theme-aware vars so it adapts to light/dark automatically. */
.size-control { display: inline-flex; align-items: stretch; height: 34px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.size-control button {
    width: 30px; border: 0; border-left: 1px solid var(--line); background: transparent; color: var(--muted);
    font-family: var(--font-mono); font-size: 12px; font-weight: 600; line-height: 1; cursor: pointer;
    transition: color .14s, background .14s;
}
.size-control button:first-child { border-left: 0; }
.size-control button:hover { color: var(--accent); }
.size-control button.active { background: var(--accent); color: #1a1206; }

/* Medium == the base .grid/.card rules above (no override). Small + Large scale the whole
   tile proportionally (grid track + media height + monogram + padding + type). */
:root[data-size-serious="s"] .grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
:root[data-size-serious="s"] .card .media { height: 112px; }
:root[data-size-serious="s"] .card .media .mono-big { font-size: 30px; }
:root[data-size-serious="s"] .card .body { padding: 11px 13px 12px; gap: 6px; }
:root[data-size-serious="s"] .card .name { font-size: 14px; }
:root[data-size-serious="s"] .card .desc { font-size: 11.5px; }

:root[data-size-serious="l"] .grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 22px; max-width: 1500px; }
:root[data-size-serious="l"] .card .media { height: 200px; }
:root[data-size-serious="l"] .card .media .mono-big { font-size: 48px; }
:root[data-size-serious="l"] .card .body { padding: 18px 20px 19px; }
:root[data-size-serious="l"] .card .name { font-size: 18px; }
:root[data-size-serious="l"] .card .desc { font-size: 13.5px; }

/* ---------------- footer ---------------- */
.statusbar { display: flex; justify-content: center; align-items: center; gap: 10px; padding: 20px; border-top: 1px solid var(--line); color: var(--faint); font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; }
.statusbar a { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.statusbar a:hover { color: var(--accent); }

/* ---------------- one-time access & cookie notice ---------------- */
/* Shown only while <html data-notice="1"> (set pre-paint in App.razor, cleared on "Got it").
   z-index 60: above both shells' bottom bars (XP taskbar is 50), below the first-run picker (9999). */
.rae-notice {
    position: fixed; left: 50%; transform: translateX(-50%);
    bottom: 44px; z-index: 60;
    display: none; align-items: center; gap: 16px;
    width: min(760px, calc(100vw - 32px));
    padding: 13px 18px;
    background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow-hi);
    font-family: var(--font-body); font-size: 13px; color: var(--ink);
}
html[data-notice="1"] .rae-notice { display: flex; }
.rae-notice p { margin: 0; line-height: 1.5; }
.rae-notice strong { color: var(--accent-2); }
.rae-notice a { white-space: nowrap; text-decoration: underline; text-underline-offset: 3px; }
.rae-notice-ok {
    flex: none; cursor: pointer;
    font-family: var(--font-body); font-size: 13px; font-weight: 600;
    background: var(--accent); color: #1a1206; border: 1px solid transparent;
    border-radius: 9px; padding: 8px 16px; transition: background .15s;
}
.rae-notice-ok:hover { background: var(--accent-2); }

/* ---------------- privacy & cookies page ---------------- */
.privacy-page { max-width: 860px; }
.privacy-page .lead { font-size: 15px; color: var(--ink); }
.privacy-page h3 { margin-top: 28px; }
.privacy-page table { width: 100%; border-collapse: collapse; margin: 10px 0 4px; font-size: 13.5px; }
.privacy-page th { text-align: left; font-family: var(--font-mono); font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); }
.privacy-page td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.privacy-page code { font-family: var(--font-mono); font-size: 12px; color: var(--accent-2); background: var(--accent-soft); padding: 1px 5px; border-radius: 5px; }

/* ---------------- pages (admin / request / not-found) ---------------- */
.page { max-width: 1100px; margin: 0 auto; padding: 28px 24px 60px; }
.page h1 { font-family: var(--font-display); font-weight: 800; letter-spacing: -.01em; color: var(--ink); }
.page h3 { font-family: var(--font-display); font-weight: 700; color: var(--ink); }
.page p, .page td, .page li { color: var(--ink); }
.page a { color: var(--accent); }
.page label { font-family: var(--font-mono); font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.page input[type=text], .page input[type=number], .page select, .page textarea {
    font-family: var(--font-body); font-size: 14px; color: var(--ink);
    padding: 9px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; width: 100%; max-width: 560px; margin-top: 4px;
}
.page input:focus, .page select:focus, .page textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.page select option { background: var(--panel); color: var(--ink); }

.admin-table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.admin-table th { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); background: var(--bg-2); text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.admin-table td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); font-size: 14px; color: var(--ink); }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table button { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; background: transparent; border: 1px solid var(--line); border-radius: 6px; padding: 4px 9px; cursor: pointer; color: var(--ink); margin-right: 4px; }
.admin-table button:hover { border-color: var(--accent); color: var(--accent); }
.shot-thumb { width: 76px; height: 46px; object-fit: cover; object-position: top center; border-radius: 6px; border: 1px solid var(--line); display: block; margin-bottom: 6px; }
.shot-actions { display: flex; gap: 6px; align-items: center; }
.upload-btn { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; border: 1px solid var(--line); border-radius: 6px; padding: 4px 9px; cursor: pointer; color: var(--ink); }
.upload-btn:hover { border-color: var(--accent); color: var(--accent); }
.upload-btn input { display: none; }
.validation-message { color: var(--accent-2); font-family: var(--font-mono); font-size: 12px; }

/* ---------------- light theme ---------------- */
[data-theme="light"] {
    --bg: #eef1f5; --bg-2: #e7ebf1; --panel: #ffffff; --panel-2: #ffffff;
    --ink: #14202e; --muted: #5c6b7d; --faint: #8d9bab;
    --line: #d7dee7; --line-soft: #e6ebf1;
    --shadow: 0 1px 2px rgba(13,27,42,.05), 0 12px 28px rgba(13,27,42,.08);
    --shadow-hi: 0 6px 14px rgba(13,27,42,.08), 0 22px 46px rgba(13,27,42,.16);
}
[data-theme="light"] html, [data-theme="light"] body {
    background-color: var(--bg);
    background-image:
        linear-gradient(rgba(13,27,42,.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(13,27,42,.04) 1px, transparent 1px);
}
[data-theme="light"] .topbar { background: rgba(238,241,245,.85); }
[data-theme="light"] .card:hover { border-color: #c2ccd8; }

/* --- Health metrics page --- */
:root {
  --health-up: var(--online, #2f8f3a);
  --health-degraded: #d9a400;
  --health-down: #c0392b;
  --health-nodata: #9aa0a6;
}
.health-timeline { display: flex; width: 100%; height: 14px; border-radius: 3px; overflow: hidden; background: var(--health-nodata); }
.health-seg { min-width: 0; height: 100%; }
/* Every OBSERVED segment keeps a small floor so a thin sliver stays visible — not just
   down/degraded. (Early on, a 30-day bar may hold only hours of data, making Up a ~1px sliver.) */
.health-seg--up { background: var(--health-up); min-width: 3px; }
.health-seg--degraded { background: var(--health-degraded); min-width: 3px; }
.health-seg--down { background: var(--health-down); min-width: 3px; }
.health-seg--nodata { min-width: 2px; background: repeating-linear-gradient(45deg, #cfd3d7, #cfd3d7 3px, #e6e9ec 3px, #e6e9ec 6px); }
.health-badge--up { color: var(--health-up); }
.health-badge--degraded { color: var(--health-degraded); }
.health-badge--down { color: var(--health-down); }
.health-badge--nodata { color: var(--health-nodata); }
.health-legend { display: flex; gap: 1rem; font-size: .8rem; margin: .5rem 0; }
.health-legend span::before { content: ""; display: inline-block; width: .8em; height: .8em; margin-right: .3em; vertical-align: middle; border-radius: 2px; }
.health-legend .up::before { background: var(--health-up); }
.health-legend .degraded::before { background: var(--health-degraded); }
.health-legend .down::before { background: var(--health-down); }
.health-legend .nodata::before { background: #cfd3d7; }

/* App-usage metrics page (/admin/usage) */
.usage-windows { margin: .5rem 0 .75rem; font-family: var(--font-mono); font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.usage-win { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; background: transparent; border: 1px solid var(--line); border-radius: 6px; padding: 4px 9px; cursor: pointer; color: var(--ink); }
.usage-win:hover { border-color: var(--accent); color: var(--accent); }
.usage-win.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.usage-bar-wrap { width: 100%; min-width: 80px; height: 12px; background: var(--bg-2); border-radius: 3px; overflow: hidden; }
.usage-bar { height: 100%; background: var(--accent); border-radius: 3px; min-width: 2px; }
.usage-row--top td { font-weight: 600; }
.usage-never td { color: var(--muted); }
.usage-never .usage-bar { min-width: 0; }
