/*
 * ETC Headquarters — interface styles.
 *
 * One stylesheet, no build step and no CSS framework. Colours, type, spacing
 * and motion are tokens on :root; dark mode only redefines tokens.
 *
 * Colour hierarchy (approved ETC HQ branding):
 *   1. Primary   — navy #08111F: sidebar, primary buttons, key elements.
 *   2. Secondary — ETC blue #1465D6: links, focus and selected details.
 *   3. Accent    — workwear orange #F28C28: TESLA and activity indicators only.
 *   4. Neutrals  — white, light grey and dark navy surfaces.
 * The logo's red and green appear nowhere else, except as functional error
 * and success states. No decorative gradients.
 */

/* The whole stylesheet is the lowest cascade layer: hq.css (the premium
   interface, loaded next) overrides it through its own layers, while every
   existing page keeps working with the classes defined here. */
@layer legacy, tokens, base, layout, components, materials, motion;

@layer legacy {

/* ------------------------------------------------------------------ */
/* Fonts (self-hosted, SIL Open Font License; see fonts/README.md)     */
/* ------------------------------------------------------------------ */

@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("../fonts/manrope-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-20C4, U+2113,
    U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("../fonts/manrope-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: "Sora";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("../fonts/sora-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-20C4, U+2113,
    U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Sora";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("../fonts/sora-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;
}

/* ------------------------------------------------------------------ */
/* Tokens                                                              */
/* ------------------------------------------------------------------ */

:root {
  /* Brand (verified from etcsystems.co.rs, orange from ETC workwear) */
  --navy: #08111f;
  --navy-2: #0d1b2f;
  --blue: #1465d6;
  --orange: #f28c28;

  /* Roles */
  --primary: var(--navy);
  --primary-hover: var(--navy-2);
  --on-primary: #ffffff;
  --link: var(--blue);
  --focus: var(--blue);
  --selected-soft: rgba(20, 101, 214, 0.08);

  /* Surfaces and text */
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-muted: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cad5e2;
  --text: #0f172a;
  --text-muted: #45556c;
  --text-subtle: #90a1b9;

  /* Navigation: navy in both themes */
  --nav-bg: var(--navy);
  --nav-border: rgba(255, 255, 255, 0.08);
  --nav-text: #cad5e2;
  --nav-text-strong: #ffffff;
  --nav-muted: #62748e;
  --nav-hover: rgba(255, 255, 255, 0.05);
  --nav-active: rgba(255, 255, 255, 0.09);

  /* Status (functional only) */
  --status-neutral: #90a1b9;
  --status-info: var(--blue);
  --status-active: var(--orange);
  --status-ok: #00914f;
  --status-error: #dc1820;

  /* Type */
  --font-sans: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --font-display: "Sora", "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-md: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.75rem;
  --text-2xl: 2rem;

  /* Space (4 px base) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;

  /* Shape, depth, motion */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(8, 17, 31, 0.04), 0 2px 8px rgba(8, 17, 31, 0.04);
  --shadow-pop: 0 12px 32px rgba(8, 17, 31, 0.16);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --duration: 160ms;

  /* Layout */
  --sidebar-width: 272px;
  --topbar-height: 64px;
  --tabbar-height: 60px;
}

/* Dark mode follows the system setting; data-theme on <html> can force
   either mode once a per-user theme preference exists. Navy stays the
   primary colour as the page itself; primary buttons invert to white. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary: #f8fafc;
    --primary-hover: #e2e8f0;
    --on-primary: var(--navy);
    --link: #3080ff;               /* lighter ETC-site blue for contrast on navy */
    --focus: #3080ff;
    --selected-soft: rgba(48, 128, 255, 0.12);
    --bg: var(--navy);
    --surface: var(--navy-2);
    --surface-muted: #1d293d;
    --border: #1d293d;
    --border-strong: #314158;
    --text: #f8fafc;
    --text-muted: #90a1b9;
    --text-subtle: #62748e;
    --nav-bg: #050b15;
    --shadow: none;
    --shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.5);
  }
}

:root[data-theme="dark"] {
  --primary: #f8fafc;
  --primary-hover: #e2e8f0;
  --on-primary: var(--navy);
  --link: #3080ff;
  --focus: #3080ff;
  --selected-soft: rgba(48, 128, 255, 0.12);
  --bg: var(--navy);
  --surface: var(--navy-2);
  --surface-muted: #1d293d;
  --border: #1d293d;
  --border-strong: #314158;
  --text: #f8fafc;
  --text-muted: #90a1b9;
  --text-subtle: #62748e;
  --nav-bg: #050b15;
  --shadow: none;
  --shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.5);
}

/* ------------------------------------------------------------------ */
/* Base                                                                */
/* ------------------------------------------------------------------ */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, p {
  margin: 0;
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -100px;
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow-pop);
}

.skip-link:focus {
  top: var(--space-4);
}

/* ------------------------------------------------------------------ */
/* Brand                                                               */
/* ------------------------------------------------------------------ */

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
}

/* The official logo has dark grey parts and no reversed version, so it
   sits unmodified on a white tile wherever the background is dark. */
.brand__logo {
  display: grid;
  place-items: center;
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 0 0 1px var(--border);
}

.brand__logo img {
  display: block;
  width: 46px;
  height: 46px;
}

.brand__text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.2;
}

.brand__hq {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.brand__tag {
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.sidebar .brand__logo,
.auth__aside .brand__logo,
.tabbar .brand__logo {
  box-shadow: none;
}

.sidebar .brand__hq,
.auth__aside .brand__hq {
  color: var(--nav-text-strong);
}

.sidebar .brand__tag,
.auth__aside .brand__tag {
  color: var(--nav-muted);
}

/* Module name under the HQ brand; future modules appear beside it. */
.module-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-3) 0;
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--nav-text-strong);
}

.module-label::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--blue);
}

/* ------------------------------------------------------------------ */
/* Application shell                                                   */
/* ------------------------------------------------------------------ */

.app {
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar {
  display: none;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-height: var(--topbar-height);
  padding: env(safe-area-inset-top) var(--space-4) 0;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar__brand .brand__logo {
  width: 40px;
  height: 40px;
}

.topbar__brand .brand__logo img {
  width: 38px;
  height: 38px;
}

.topbar__date {
  display: none;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.topbar__actions {
  margin-left: auto;
}

.content {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: var(--space-5) var(--space-4)
    calc(var(--tabbar-height) + env(safe-area-inset-bottom) + var(--space-6));
}

.content:focus {
  outline: none;
}

@media (min-width: 1024px) {
  .app {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  }

  .sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    padding: var(--space-5) var(--space-4);
    background: var(--nav-bg);
    color: var(--nav-text);
  }

  .sidebar__head {
    padding: 0 var(--space-2) var(--space-4);
    margin-bottom: var(--space-1);
    border-bottom: 1px solid var(--nav-border);
  }

  .sidebar__head .brand {
    padding: 0 var(--space-1);
  }

  .sidebar__footer {
    margin-top: auto;
    padding-top: var(--space-4);
    border-top: 1px solid var(--nav-border);
  }

  .topbar {
    padding: 0 var(--space-6);
  }

  .topbar__brand {
    display: none;
  }

  .topbar__date {
    display: block;
  }

  .content {
    padding: var(--space-6);
  }

  .tabbar {
    display: none !important;
  }
}

@media (min-width: 1440px) {
  .content {
    padding: var(--space-6) var(--space-7);
  }
}

/* ------------------------------------------------------------------ */
/* Navigation (sidebar and mobile sheet)                               */
/* ------------------------------------------------------------------ */

.nav__heading {
  padding: var(--space-4) var(--space-3) var(--space-2);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--nav-muted);
}

.nav__list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav__link {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 40px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--nav-text);
  text-decoration: none;
  transition: background-color var(--duration) var(--ease), color var(--duration) var(--ease);
}

a.nav__link:hover {
  background: var(--nav-hover);
  color: var(--nav-text-strong);
}

.nav__link[aria-current="page"] {
  background: var(--nav-active);
  color: var(--nav-text-strong);
  font-weight: 600;
}

.nav__link.is-disabled {
  color: var(--nav-muted);
  cursor: default;
}

.nav__link > span:not(.nav__soon) {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav__soon {
  flex: none;
  margin-left: auto;
  padding: 0 6px;
  border: 1px solid var(--nav-border);
  border-radius: 999px;
  font-size: 0.625rem;
  font-weight: 500;
  line-height: 1.6;
  white-space: nowrap;
}

/* ------------------------------------------------------------------ */
/* Mobile tab bar                                                      */
/* ------------------------------------------------------------------ */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  padding: 0 var(--space-1) env(safe-area-inset-bottom);
  background: var(--nav-bg);
  border-top: 1px solid var(--nav-border);
}

.tabbar__item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: var(--tabbar-height);
  padding: 0 1px;
  font-size: 0.65625rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--nav-muted);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  list-style: none;
  -webkit-tap-highlight-color: transparent;
}

.tabbar__item > span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

a.tabbar__item,
.tabbar__more > summary {
  color: var(--nav-text);
}

.tabbar__item[aria-current="page"],
.tabbar__more[open] > summary {
  color: var(--nav-text-strong);
  font-weight: 600;
}

/* Small blue mark under the active tab's icon. */
.tabbar__item[aria-current="page"]::after {
  content: "";
  position: absolute;
  top: 6px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--blue);
}

.tabbar__item.is-disabled {
  cursor: default;
}

.tabbar__more > summary::-webkit-details-marker {
  display: none;
}

/* The backdrop belongs to the summary, so tapping it closes the sheet. */
.tabbar__more[open] > summary::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(8, 17, 31, 0.55);
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom));
  max-height: 72vh;
  max-height: 72dvh;
  overflow-y: auto;
  padding: var(--space-2) var(--space-4) var(--space-4);
  background: var(--nav-bg);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: 0 -12px 32px rgba(0, 0, 0, 0.3);
}

.sheet .nav__link {
  min-height: 48px;
}

.sheet__footer {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--nav-border);
}

/* ------------------------------------------------------------------ */
/* User menu                                                           */
/* ------------------------------------------------------------------ */

.usermenu {
  position: relative;
}

.usermenu__button {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: var(--space-1) var(--space-2) var(--space-1) var(--space-1);
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  list-style: none;
  transition: background-color var(--duration) var(--ease), border-color var(--duration) var(--ease);
}

.usermenu__button::-webkit-details-marker {
  display: none;
}

.usermenu__button:hover,
.usermenu[open] .usermenu__button {
  background: var(--surface);
  border-color: var(--border);
}

.usermenu__button > .icon {
  width: 16px;
  height: 16px;
  color: var(--text-subtle);
}

.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--navy);
  color: #ffffff;
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  box-shadow: 0 0 0 1px var(--border-strong);
}

.usermenu__who {
  display: none;
  flex-direction: column;
  line-height: 1.2;
}

.usermenu__name {
  font-size: var(--text-sm);
  font-weight: 600;
}

.usermenu__role {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

@media (min-width: 640px) {
  .usermenu__who {
    display: flex;
  }
}

.usermenu__panel {
  position: absolute;
  right: 0;
  top: calc(100% + var(--space-2));
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  width: min(300px, calc(100vw - 2 * var(--space-4)));
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
}

.usermenu__status {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.usermenu__language label {
  display: block;
  margin-bottom: var(--space-1);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
}

.inline-field {
  display: flex;
  gap: var(--space-2);
}

.inline-field select {
  flex: 1;
  min-width: 0;
}

/* ------------------------------------------------------------------ */
/* Forms and buttons                                                   */
/* ------------------------------------------------------------------ */

input[type="text"],
input[type="password"],
input[type="email"],
select {
  width: 100%;
  min-height: 44px;
  padding: 0 var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: var(--text-md);     /* 16 px stops iOS zooming into fields */
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--selected-soft);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0 var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--duration) var(--ease), border-color var(--duration) var(--ease),
    color var(--duration) var(--ease);
}

.btn--block {
  width: 100%;
}

.btn--primary {
  background: var(--primary);
  color: var(--on-primary);
}

.btn--primary:hover {
  background: var(--primary-hover);
}

.btn--secondary {
  background: var(--surface-muted);
  border-color: var(--border-strong);
}

.btn--secondary:hover {
  border-color: var(--text-subtle);
}

.btn--ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}

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

.btn .icon {
  width: 18px;
  height: 18px;
}

.form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.field label {
  display: block;
  margin-bottom: var(--space-1);
  font-size: var(--text-sm);
  font-weight: 600;
}

.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
}

.alert--error {
  background: color-mix(in srgb, var(--status-error) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--status-error) 35%, transparent);
}

.alert ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* ------------------------------------------------------------------ */
/* Page header                                                         */
/* ------------------------------------------------------------------ */

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-3) var(--space-5);
  margin-bottom: var(--space-5);
}

.eyebrow {
  margin-bottom: var(--space-1);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--link);
}

.page-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.page-subtitle {
  margin-top: var(--space-1);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.meta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-muted);
}

.meta .icon {
  width: 14px;
  height: 14px;
}

.stack > * + * {
  margin-top: var(--space-5);
}

/* ------------------------------------------------------------------ */
/* Status pill                                                         */
/* ------------------------------------------------------------------ */

.pill {
  --pill-color: var(--status-neutral);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid color-mix(in srgb, var(--pill-color) 40%, transparent);
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
  color: var(--pill-color);
}

.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ------------------------------------------------------------------ */
/* TESLA agent status                                                  */
/* ------------------------------------------------------------------ */

.tesla {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-5);
  background: var(--navy);
  border: 1px solid #1d293d;
  border-radius: var(--radius-lg);
  color: #cad5e2;
}

.tesla__mark {
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #62748e;
}

.tesla__mark .icon {
  position: relative;
  width: 28px;
  height: 28px;
  stroke-width: 1.5;
}

/* Orange marks TESLA only when it has something to report. */
.tesla:not([data-state="not_configured"]):not([data-state="idle"]) .tesla__mark {
  color: var(--orange);
  border-color: rgba(242, 140, 40, 0.4);
}

/* Radar sweep: only rendered while TESLA is actually working. */
.tesla__sweep {
  position: absolute;
  inset: 0;
  display: none;
  border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(242, 140, 40, 0.3), transparent 25%);
}

.tesla[data-state="researching"] .tesla__sweep,
.tesla[data-state="analysing"] .tesla__sweep {
  display: block;
  animation: tesla-sweep 2.4s linear infinite;
}

@keyframes tesla-sweep {
  to {
    transform: rotate(1turn);
  }
}

.tesla__eyebrow {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #90a1b9;
}

.tesla__title {
  margin-top: 2px;
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #ffffff;
}

.tesla__detail {
  margin-top: var(--space-1);
  max-width: 68ch;
  font-size: var(--text-sm);
  color: #90a1b9;
}

.tesla__state {
  grid-column: 1 / -1;
}

.tesla .pill {
  --pill-color: #90a1b9;
}

.tesla[data-state="scheduled"] .pill {
  --pill-color: #cad5e2;
}

.tesla[data-state="researching"] .pill,
.tesla[data-state="analysing"] .pill {
  --pill-color: var(--orange);
}

.tesla[data-state="completed"] .pill {
  --pill-color: #05df72;
}

.tesla[data-state="error"] .pill {
  --pill-color: #ff6467;
}

@media (min-width: 720px) {
  .tesla {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: var(--space-5);
    padding: var(--space-5) var(--space-6);
  }

  .tesla__state {
    grid-column: auto;
  }
}

/* In dark mode the card would merge with the navy page; lift it slightly. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tesla {
    background: #050b15;
  }
}

:root[data-theme="dark"] .tesla {
  background: #050b15;
}

/* ------------------------------------------------------------------ */
/* KPI cards                                                           */
/* ------------------------------------------------------------------ */

.kpis {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.kpi {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.kpi__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
}

.kpi__label {
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-muted);
}

.kpi__icon {
  display: none;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--text-muted);
}

.kpi__icon .icon {
  width: 18px;
  height: 18px;
}

.kpi__value {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.kpi__value.is-empty {
  color: var(--border-strong);
}

.kpi__note {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

@media (min-width: 720px) {
  .kpis {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: var(--space-4);
  }

  .kpi__icon {
    display: grid;
  }
}

/* ------------------------------------------------------------------ */
/* Dashboard panels                                                    */
/* ------------------------------------------------------------------ */

.dashboard-grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 1100px) {
  .dashboard-grid {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: var(--space-5);
  }

  .panel--wide {
    grid-column: span 8;
  }

  .panel--narrow {
    grid-column: span 4;
  }

  .panel--half {
    grid-column: span 6;
  }
}

.panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.panel__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}

.panel__icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--text);
}

.panel__icon .icon {
  width: 17px;
  height: 17px;
}

.panel__title {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.panel__body {
  display: flex;
  flex: 1;
  padding: var(--space-5);
}

.empty {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  max-width: 46ch;
  margin: auto;
  padding: var(--space-4) 0;
  text-align: center;
}

.empty__title {
  font-size: var(--text-sm);
  font-weight: 700;
}

.empty__text {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* ------------------------------------------------------------------ */
/* Record pages: lists, details, evidence                              */
/* ------------------------------------------------------------------ */

/* Pill tones. Green and red are functional success and error states only;
   orange marks activity in progress, as elsewhere. */
.pill--ok {
  --pill-color: var(--status-ok);
}

.pill--info {
  --pill-color: var(--status-info);
}

.pill--error {
  --pill-color: var(--status-error);
}

.pill--active {
  --pill-color: var(--status-active);
}

.pill--neutral {
  --pill-color: var(--text-muted);
}

a.pill {
  text-decoration: none;
}

a.pill:hover {
  background: var(--selected-soft);
}

.muted {
  color: var(--text-muted);
}

.mono {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  word-break: break-all;
}

.unknown {
  color: var(--text-subtle);
  font-style: italic;
}

.link,
.table__link,
.breadcrumb a,
.panel__link,
.claim__meta a,
.timeline__by a {
  color: var(--link);
  text-decoration: none;
}

.link:hover,
.table__link:hover,
.breadcrumb a:hover,
.panel__link:hover,
.claim__meta a:hover,
.timeline__by a:hover {
  text-decoration: underline;
}

.table__link {
  font-weight: 600;
}

.note {
  font-size: var(--text-sm);
  color: var(--text-muted);
  max-width: 80ch;
}

.count {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-muted);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.tag {
  display: inline-block;
  padding: 1px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
}

.tag--estimate {
  border-style: dashed;
}

.subheading {
  margin: var(--space-2) 0 0;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.panel__body--column {
  flex-direction: column;
  gap: var(--space-4);
}

.panel__link {
  margin-left: auto;
  font-size: var(--text-sm);
  font-weight: 600;
}

.panel__header .count + .panel__link {
  margin-left: var(--space-3);
}

.breadcrumb {
  margin-bottom: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 600;
}

.breadcrumb a::before {
  content: "← ";
}

.page-header__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

/* Filters */
.filters {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: minmax(0, 1fr);
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.filters input[type="search"] {
  width: 100%;
  min-height: 44px;
  padding: 0 var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: var(--text-md);
}

.filters__field label {
  display: block;
  margin-bottom: var(--space-1);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
}

.filters__actions {
  display: flex;
  gap: var(--space-2);
  align-items: flex-end;
}

.filters__actions .btn {
  flex: 1;
  text-decoration: none;
}

@media (min-width: 720px) {
  .filters {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    align-items: end;
  }

  .filters__search {
    grid-column: 1 / -1;
  }

  .filters__actions .btn {
    flex: none;
  }
}

@media (min-width: 1100px) {
  .filters__search {
    grid-column: span 2;
  }
}

/* Tables become stacked cards on narrow screens. */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.table th,
.table td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  vertical-align: top;
}

.table thead th {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table tbody tr + tr > * {
  border-top: 1px solid var(--border);
}

.table tbody th {
  font-weight: 500;
}

.table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table__sub {
  display: block;
  margin-top: 2px;
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--text-muted);
}

@media (max-width: 719px) {
  .table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .table,
  .table tbody,
  .table tr,
  .table th,
  .table td {
    display: block;
  }

  .table tbody tr {
    padding: var(--space-3) var(--space-4);
  }

  .table tbody tr + tr {
    border-top: 1px solid var(--border);
  }

  .table tbody tr + tr > * {
    border-top: 0;
  }

  .table th,
  .table td {
    padding: var(--space-1) 0;
  }

  .table tbody th {
    padding-bottom: var(--space-2);
    font-size: var(--text-md);
  }

  .table td {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
  }

  .table td::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-size: var(--text-xs);
    font-weight: 600;
  }

  .table .num {
    text-align: right;
  }
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.pagination .btn {
  text-decoration: none;
}

.btn.is-disabled {
  opacity: 0.45;
  cursor: default;
}

.pagination__status {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* Status summary */
.status-summary {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.status-summary__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.status-summary__count {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.status-summary--stacked {
  flex-direction: column;
}

.status-summary--stacked .status-summary__item {
  justify-content: space-between;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: var(--space-2) 0;
}

/* Section tabs */
.tabs {
  display: flex;
  gap: var(--space-1);
  margin-bottom: var(--space-5);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.tabs__item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0 var(--space-3);
  border-bottom: 2px solid transparent;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
}

.tabs__item[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--blue);
}

.tabs__item .count {
  margin-left: 0;
}

/* Detail layout */
.detail-grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: minmax(0, 1fr);
}

.detail-grid__main,
.detail-grid__side {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}

@media (min-width: 1100px) {
  .detail-grid {
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: var(--space-5);
  }
}

/* Definition lists of record values */
.facts {
  display: flex;
  flex-direction: column;
  margin: 0;
}

.facts__row {
  display: grid;
  gap: var(--space-1) var(--space-4);
  grid-template-columns: minmax(0, 1fr);
  padding: var(--space-3) 0;
  border-top: 1px solid var(--border);
}

.facts__row:first-child {
  border-top: 0;
  padding-top: 0;
}

.facts dt {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
}

.facts dd {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  margin: 0;
  font-size: var(--text-sm);
  min-width: 0;
}

.facts dd.mono {
  display: block;
}

.facts__value {
  font-weight: 600;
}

.facts__evidence {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.evidence-none {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

@media (min-width: 640px) {
  .facts__row {
    grid-template-columns: 200px minmax(0, 1fr);
    align-items: baseline;
  }

  .facts--compact .facts__row {
    grid-template-columns: 140px minmax(0, 1fr);
  }

  .facts--grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    column-gap: var(--space-5);
  }

  .facts--grid .facts__row {
    grid-template-columns: minmax(0, 1fr);
    border-top: 0;
    padding-top: 0;
  }
}

/* Claim kinds: the text always names the kind; the border style repeats
   it for quick scanning (solid fill, outline, dashed, plain). */
.kind {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
  color: var(--text-muted);
  text-decoration: none;
}

.kind--verified_fact {
  background: color-mix(in srgb, var(--status-ok) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--status-ok) 45%, transparent);
  color: var(--status-ok);
}

.kind--ai_extraction {
  border-color: color-mix(in srgb, var(--status-info) 50%, transparent);
  color: var(--status-info);
}

.kind--ai_estimate {
  border-style: dashed;
  border-color: var(--text-subtle);
}

.kind--manual {
  background: var(--surface-muted);
}

a.kind:hover {
  text-decoration: underline;
}

.certainty {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
}

.certainty--confirmed {
  color: var(--status-ok);
}

.certainty--estimated {
  font-style: italic;
}

/* Claims */
.claims {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

.claim {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-4) 0;
  border-top: 1px solid var(--border);
  scroll-margin-top: calc(var(--topbar-height) + var(--space-4));
}

.claim:first-child {
  border-top: 0;
  padding-top: 0;
}

.claim:target {
  margin: 0 calc(-1 * var(--space-3));
  padding-inline: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--selected-soft);
}

.claim.is-closed .claim__value {
  color: var(--text-muted);
  text-decoration: line-through;
}

.claim__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.claim__field {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.claim__subject {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.claim__value {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.claim__quote {
  margin: 0;
  padding: var(--space-2) var(--space-3);
  border-left: 3px solid var(--border-strong);
  background: var(--surface-muted);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
}

.claim__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-5);
  margin: 0;
  font-size: var(--text-xs);
}

.claim__meta > div {
  display: flex;
  gap: var(--space-1);
  min-width: 0;
}

.claim__meta dt {
  color: var(--text-muted);
}

.claim__meta dt::after {
  content: ":";
}

.claim__meta dd {
  margin: 0;
  overflow-wrap: anywhere;
}

/* Roles and short record lists */
.roles {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

.role {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-3) 0;
  border-top: 1px solid var(--border);
}

.role:first-child {
  border-top: 0;
  padding-top: 0;
}

.role.is-closed {
  opacity: 0.75;
}

.role__main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  font-size: var(--text-sm);
}

.role__name {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
}

.role__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
}

/* Change history */
.timeline {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline__item {
  position: relative;
  padding: 0 0 var(--space-4) var(--space-5);
  border-left: 1px solid var(--border);
  margin-left: 4px;
}

.timeline__item::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 4px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border-strong);
}

.timeline__item:last-child {
  padding-bottom: 0;
}

.timeline__when {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.timeline__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
}

.timeline__subject,
.timeline__by {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.timeline__old {
  color: var(--text-muted);
}

.timeline__new {
  font-weight: 600;
}

/* Access assessments */
.assessments {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

.assessment {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.assessment.is-current {
  border-color: color-mix(in srgb, var(--blue) 45%, var(--border));
}

.assessment__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.assessment__title {
  margin-right: auto;
  font-weight: 700;
  font-size: var(--text-sm);
}

/* Errors */
.error-message {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.code {
  margin: 0;
  padding: var(--space-3);
  overflow-x: auto;
  background: var(--surface-muted);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
}

/* ------------------------------------------------------------------ */
/* Login and standalone pages                                          */
/* ------------------------------------------------------------------ */

.auth {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.auth__aside {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding: calc(env(safe-area-inset-top) + var(--space-5)) var(--space-5) var(--space-5);
  background: var(--nav-bg);
  color: var(--nav-text);
}

.auth__module {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--nav-text-strong);
}

.auth__headline {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  line-height: 1.3;
  color: var(--nav-text-strong);
}

.auth__text {
  margin-top: var(--space-2);
  font-size: var(--text-sm);
}

.auth__agent {
  display: none;
  font-size: var(--text-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--nav-muted);
}

.auth__agent strong {
  font-family: var(--font-display);
  color: var(--orange);
}

.auth__main {
  display: flex;
  flex: 1;
  align-items: flex-start;
  justify-content: center;
  padding: var(--space-6) var(--space-4) calc(env(safe-area-inset-bottom) + var(--space-6));
}

.auth-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  width: 100%;
  max-width: 400px;
}

.auth--single .auth__main {
  align-items: center;
}

.auth--single .auth-card {
  padding: var(--space-6) var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.auth-card__title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-card__text {
  margin-top: calc(-1 * var(--space-2));
  font-size: var(--text-sm);
  color: var(--text-muted);
}

@media (min-width: 900px) {
  .auth {
    flex-direction: row;
  }

  .auth__aside {
    width: 44%;
    max-width: 560px;
    justify-content: space-between;
    padding: var(--space-7);
  }

  .auth__headline {
    font-size: 1.75rem;
    letter-spacing: -0.02em;
    max-width: 18ch;
  }

  .auth__text {
    max-width: 40ch;
    font-size: var(--text-md);
  }

  .auth__agent {
    display: block;
  }

  .auth__main {
    align-items: center;
    padding: var(--space-7);
  }
}

/* ------------------------------------------------------------------ */
/* TESLA: opportunities, contacts, evidence and reports                */
/* ------------------------------------------------------------------ */

textarea {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: var(--text-md);
  resize: vertical;
}

textarea:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--selected-soft);
}

.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Priority is a TESLA estimate: navy (solid) for HIGH, blue for MEDIUM,
   neutral for LOW. No red or green: those mean errors and success only. */
.prio {
  display: inline-block;
  min-width: 4.5em;
  padding: 3px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-align: center;
  color: var(--text-muted);
}

.prio--high {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}

.prio--medium {
  border-color: var(--link);
  color: var(--link);
}

.ok-text {
  color: var(--status-ok);
  font-weight: 600;
}

.cell-wrap {
  min-width: 16ch;
  max-width: 42ch;
  white-space: normal;
}

.plain-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.flash {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.flash__item {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-left: 3px solid var(--link);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: var(--text-sm);
}

.flash__item--error {
  border-left-color: var(--status-error);
}

.flash__item--success {
  border-left-color: var(--status-ok);
}

.meter {
  height: 6px;
  margin: var(--space-2) 0;
  border-radius: 999px;
  background: var(--surface-muted);
  overflow: hidden;
}

.meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--link);
}

.mini-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  margin: 0;
  width: 100%;
}

.mini-stats--wide {
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

.mini-stats div {
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
}

.mini-stats dt {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.mini-stats dd {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.opp-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.opp-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.opp-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}

.opp-card__score {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.opp-card__title {
  flex: 1 1 18ch;
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

.opp-card__title:hover {
  color: var(--link);
  text-decoration: underline;
}

.opp-card__meta {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.opp-card__why,
.opp-card__action {
  font-size: var(--text-sm);
}

.verdict {
  padding: var(--space-4);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-muted);
}

.verdict--yes {
  border-left: 4px solid var(--orange);
}

.verdict__label {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.verdict__value {
  margin-top: var(--space-1);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
}

.verdict__why {
  margin-top: var(--space-2);
  font-size: var(--text-sm);
}

.panel__icon--tesla {
  color: var(--orange);
}

.factors {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  max-width: 360px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.factors li {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
}

.quote {
  display: block;
  width: 100%;
  margin: var(--space-1) 0 0;
  padding-left: var(--space-3);
  border-left: 2px solid var(--border-strong);
  font-size: var(--text-xs);
  color: var(--text-muted);
  quotes: none;
}

.source-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--text-sm);
}

.source-list li {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.source-list .muted {
  font-size: var(--text-xs);
}

.src-chip {
  display: inline-block;
  max-width: 22ch;
  padding: 1px 8px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: var(--text-xs);
  color: var(--link);
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

.src-chip:hover {
  background: var(--selected-soft);
}

.company-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.company-card--target {
  border-color: var(--link);
  box-shadow: 0 0 0 1px var(--link) inset;
}

.company-card__role {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.company-card__name {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

.company-card__name:hover {
  color: var(--link);
}

.contact-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: var(--space-2) 0 0;
  padding: 0;
  list-style: none;
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
}

.contact-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
}

@media (max-width: 719px) {
  .table td.cell-wrap {
    display: block;
    max-width: none;
  }

  .table td.cell-wrap::before {
    display: block;
    margin-bottom: 2px;
  }
}

.contact-list__kind {
  min-width: 8ch;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ------------------------------------------------------------------ */
/* ETC HQ: monthly workbook figures                                    */
/* ------------------------------------------------------------------ */

/* Where a figure comes from: an Excel cell or ETC HQ's own calculation. */
.kpi__source,
.source-ref {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Amounts are longer than counts; on phones they get a smaller size so two
   cards still fit side by side. */
@media (max-width: 719px) {
  .kpi__value--amount {
    font-size: var(--text-lg);
  }
}

.flash__item--warning {
  border-left-color: var(--primary);
}

.flash__item .source-ref {
  display: block;
  margin-top: 2px;
}

.cost-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cost-list__row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  font-size: var(--text-sm);
}

.cost-list__row span:last-child {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.cost-list .meter {
  margin: 2px 0 0;
}

.period-form {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.period-form select {
  min-height: 40px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.figure-changed {
  font-weight: 700;
}

.table__scroll {
  width: 100%;
  overflow-x: auto;
}

/* ------------------------------------------------------------------ */
/* Motion preferences                                                  */
/* ------------------------------------------------------------------ */

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

} /* @layer legacy */
