/* ===================================================================
   Frydensberg Tech — M365 Automation Portal, pitch demo
   app.css — one stylesheet, no build step. Same house rule as
   website/public/assets/site.css: plain CSS, hand-edited, self-hosted
   fonts (no Google Fonts CDN request leaking a visitor's IP before
   consent — same reasoning as the marketing site, even though this
   build is only ever shown by Simon in a meeting, never distributed).

   Palette and component shapes come from the design canvas ("M365
   Automation Portal Demo", 6 artboards). Dark chrome tokens below are
   byte-identical to website/public/assets/site.css's --c-* tokens.
   The light report-card palette (--r-*) is scoped to .report-card
   only and must never leak into app chrome.
   =================================================================== */

:root {
  --bg: #070E18;
  --surface: #0C1624;
  --surface2: #111E30;
  --line: #1B2A3F;
  --ink: #E9EFF6;
  --muted: #93A6BC;
  --accent: #3ECFAE;
  --accent-ink: #04140F;
  --warn: #E9A23B;
  --danger: #E2566E;

  --r-navy: #0B2545;
  --r-teal: #2A9D8F;
  --r-warn: #E9A23B;
  --r-danger: #D1495B;
  --r-ink: #1c2430;
  --r-muted: #6b7684;
  --r-line: #e3e8ef;

  --font-sans: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
  --font-report: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;

  --max-w-content: 1440px;
}

/* ------------------------------------------------------------------
   Self-hosted fonts. Same two files per family as the marketing site
   uses (latin + latin-ext subsets) so æøå render correctly.
   ------------------------------------------------------------------ */
@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("fonts/space-grotesk-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("fonts/space-grotesk-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("fonts/jetbrains-mono-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("fonts/jetbrains-mono-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--ink); }
button { font-family: var(--font-sans); cursor: pointer; }
img { max-width: 100%; }

/* ------------------------------------------------------------------
   Demo badge — "Preview build · sample data" (login) / "Demo data"
   (app chrome pill in the top nav).
   ------------------------------------------------------------------ */
.demo-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 13px; border: 1px solid var(--line); border-radius: 100px;
  background: var(--surface); white-space: nowrap;
}
.demo-badge .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--warn); flex-shrink: 0; }
.demo-badge span.label {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .06em;
  color: var(--muted); text-transform: uppercase;
}
.pill-demo {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px;
  border: 1px solid var(--line); border-radius: 100px;
}
.pill-demo .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--warn); }
.pill-demo span.label {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted);
}

/* ------------------------------------------------------------------
   App shell — top nav shared by dashboard / health score / automation
   / reports.
   ------------------------------------------------------------------ */
.topnav {
  height: 64px; flex-shrink: 0; display: flex; align-items: center;
  justify-content: space-between; padding: 0 28px;
  border-bottom: 1px solid var(--line); background: var(--surface);
}
.topnav .brand-group { display: flex; align-items: center; gap: 28px; }
.topnav .wordmark { height: 19px; width: auto; }
.topnav .divider { width: 1px; height: 22px; background: var(--line); }
.topnav nav { display: flex; gap: 22px; }
.navlink { font-size: 13.5px; color: var(--muted); padding: 8px 4px; cursor: pointer; }
.navlink.active { color: var(--ink); border-bottom: 2px solid var(--accent); }
.topnav .right { display: flex; align-items: center; gap: 16px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--surface2);
  border: 1px solid var(--line); display: flex; align-items: center;
  justify-content: center; font-size: 12px; font-weight: 600; color: var(--ink);
}
.hamburger-btn {
  display: none; background: transparent; border: none; padding: 6px;
  color: var(--ink);
}

.page { padding: 32px 40px 60px; flex: 1; }

/* ------------------------------------------------------------------
   Stat tiles.
   ------------------------------------------------------------------ */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 28px; }
.stat-tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: 9px;
  padding: 18px 20px;
}
.stat-tile.at-risk { border-left: 2px solid var(--danger); }
.stat-tile .value { font-size: 26px; font-weight: 600; }
.stat-tile .value.warn { color: var(--warn); }
.stat-tile .value.danger { color: var(--danger); }
.stat-tile .caption { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ------------------------------------------------------------------
   Table.
   ------------------------------------------------------------------ */
.data-card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
table.tenant-table { border-collapse: collapse; width: 100%; }
table.tenant-table th {
  text-align: left; font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); font-weight: 500; padding: 0 16px 12px; border-bottom: 1px solid var(--line);
}
table.tenant-table thead tr { padding-top: 16px; display: table-row; }
table.tenant-table td { padding: 16px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 13.5px; }
table.tenant-table tr:last-child td { border-bottom: none; }
table.tenant-table tbody tr:hover { background: var(--surface2); }
.tenant-name { font-weight: 600; font-size: 14px; }
.tenant-domain { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.score-cell { display: flex; align-items: center; gap: 10px; }
.score-cell .num { font-weight: 600; font-size: 14.5px; }
.score-cell .grade { font-size: 11px; font-weight: 600; }
.auto-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px;
  border-radius: 100px; font-size: 12px;
}
.auto-pill .dot { width: 6px; height: 6px; border-radius: 50%; }
.view-link { font-size: 12.5px; color: var(--accent); cursor: pointer; }
.view-link.disabled { color: var(--muted); cursor: default; }

/* ------------------------------------------------------------------
   Skeleton (loading state).
   ------------------------------------------------------------------ */
@keyframes pulse { 0%, 100% { opacity: .35; } 50% { opacity: .7; } }
.skel { background: var(--surface2); border-radius: 4px; animation: pulse 1.6s ease-in-out infinite; }

/* ------------------------------------------------------------------
   Empty / error states.
   ------------------------------------------------------------------ */
.empty-state {
  border: 1px dashed var(--line); border-radius: 10px; padding: 80px 20px;
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.empty-state h2 { font-size: 16px; font-weight: 600; margin: 18px 0 6px; }
.empty-state p { font-size: 13.5px; color: var(--muted); max-width: 360px; margin: 0 0 22px; line-height: 1.6; }

.error-banner {
  border: 1px solid rgba(226, 86, 110, .35); background: rgba(226, 86, 110, .06);
  border-radius: 10px; padding: 22px 24px; display: flex; align-items: flex-start; gap: 14px;
}
.error-banner .title { font-weight: 600; font-size: 14.5px; margin-bottom: 4px; }
.error-banner .body { font-size: 13px; color: var(--muted); line-height: 1.6; }

/* ------------------------------------------------------------------
   Buttons.
   ------------------------------------------------------------------ */
.btn {
  border-radius: 7px; padding: 9px 16px; font-family: var(--font-sans);
  font-size: 13.5px; border: 1px solid var(--line); background: transparent; color: var(--ink);
}
.btn-primary { background: var(--accent); border: none; color: var(--accent-ink); font-weight: 600; }
.btn-danger-outline { background: transparent; border: 1px solid rgba(226, 86, 110, .5); color: var(--danger); font-weight: 600; }

/* ------------------------------------------------------------------
   State switcher (demo-only convenience, not in the source design —
   lets Simon flip Populated/Empty/Loading/Error or Running/Completed/
   Failed live without editing a URL mid-pitch).
   ------------------------------------------------------------------ */
.state-switch { display: flex; gap: 6px; align-items: center; }
.state-switch a {
  font-family: var(--font-mono); font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted); padding: 4px 9px; border: 1px solid var(--line);
  border-radius: 100px;
}
.state-switch a.active { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }

/* ------------------------------------------------------------------
   Health score gauge + breakdown.
   ------------------------------------------------------------------ */
.score-gauge-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 28px;
  display: flex; flex-direction: column; align-items: center; text-align: center; height: fit-content;
}
.score-gauge-card .grade-label { margin-top: 14px; font-size: 15px; font-weight: 600; }
.score-gauge-card .coverage-note { margin-top: 12px; font-size: 12px; color: var(--muted); line-height: 1.65; }
.breakdown-card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 22px 26px; }
.breakdown-card .heading { font-size: 13px; font-weight: 600; margin-bottom: 16px; }
.dimrow {
  display: grid; grid-template-columns: 170px 44px 1fr; gap: 16px; align-items: center; padding: 14px 0;
}
.dimrow + .dimrow { border-top: 1px solid var(--line); }
.dimrow .dim-name { font-size: 13.5px; font-weight: 600; }
.dimrow .dim-weight { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.dimrow .dim-score { font-size: 15px; font-weight: 600; text-align: right; }
.dimrow .bar-track { height: 7px; border-radius: 100px; background: var(--surface2); overflow: hidden; margin-bottom: 7px; }
.dimrow .bar-fill { height: 100%; border-radius: 100px; }
.dimrow .dim-note { font-size: 12px; color: var(--muted); line-height: 1.5; }

.findings-card { margin-top: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 22px 26px; }
.finding-row { display: flex; align-items: center; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.finding-row:last-child { border-bottom: none; }
.finding-row .sev-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.finding-row .sev-label {
  width: 70px; flex-shrink: 0; font-family: var(--font-mono); font-size: 10.5px;
  text-transform: uppercase; letter-spacing: .04em;
}
.finding-row .text { flex: 1; font-size: 13.5px; }
.finding-row .action { font-size: 12.5px; color: var(--accent); cursor: pointer; flex-shrink: 0; }

/* ------------------------------------------------------------------
   Automation run view.
   ------------------------------------------------------------------ */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 1.1s linear infinite; transform-origin: center; }
.run-list { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; height: fit-content; }
.run-item { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.run-item:last-child { border-bottom: none; }
.run-item.selected { background: var(--surface2); border-left: 2px solid var(--accent); }
.run-item .head { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.run-item .title { font-size: 13px; font-weight: 600; }
.run-item .sub { font-size: 12px; color: var(--muted); }

.run-summary { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 20px 24px; margin-bottom: 16px; }
.run-summary .head-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.run-summary .subject { font-size: 15px; font-weight: 600; }
.run-summary .subject-meta { font-family: var(--font-mono); font-size: 12px; color: var(--muted); margin-top: 3px; }
.status-pill { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 100px; font-size: 12px; font-weight: 600; }
.status-pill .dot { width: 6px; height: 6px; border-radius: 50%; }
.run-summary .meta-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.run-summary .meta-grid .k { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.run-summary .meta-grid .v { font-size: 13px; }
.run-summary .meta-grid .v.mono { font-family: var(--font-mono); }

.step-timeline { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.step { display: flex; gap: 16px; padding: 18px 24px; }
.step + .step { border-top: 1px solid var(--line); }
.step .icon { flex-shrink: 0; width: 22px; padding-top: 1px; }
.step .body { flex: 1; }
.step .row { display: flex; align-items: center; justify-content: space-between; }
.step .step-title { font-size: 14px; font-weight: 600; }
.step .step-meta { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); }
.step .step-desc { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.step .step-log {
  margin-top: 9px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  padding: 8px 11px; font-family: var(--font-mono); font-size: 11.5px; color: var(--accent);
}
.step.is-failed .step-desc { color: var(--danger); }
.step.is-failed .step-log { color: var(--danger); }
.step.is-pending .step-title, .step.is-pending .step-desc { color: var(--muted); }

.confirmation-note { margin-top: 14px; font-size: 12px; color: var(--muted); line-height: 1.6; }

/* ------------------------------------------------------------------
   Reports view + light report-card palette (scoped, never mixed into
   app chrome).
   ------------------------------------------------------------------ */
.report-history { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; height: fit-content; }
.report-row { padding: 13px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.report-row:last-child { border-bottom: none; }
.report-row.selected { background: var(--surface2); border-left: 2px solid var(--accent); }
.report-row .title { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.report-row .sub { font-size: 11.5px; color: var(--muted); }

.lang-toggle { display: inline-flex; background: var(--surface2); border: 1px solid var(--line); border-radius: 100px; padding: 3px; }
.lang-toggle button {
  padding: 6px 16px; border-radius: 100px; font-size: 12.5px; font-weight: 600;
  border: none; background: transparent; color: var(--muted); font-family: var(--font-sans);
}
.lang-toggle button.active { background: var(--accent); color: var(--accent-ink); }

.report-card {
  background: #fff; border-radius: 8px; overflow: hidden;
  box-shadow: 0 20px 40px -20px rgba(0, 0, 0, .5); color: var(--r-ink);
}
.report-card .header {
  background: var(--r-navy); color: #fff; padding: 22px 26px; border-bottom: 4px solid var(--r-teal);
}
.report-card .eyebrow { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: #9FB3CC; }
.report-card h2 { margin: 5px 0 3px; font-size: 21px; font-weight: 600; font-family: var(--font-report); }
.report-card .subtitle { font-size: 12.5px; color: #C3D2E4; font-family: var(--font-report); }
.report-card .body { padding: 22px 26px; }
.report-tiles { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.report-tile {
  background: #fff; border: 1px solid var(--r-line); border-left: 4px solid var(--r-teal);
  border-radius: 6px; padding: 12px 16px; min-width: 150px; flex: 1 1 150px; font-family: var(--font-report);
}
.report-tile .value { font-size: 24px; font-weight: 600; color: var(--r-navy); }
.report-tile .label { font-size: 11px; color: var(--r-muted); text-transform: uppercase; letter-spacing: .04em; margin-top: 2px; }
.report-card .details-heading { font-size: 14px; font-weight: 600; color: var(--r-navy); margin-bottom: 10px; font-family: var(--font-report); }
.report-table-wrap { overflow-x: auto; border: 1px solid var(--r-line); border-radius: 6px; }
table.report-table { width: 100%; border-collapse: collapse; font-size: 12.5px; font-family: var(--font-report); }
table.report-table th {
  text-align: left; background: #eef2f7; color: var(--r-navy); font-weight: 600;
  padding: 8px 9px; border-bottom: 2px solid var(--r-line); white-space: nowrap;
}
table.report-table td { padding: 7px 9px; border-bottom: 1px solid var(--r-line); color: var(--r-ink); }
.report-card .footer { padding: 0 26px 20px; font-size: 11.5px; color: var(--r-muted); font-family: var(--font-report); }
.report-note { font-size: 13px; color: var(--muted); }

/* ===================================================================
   Responsive — dashboard at narrow viewports. Table collapses to
   stacked cards, stat row to 2x2, nav to hamburger.
   =================================================================== */
@media (max-width: 768px) {
  .page { padding: 20px 16px 40px; }
  .topnav { padding: 0 16px; }
  .topnav .divider { display: none; }
  .topnav nav { display: none; }
  .hamburger-btn { display: block; }
  .topnav .right span.username { display: none; }

  .stat-row { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-tile { padding: 14px 15px; }
  .stat-tile .value { font-size: 21px; }
  .stat-tile .caption { font-size: 11px; }

  /* table -> stacked cards */
  table.tenant-table thead { display: none; }
  table.tenant-table, table.tenant-table tbody, table.tenant-table tr, table.tenant-table td { display: block; width: 100%; }
  .data-card { border-radius: 10px; }
  table.tenant-table tr {
    background: var(--surface); border-radius: 10px; padding: 14px 15px; margin: 10px;
    border: 1px solid var(--line);
  }
  table.tenant-table td { padding: 0; border-bottom: none; }
  table.tenant-table td:not(:first-child) { margin-top: 9px; }
  table.tenant-table td[data-label]::before {
    content: attr(data-label); display: block; font-size: 10.5px; color: var(--muted);
    text-transform: uppercase; letter-spacing: .05em; margin-bottom: 3px;
  }
  .score-cell svg { width: 28px; height: 28px; }

  .automations-grid, .healthscore-grid, .reports-grid, .ticket-grid { grid-template-columns: 1fr !important; }
}

@media (max-width: 480px) {
  .stat-row { gap: 8px; }
}
