/* ============================================================
   KINETIC — Tenant Business Centre
   Admin-plane design system
   ============================================================ */

/* ── Google Font ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* ── Design Tokens ──
   Epic 68.1: Re-sourced onto the shared "Forward Motion v2" system
   (shared/design-system.css, loaded before this file). Token NAMES are
   unchanged — every existing consumer keeps working — but values now
   derive from --color-* system tokens. Orange primary, dual theme.
   Legacy purple (#7c3aed family) fully retired. */
:root {
  /* Background — follows the active theme via --color-* resolution */
  --bg-base: var(--color-background);
  --bg-panel: color-mix(in srgb, var(--color-surface) 86%, transparent);
  --bg-panel-solid: var(--color-surface-container-lowest);
  --bg-surface: color-mix(in srgb, var(--color-surface-container-low) 70%, transparent);
  --bg-hover: color-mix(in srgb, var(--color-primary) 10%, transparent);
  --bg-input: color-mix(in srgb, var(--color-surface-container-lowest) 90%, transparent);

  /* Accent — the Kinetic orange, from the system palette */
  --accent: var(--color-primary-container);
  --accent-light: color-mix(in srgb, var(--color-primary-container) 72%, white);
  --accent-dark: color-mix(in srgb, var(--color-primary-container) 78%, black);
  --accent-soft: color-mix(in srgb, var(--color-primary-container) 12%, transparent);
  --accent-glow: color-mix(in srgb, var(--color-primary-container) 26%, transparent);
  --accent-glow-lg: color-mix(in srgb, var(--color-primary-container) 40%, transparent);

  /* Borders — neutral outlines, no more indigo tint */
  --border-panel: 1px solid var(--color-outline-variant);
  --border-panel-alt: 1px solid color-mix(in srgb, var(--color-outline-variant) 80%, transparent);
  --border-input: 1px solid color-mix(in srgb, var(--color-outline) 55%, transparent);
  --border-subtle: 1px solid color-mix(in srgb, var(--color-on-surface) 6%, transparent);

  /* Text */
  --text-primary: var(--color-on-surface);
  --text-muted: var(--color-on-surface-variant);
  --text-faint: var(--color-outline);
  --text-accent: var(--color-primary);

  /* Semantic — aliased to system status colours (Epic 65.9 rules) */
  --danger: var(--color-error);
  --danger-soft: color-mix(in srgb, var(--color-error) 12%, transparent);
  --success: var(--color-success);
  --success-soft: color-mix(in srgb, var(--color-success) 12%, transparent);
  --warning: var(--color-warning, #f57f17);
  --warning-soft: color-mix(in srgb, var(--color-warning, #f57f17) 12%, transparent);
  --info: var(--color-tertiary);
  --info-soft: color-mix(in srgb, var(--color-tertiary) 12%, transparent);

  /* Semantic */
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.12);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.12);
  --info: #38bdf8;
  --info-soft: rgba(56, 189, 248, 0.12);

  /* Radius */
  --radius-card: 16px;
  --radius-input: 12px;
  --radius-pill: 999px;
  --radius-sm: 8px;
  --radius-xs: 6px;

  /* Shadow — neutral ring + restrained elevation (orange glows only on focus) */
  --shadow-card:
    0 0 0 1px color-mix(in srgb, var(--color-outline-variant) 60%, transparent),
    0 8px 32px rgba(0, 0, 0, 0.22);
  --shadow-panel:
    0 0 0 1px color-mix(in srgb, var(--color-outline-variant) 70%, transparent),
    0 16px 48px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 4px 20px var(--accent-glow);
  --shadow-glow-soft: 0 0 30px var(--accent-soft);
  --shadow-input: 0 0 0 3px var(--accent-soft);
  --shadow-input-err: 0 0 0 3px var(--danger-soft);

  /* Gradient */
  --grad-brand: linear-gradient(135deg, var(--accent-light), var(--accent));
  --grad-accent: linear-gradient(135deg, var(--accent), var(--accent-dark));
  --grad-subtle: linear-gradient(
    135deg,
    var(--accent-soft),
    color-mix(in srgb, var(--color-primary) 5%, transparent)
  );

  /* Transition */
  --t-fast: 150ms ease;
  --t-base: 220ms ease;
  --t-slow: 350ms ease;

  /* Layout */
  --sidebar-width: 18rem;
  --sidebar-min: 15rem;
  --topbar-h: 60px;
  --gap: 1rem;
  --pad: 1rem;
}

/* ============================================================
   RESET & BASE
   ============================================================ */

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family:
    'Inter',
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img,
svg {
  display: block;
  max-width: 100%;
}

a {
  color: var(--accent-light);
  text-decoration: none;
  transition: color var(--t-fast);
}

a:hover {
  color: var(--accent);
}

button,
input,
select,
textarea,
optgroup {
  font-family: inherit;
  font-size: inherit;
}

ul,
ol {
  list-style: none;
}

.hidden {
  display: none !important;
}
.auth-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  background: var(--bg-input);
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  border: var(--border-input);
}

.auth-tab {
  flex: 1;
  padding: 0.6rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-xs);
  transition: all var(--t-fast);
}

.auth-tab.active {
  background: var(--accent-soft);
  color: var(--accent-light);
}

.login-form button[type='submit'] {
  padding: 0.8rem 1.4rem;
  font-size: 0.92rem;
  font-weight: 700;
  background: var(--grad-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-input);
  cursor: pointer;
  transition:
    transform var(--t-fast),
    box-shadow var(--t-fast),
    filter var(--t-fast);
}

.login-form button[type='submit']:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
  filter: brightness(1.08);
}

hr {
  border: none;
  border-top: var(--border-subtle);
  margin: 1.5rem 0;
}

/* ============================================================
   SCROLLBAR
   ============================================================ */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(8, 12, 20, 0.5);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb {
  background: rgba(20, 184, 166, 0.35);
  border-radius: 999px;
  transition: background var(--t-base);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(20, 184, 166, 0.6);
}

::-webkit-scrollbar-corner {
  background: transparent;
}

/* ============================================================
   LAYOUT — APP SHELL
   ============================================================ */

.app-shell {
  display: grid;
  grid-template-columns: minmax(var(--sidebar-min), var(--sidebar-width)) 1fr;
  gap: var(--gap);
  padding: var(--pad);
  min-height: 100vh;
  position: relative;
}

/* Background ambient glow */
.app-shell::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(
      ellipse 80% 50% at 10% 20%,
      rgba(20, 184, 166, 0.04) 0%,
      transparent 60%
    ),
    radial-gradient(
      ellipse 60% 40% at 90% 80%,
      rgba(13, 148, 136, 0.03) 0%,
      transparent 60%
    );
  pointer-events: none;
  z-index: 0;
}

.app-shell > * {
  position: relative;
  z-index: 1;
}

/* ── Main Content Area ── */
.main-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  overflow: hidden;
  min-width: 0;
}

/* ============================================================
   SIDEBAR
   ============================================================ */

.sidebar {
  background: var(--bg-panel);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: var(--border-panel);
  border-right: 1px solid rgba(20, 184, 166, 0.1);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-panel);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 0;
  position: sticky;
  top: var(--pad);
  height: calc(100vh - 2 * var(--pad));
  overflow: hidden;
  padding: 0;
}

.sidebar-header {
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: var(--border-panel-alt);
}

.sidebar-nav {
  padding: 0.75rem 0.75rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: var(--border-panel-alt);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* ============================================================
   BRAND
   ============================================================ */

.brand {
  background: var(--grad-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 800;
  font-size: 1.6rem;
  line-height: 1.1;
  letter-spacing: -0.03em;
  display: inline-block;
}

.brand-lockup {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.eyebrow {
  color: var(--accent-light);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  line-height: 1;
}

/* ============================================================
   NAVIGATION
   ============================================================ */

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  margin-bottom: 1rem;
}

.nav-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 0.5rem 0.75rem 0.25rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  transition:
    background var(--t-fast),
    color var(--t-fast);
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
}

.nav-link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-link.active {
  background: var(--accent-soft);
  color: var(--accent-light);
  border-color: rgba(20, 184, 166, 0.18);
}

.nav-link .nav-icon {
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-link.active .nav-icon {
  opacity: 1;
}

.nav-badge {
  margin-left: auto;
  background: var(--accent-soft);
  color: var(--accent-light);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-pill);
  letter-spacing: 0.02em;
}

/* ============================================================
   TOPBAR / PAGE HEADER
   ============================================================ */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.page-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

/* ============================================================
   CARDS / PANELS
   ============================================================ */

.card {
  background: var(--bg-panel);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: var(--border-panel);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 1.5rem;
  transition:
    box-shadow var(--t-base),
    border-color var(--t-base);
}

.card:hover {
  box-shadow: var(--shadow-panel);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  gap: 1rem;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.card-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ── Panel (alias) ── */
.panel {
  background: var(--bg-panel);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: var(--border-panel);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

/* ============================================================
   METRICS GRID
   ============================================================ */

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.metric {
  background: var(--bg-panel);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: var(--border-panel);
  border-top: 2px solid var(--accent);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition:
    transform var(--t-base),
    box-shadow var(--t-base);
  animation: rise 0.5s ease both;
}

.metric:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-panel), var(--shadow-glow-soft);
}

.metric-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.metric-value {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--accent-light);
  line-height: 1;
  letter-spacing: -0.03em;
}

.metric-delta {
  font-size: 0.8rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.metric-delta.up {
  color: var(--success);
}
.metric-delta.down {
  color: var(--danger);
}
.metric-delta.flat {
  color: var(--text-muted);
}

.metric-icon {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.25rem;
  color: var(--accent-light);
}

/* ============================================================
   NAV TABS
   ============================================================ */

.nav-tabs {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--bg-panel-solid);
  border: var(--border-panel);
  border-radius: 12px;
  padding: 0.25rem;
  width: fit-content;
}

.tab-button {
  padding: 0.45rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition:
    background var(--t-fast),
    color var(--t-fast),
    border-color var(--t-fast);
  white-space: nowrap;
}

.tab-button:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.tab-button.active {
  background: rgba(20, 184, 166, 0.2);
  color: var(--accent-light);
  border-color: rgba(20, 184, 166, 0.25);
}

/* ── Underline tab variant ── */
.nav-tabs-underline {
  display: flex;
  align-items: center;
  gap: 0;
  border-bottom: 1px solid rgba(20, 184, 166, 0.12);
}

.nav-tabs-underline .tab-button {
  border-radius: 0;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 0.6rem 1.2rem;
  background: transparent;
}

.nav-tabs-underline .tab-button:hover {
  color: var(--text-primary);
  background: transparent;
  border-bottom-color: rgba(20, 184, 166, 0.3);
}

.nav-tabs-underline .tab-button.active {
  background: transparent;
  color: var(--accent-light);
  border-bottom-color: var(--accent);
}

/* ============================================================
   FORM ELEMENTS
   ============================================================ */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.form-label.required::after {
  content: ' *';
  color: var(--danger);
}

.form-hint {
  font-size: 0.76rem;
  color: var(--text-faint);
  margin-top: 0.2rem;
}

.form-error {
  font-size: 0.76rem;
  color: var(--danger);
  margin-top: 0.2rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ── Inputs ── */

input[type='text'],
input[type='email'],
input[type='password'],
input[type='search'],
input[type='url'],
input[type='tel'],
input[type='number'],
input[type='date'],
select,
textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid rgba(20, 184, 166, 0.2);
  border-radius: var(--radius-input);
  padding: 0.65rem 0.9rem;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition:
    border-color var(--t-fast),
    box-shadow var(--t-fast);
  appearance: none;
  -webkit-appearance: none;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-faint);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow-input);
}

input.error,
select.error,
textarea.error {
  border-color: var(--danger);
}

input.error:focus,
select.error:focus,
textarea.error:focus {
  box-shadow: var(--shadow-input-err);
}

input[disabled],
select[disabled],
textarea[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

textarea {
  resize: vertical;
  min-height: 100px;
}

/* ── Select custom arrow ── */
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235eead4' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  padding-right: 2.2rem;
}

select option {
  background: var(--bg-panel-solid);
  color: var(--text-primary);
}

/* ── Input with icon ── */
.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrapper input {
  padding-left: 2.5rem;
}

.input-icon {
  position: absolute;
  left: 0.75rem;
  color: var(--text-faint);
  pointer-events: none;
  width: 1rem;
  height: 1rem;
}

.input-wrapper:focus-within .input-icon {
  color: var(--accent-light);
}

.input-suffix {
  position: absolute;
  right: 0.75rem;
  color: var(--text-faint);
  font-size: 0.8rem;
}

/* ── Toggle / Checkbox ── */
.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  user-select: none;
}

.toggle input[type='checkbox'] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-track {
  width: 2.5rem;
  height: 1.4rem;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(20, 184, 166, 0.2);
  transition:
    background var(--t-base),
    border-color var(--t-base);
  position: relative;
  flex-shrink: 0;
}

.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: var(--text-muted);
  transition:
    transform var(--t-base),
    background var(--t-base);
}

.toggle input:checked ~ .toggle-track {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.toggle input:checked ~ .toggle-track .toggle-thumb {
  transform: translateX(1.1rem);
  background: var(--accent-light);
}

.toggle-label {
  font-size: 0.88rem;
  color: var(--text-primary);
  font-weight: 500;
}

/* ── Checkbox ── */
.checkbox-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
}

.checkbox-group input[type='checkbox'] {
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 4px;
  border: 1px solid rgba(20, 184, 166, 0.3);
  background: var(--bg-input);
  accent-color: var(--accent);
  cursor: pointer;
}

/* ── Radio ── */
.radio-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
}

.radio-group input[type='radio'] {
  width: 1rem;
  height: 1rem;
  border: 1px solid rgba(20, 184, 166, 0.3);
  background: var(--bg-input);
  accent-color: var(--accent);
  cursor: pointer;
}

/* ── Search bar ── */
.search-bar {
  position: relative;
  max-width: 340px;
}

.search-bar input[type='search'] {
  padding-left: 2.5rem;
  padding-right: 1rem;
  border-radius: var(--radius-pill);
  font-size: 0.875rem;
}

.search-bar .input-icon {
  left: 0.85rem;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-input);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  border: 1px solid transparent;
  transition:
    background var(--t-fast),
    box-shadow var(--t-fast),
    transform var(--t-fast),
    border-color var(--t-fast),
    color var(--t-fast);
  white-space: nowrap;
  text-decoration: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.btn svg {
  width: 1em;
  height: 1em;
  flex-shrink: 0;
}

/* ── Primary ── */
.btn-primary,
.primary-button {
  background: var(--grad-accent);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(20, 184, 166, 0.2);
}

.btn-primary:hover,
.primary-button:hover {
  box-shadow: var(--shadow-glow);
  filter: brightness(1.08);
}

/* ── Ghost ── */
.btn-ghost,
.ghost-button {
  background: transparent;
  border-color: rgba(20, 184, 166, 0.25);
  color: var(--text-muted);
}

.btn-ghost:hover,
.ghost-button:hover {
  border-color: var(--accent);
  color: var(--text-primary);
  background: var(--accent-soft);
}

/* ── Secondary ── */
.btn-secondary {
  background: var(--bg-surface);
  border-color: rgba(20, 184, 166, 0.18);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-light);
}

/* ── Danger ── */
.btn-danger {
  background: var(--danger-soft);
  border-color: rgba(248, 113, 113, 0.3);
  color: var(--danger);
}

.btn-danger:hover {
  background: rgba(248, 113, 113, 0.2);
  box-shadow: 0 4px 16px rgba(248, 113, 113, 0.25);
}

/* ── Success ── */
.btn-success {
  background: var(--success-soft);
  border-color: rgba(52, 211, 153, 0.3);
  color: var(--success);
}

.btn-success:hover {
  background: rgba(52, 211, 153, 0.2);
  box-shadow: 0 4px 16px rgba(52, 211, 153, 0.25);
}

/* ── Icon button ── */
.btn-icon {
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  background: transparent;
  border-color: rgba(20, 184, 166, 0.18);
  color: var(--text-muted);
}

.btn-icon:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-light);
}

/* ── Size variants ── */
.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 0.8rem 1.8rem;
  font-size: 1rem;
  border-radius: var(--radius-input);
}

.btn-pill {
  border-radius: var(--radius-pill);
}

/* ── Loading spinner ── */
.btn.loading .btn-text {
  opacity: 0;
}
.btn.loading::after {
  content: '';
  position: absolute;
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ============================================================
   BADGE / PILL / TAG
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge-accent {
  background: var(--accent-soft);
  color: var(--accent-light);
}
.badge-success {
  background: var(--success-soft);
  color: var(--success);
}
.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}
.badge-warning {
  background: var(--warning-soft);
  color: var(--warning);
}
.badge-info {
  background: var(--info-soft);
  color: var(--info);
}
.badge-muted {
  background: rgba(148, 163, 184, 0.1);
  color: var(--text-muted);
}

/* ── Tag (removable) ── */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  border: 1px solid rgba(20, 184, 166, 0.2);
  color: var(--accent-light);
  font-size: 0.78rem;
  font-weight: 500;
}

.tag-remove {
  cursor: pointer;
  opacity: 0.6;
  line-height: 1;
  transition: opacity var(--t-fast);
}

.tag-remove:hover {
  opacity: 1;
}

/* ============================================================
   STATUS INDICATORS
   ============================================================ */

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.status-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-indicator.online .status-dot {
  background: var(--success);
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.4);
  animation: pulse 2s ease-in-out infinite;
}

.status-indicator.offline .status-dot {
  background: var(--text-faint);
}
.status-indicator.error .status-dot {
  background: var(--danger);
}
.status-indicator.warning .status-dot {
  background: var(--warning);
}
.status-indicator.pending .status-dot {
  background: var(--info);
}

.status-indicator.online {
  color: var(--success);
}
.status-indicator.offline {
  color: var(--text-muted);
}
.status-indicator.error {
  color: var(--danger);
}
.status-indicator.warning {
  color: var(--warning);
}
.status-indicator.pending {
  color: var(--info);
}

/* ============================================================
   TABLE
   ============================================================ */

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-card);
  border: var(--border-panel);
  box-shadow: var(--shadow-card);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead {
  background: rgba(8, 12, 20, 0.6);
}

thead th {
  padding: 0.85rem 1.1rem;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-bottom: 1px solid rgba(20, 184, 166, 0.1);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  transition: background var(--t-fast);
}

tbody tr:last-child {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--bg-hover);
}

tbody td {
  padding: 0.85rem 1.1rem;
  color: var(--text-primary);
  vertical-align: middle;
}

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

/* ── Sortable header ── */
.th-sort {
  cursor: pointer;
  user-select: none;
}

.th-sort:hover {
  color: var(--accent-light);
}

/* ============================================================
   LIST ITEMS — TENANT / STACK
   ============================================================ */

.tenant-list,
.stack-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.tenant-item,
.stack-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--bg-panel);
  border: var(--border-panel);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition:
    border-color var(--t-base),
    box-shadow var(--t-base),
    transform var(--t-base),
    background var(--t-base);
  text-decoration: none;
  color: inherit;
}

.tenant-item:hover,
.stack-item:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-panel), var(--shadow-glow-soft);
  transform: translateY(-1px);
  background: rgba(13, 18, 30, 0.95);
}

.item-avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-sm);
  background: var(--grad-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.9rem;
  color: #fff;
  flex-shrink: 0;
  text-transform: uppercase;
}

.item-avatar.muted {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
}

.item-info {
  flex: 1;
  min-width: 0;
}

.item-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* ============================================================
   AVATAR
   ============================================================ */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 700;
  text-transform: uppercase;
  flex-shrink: 0;
  overflow: hidden;
}

.avatar-sm {
  width: 1.8rem;
  height: 1.8rem;
  font-size: 0.7rem;
}
.avatar-md {
  width: 2.4rem;
  height: 2.4rem;
  font-size: 0.9rem;
}
.avatar-lg {
  width: 3.2rem;
  height: 3.2rem;
  font-size: 1.2rem;
}
.avatar-xl {
  width: 4.5rem;
  height: 4.5rem;
  font-size: 1.6rem;
}

.avatar-teal {
  background: var(--grad-accent);
  color: #fff;
}
.avatar-surface {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-muted);
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Avatar group (overlapping) */
.avatar-group {
  display: flex;
  flex-direction: row-reverse;
}

.avatar-group .avatar {
  margin-left: -0.6rem;
  border: 2px solid var(--bg-panel-solid);
}

.avatar-group .avatar:last-child {
  margin-left: 0;
}

/* ============================================================
   PROGRESS BAR
   ============================================================ */

.progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--grad-accent);
  border-radius: var(--radius-pill);
  transition: width 0.6s ease;
}

.progress-fill.danger {
  background: var(--danger);
}
.progress-fill.warning {
  background: var(--warning);
}
.progress-fill.success {
  background: var(--success);
}

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

/* ============================================================
   DIVIDER
   ============================================================ */

.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-faint);
  font-size: 0.78rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(20, 184, 166, 0.1);
}

/* ============================================================
   MODAL / DIALOG
   ============================================================ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 20, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--bg-panel);
  border: var(--border-panel);
  border-radius: var(--radius-card);
  box-shadow:
    var(--shadow-panel),
    0 0 60px rgba(20, 184, 166, 0.08);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: rise 0.25s ease;
}

.modal-lg {
  max-width: 720px;
}
.modal-xl {
  max-width: 960px;
}
.modal-sm {
  max-width: 380px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: var(--border-panel-alt);
  flex-shrink: 0;
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: var(--border-panel-alt);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-shrink: 0;
}

.modal-close {
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid rgba(20, 184, 166, 0.15);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background var(--t-fast),
    color var(--t-fast);
}

.modal-close:hover {
  background: var(--accent-soft);
  color: var(--accent-light);
}

/* ============================================================
   TOAST / NOTIFICATION
   ============================================================ */

.toast-container {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  background: var(--bg-panel);
  border: var(--border-panel);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-panel);
  min-width: 280px;
  max-width: 380px;
  animation: rise 0.3s ease;
}

.toast-icon {
  width: 1.2rem;
  height: 1.2rem;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.toast-content {
  flex: 1;
  min-width: 0;
}
.toast-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
}
.toast-message {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.toast.success {
  border-left: 3px solid var(--success);
}
.toast.error {
  border-left: 3px solid var(--danger);
}
.toast.warning {
  border-left: 3px solid var(--warning);
}
.toast.info {
  border-left: 3px solid var(--accent);
}

.toast.success .toast-icon {
  color: var(--success);
}
.toast.error .toast-icon {
  color: var(--danger);
}
.toast.warning .toast-icon {
  color: var(--warning);
}
.toast.info .toast-icon {
  color: var(--accent);
}

/* ============================================================
   DROPDOWN MENU
   ============================================================ */

.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  background: var(--bg-panel);
  border: var(--border-panel);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-panel);
  min-width: 180px;
  z-index: 1000;
  overflow: hidden;
  animation: rise 0.15s ease;
}

.dropdown-menu.left {
  right: auto;
  left: 0;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.9rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  cursor: pointer;
  transition:
    background var(--t-fast),
    color var(--t-fast);
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.dropdown-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.dropdown-item.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.dropdown-item.active {
  color: var(--accent-light);
}

.dropdown-divider {
  height: 1px;
  background: rgba(20, 184, 166, 0.08);
  margin: 0.25rem 0;
}

.dropdown-header {
  padding: 0.5rem 0.9rem 0.25rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
}

/* ============================================================
   ALERT / BANNER
   ============================================================ */

.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem 1.1rem;
  border-radius: var(--radius-input);
  border: 1px solid transparent;
  font-size: 0.875rem;
}

.alert-icon {
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.alert-content {
  flex: 1;
}
.alert-title {
  font-weight: 700;
  margin-bottom: 0.2rem;
}
.alert-message {
  opacity: 0.85;
  line-height: 1.5;
}

.alert.info {
  background: var(--info-soft);
  border-color: rgba(56, 189, 248, 0.2);
  color: var(--info);
}
.alert.success {
  background: var(--success-soft);
  border-color: rgba(52, 211, 153, 0.2);
  color: var(--success);
}
.alert.warning {
  background: var(--warning-soft);
  border-color: rgba(251, 191, 36, 0.2);
  color: var(--warning);
}
.alert.danger {
  background: var(--danger-soft);
  border-color: rgba(248, 113, 113, 0.2);
  color: var(--danger);
}

/* ============================================================
   EMPTY STATE
   ============================================================ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 2rem;
  gap: 1rem;
}

.empty-icon {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: var(--radius-card);
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-light);
  font-size: 1.5rem;
}

.empty-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}
.empty-message {
  font-size: 0.875rem;
  color: var(--text-muted);
  max-width: 280px;
  line-height: 1.6;
}

/* ============================================================
   SKELETON LOADER
   ============================================================ */

.skeleton {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.03) 0%,
    rgba(255, 255, 255, 0.06) 50%,
    rgba(255, 255, 255, 0.03) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-xs);
}

.skeleton-text {
  height: 0.875rem;
  width: 100%;
}
.skeleton-title {
  height: 1.25rem;
  width: 60%;
}
.skeleton-card {
  height: 120px;
  border-radius: var(--radius-card);
}

/* ============================================================
   TOOLTIP
   ============================================================ */

[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 0.4rem);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(13, 18, 30, 0.98);
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-xs);
  border: 1px solid rgba(20, 184, 166, 0.18);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-fast);
  z-index: 100;
  box-shadow: var(--shadow-panel);
}

[data-tooltip]:hover::after {
  opacity: 1;
}

/* ============================================================
   LOGIN SCREEN
   ============================================================ */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}

/* Ambient radial glow */
.login-screen::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(
      ellipse 70% 55% at 20% 30%,
      rgba(20, 184, 166, 0.07) 0%,
      transparent 60%
    ),
    radial-gradient(
      ellipse 55% 45% at 80% 70%,
      rgba(13, 148, 136, 0.05) 0%,
      transparent 60%
    ),
    radial-gradient(
      ellipse 40% 30% at 50% 10%,
      rgba(94, 234, 212, 0.04) 0%,
      transparent 50%
    );
  pointer-events: none;
}

.login-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--bg-panel);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(20, 184, 166, 0.25);
  border-radius: calc(var(--radius-card) + 4px);
  box-shadow:
    0 0 0 1px rgba(20, 184, 166, 0.08),
    0 20px 60px rgba(0, 0, 0, 0.5),
    0 0 80px rgba(20, 184, 166, 0.06);
  padding: 2.5rem 2rem;
  animation: rise 0.5s ease;
}

.login-logo {
  text-align: center;
  margin-bottom: 0.5rem;
}

.login-brand {
  font-size: 2rem;
  font-weight: 800;
  background: var(--grad-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-tagline {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 2rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
}

.login-panel {
  width: min(100%, 32rem);
  background: var(--bg-panel);
  border: var(--border-panel);
  border-radius: calc(var(--radius-card) + 8px);
  padding: 2.5rem;
  box-shadow:
    var(--shadow-panel),
    0 0 60px rgba(20, 184, 166, 0.12);
  animation: rise 0.55s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  opacity: 0;
  transform: translateY(24px);
}

.login-panel h1 {
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 800;
  line-height: 1.1;
  color: var(--text-primary);
  margin: 0.25rem 0 1rem;
}

.login-panel .muted {
  margin-bottom: 1.75rem;
}

.auth-switch {
  width: 100%;
  margin-top: 0.75rem;
}

.error-text.success {
  color: var(--success);
}

.login-footer {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.8rem;
  color: var(--text-faint);
}

.login-footer a {
  color: var(--accent-light);
}

/* ============================================================
   TENANT COPILOT
   ============================================================ */

.copilot-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 320px);
  grid-template-rows: minmax(420px, 58vh) auto;
  gap: 1rem;
}

.copilot-messages {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  min-height: 420px;
  max-height: 58vh;
  overflow-y: auto;
  padding: 1rem;
  border: var(--border-panel);
  border-radius: var(--radius-card);
  background: rgba(8, 12, 20, 0.72);
}

.copilot-side {
  min-height: 420px;
  max-height: 58vh;
  overflow-y: auto;
  padding: 1rem;
  border: var(--border-panel);
  border-radius: var(--radius-card);
  background: rgba(12, 18, 30, 0.72);
}

.copilot-bubble {
  max-width: min(760px, 86%);
  padding: 0.8rem 1rem;
  border-radius: 14px;
  font-size: 0.92rem;
  line-height: 1.55;
  word-break: break-word;
}

.copilot-bubble.user {
  align-self: flex-end;
  color: var(--text-primary);
  background: rgba(20, 184, 166, 0.18);
  border: 1px solid rgba(20, 184, 166, 0.2);
}

.copilot-bubble.assistant {
  align-self: flex-start;
  color: var(--text-primary);
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.copilot-bubble.error {
  align-self: flex-start;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid rgba(248, 113, 113, 0.2);
}

.copilot-input-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
}

.copilot-input {
  width: 100%;
  min-width: 0;
  background: rgba(8, 12, 20, 0.8);
  border: 1px solid rgba(20, 184, 166, 0.25);
  border-radius: var(--radius-input);
  color: var(--text-primary);
  font: inherit;
  padding: 0.8rem 1rem;
  outline: none;
}

.copilot-input:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow-input);
}

.copilot-send {
  min-width: 96px;
  border: none;
  border-radius: var(--radius-input);
  background: var(--grad-accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.copilot-send:disabled,
.sandbox-send:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

/* ============================================================
   CHAT SANDBOX — PHONE FRAME
   ============================================================ */

.sandbox-wrapper {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 2rem;
  flex-wrap: wrap;
}

.sandbox-frame {
  width: 360px;
  height: 620px;
  border-radius: 36px;
  border: 2px solid rgba(20, 184, 166, 0.3);
  background: rgba(8, 12, 20, 0.95);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 0 60px rgba(20, 184, 166, 0.1),
    0 0 0 1px rgba(20, 184, 166, 0.06),
    0 24px 60px rgba(0, 0, 0, 0.6);
  position: relative;
  flex-shrink: 0;
}

/* ── Notch / Camera pill ── */
.sandbox-frame::before {
  content: '';
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 6px;
  background: rgba(20, 184, 166, 0.2);
  border-radius: var(--radius-pill);
  z-index: 10;
}

/* ── Frame header bar ── */
.sandbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.8rem 1.2rem 0.6rem;
  border-bottom: 1px solid rgba(20, 184, 166, 0.1);
  flex-shrink: 0;
}

.sandbox-agent-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.sandbox-agent-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--grad-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
}

.sandbox-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--grad-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
}

.sandbox-agent-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
}

.sandbox-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
}

.sandbox-agent-status {
  font-size: 0.68rem;
  color: var(--success);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.sandbox-sub {
  font-size: 0.68rem;
  color: var(--success);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.sandbox-sub::before {
  content: '';
  display: inline-block;
  width: 0.4rem;
  height: 0.4rem;
  background: var(--success);
  border-radius: 50%;
}

.sandbox-agent-status::before {
  content: '';
  display: inline-block;
  width: 0.4rem;
  height: 0.4rem;
  background: var(--success);
  border-radius: 50%;
}

/* ── Messages area ── */
.sandbox-messages {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
  flex: 1;
  overflow-y: auto;
}

/* ── Bubbles ── */
.sandbox-bubble {
  max-width: 80%;
  padding: 0.65rem 1rem;
  border-radius: 18px;
  font-size: 0.9rem;
  line-height: 1.5;
  word-break: break-word;
}

.sandbox-bubble.user {
  background: rgba(20, 184, 166, 0.2);
  color: var(--text-primary);
  align-self: flex-end;
  border-bottom-right-radius: 6px;
  border: 1px solid rgba(20, 184, 166, 0.15);
}

.sandbox-bubble.bot {
  background: rgba(30, 41, 59, 0.9);
  color: var(--text-primary);
  align-self: flex-start;
  border-bottom-left-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.sandbox-bubble-time {
  font-size: 0.65rem;
  color: var(--text-faint);
  margin-top: 0.25rem;
  display: block;
}

.sandbox-bubble.user .sandbox-bubble-time {
  text-align: right;
}

/* ── Typing indicator ── */
.typing-indicator {
  align-self: flex-start;
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  padding: 0.65rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.sandbox-typing {
  align-self: flex-start;
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  padding: 0.65rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.6;
  animation: bounce 1.2s ease-in-out infinite;
}

.sandbox-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.6;
  animation: bounce 1.2s ease-in-out infinite;
}

.sandbox-typing span:nth-child(2) {
  animation-delay: 0.2s;
}
.sandbox-typing span:nth-child(3) {
  animation-delay: 0.4s;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}
.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

/* ── Input row ── */
.sandbox-input-row {
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid rgba(20, 184, 166, 0.15);
  flex-shrink: 0;
  align-items: flex-end;
}

.sandbox-input {
  flex: 1;
  background: rgba(8, 12, 20, 0.8);
  border: 1px solid rgba(20, 184, 166, 0.25);
  border-radius: 12px;
  padding: 0.6rem 0.9rem;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.875rem;
  outline: none;
  resize: none;
  max-height: 100px;
  transition:
    border-color var(--t-fast),
    box-shadow var(--t-fast);
}

.sandbox-input::placeholder {
  color: var(--text-faint);
}

.sandbox-input:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow-input);
}

.sandbox-send {
  background: var(--grad-accent);
  border: none;
  border-radius: 10px;
  padding: 0.6rem 1rem;
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition:
    box-shadow var(--t-fast),
    filter var(--t-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  height: 2.4rem;
}

.sandbox-send:hover {
  box-shadow: var(--shadow-glow);
  filter: brightness(1.08);
}

.sandbox-send:active {
  transform: scale(0.97);
}

/* ── Sandbox controls ── */
.sandbox-controls {
  flex: 1;
  min-width: 280px;
}

/* ============================================================
   USER PROFILE SECTION (sidebar footer)
   ============================================================ */

.user-profile {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--t-fast);
  border: 1px solid transparent;
}

.user-profile:hover {
  background: var(--bg-hover);
  border-color: rgba(20, 184, 166, 0.1);
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   STAT SPARKLINE PLACEHOLDER
   ============================================================ */

.sparkline {
  height: 40px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
}

.sparkline-bar {
  flex: 1;
  border-radius: 2px 2px 0 0;
  background: var(--accent-soft);
  transition: height 0.4s ease;
}

.sparkline-bar.highlight {
  background: var(--grad-accent);
}

/* ============================================================
   GRID UTILITIES
   ============================================================ */

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.flex {
  display: flex;
}
.flex-col {
  display: flex;
  flex-direction: column;
}
.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}
.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.flex-end {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
.flex-wrap {
  flex-wrap: wrap;
}
.items-center {
  align-items: center;
}
.items-start {
  align-items: flex-start;
}
.gap-xs {
  gap: 0.35rem;
}
.gap-sm {
  gap: 0.6rem;
}
.gap-md {
  gap: 1rem;
}
.gap-lg {
  gap: 1.5rem;
}
.gap-xl {
  gap: 2rem;
}

/* ============================================================
   SPACING UTILITIES
   ============================================================ */

.mt-xs {
  margin-top: 0.35rem;
}
.mt-sm {
  margin-top: 0.6rem;
}
.mt-md {
  margin-top: 1rem;
}
.mt-lg {
  margin-top: 1.5rem;
}

.mb-xs {
  margin-bottom: 0.35rem;
}
.mb-sm {
  margin-bottom: 0.6rem;
}
.mb-md {
  margin-bottom: 1rem;
}
.mb-lg {
  margin-bottom: 1.5rem;
}

.p-sm {
  padding: 0.6rem;
}
.p-md {
  padding: 1rem;
}
.p-lg {
  padding: 1.5rem;
}

/* ============================================================
   TEXT UTILITIES
   ============================================================ */

.text-xs {
  font-size: 0.72rem;
}
.text-sm {
  font-size: 0.82rem;
}
.text-base {
  font-size: 0.9rem;
}
.text-lg {
  font-size: 1.05rem;
}
.text-xl {
  font-size: 1.25rem;
}

.font-medium {
  font-weight: 500;
}
.font-semi {
  font-weight: 600;
}
.font-bold {
  font-weight: 700;
}
.font-black {
  font-weight: 800;
}

.text-primary {
  color: var(--text-primary);
}
.text-muted {
  color: var(--text-muted);
}
.text-faint {
  color: var(--text-faint);
}
.text-accent {
  color: var(--accent-light);
}
.text-success {
  color: var(--success);
}
.text-danger {
  color: var(--danger);
}
.text-warning {
  color: var(--warning);
}

.text-truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.text-gradient {
  background: var(--grad-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.text-center {
  text-align: center;
}
.text-right {
  text-align: right;
}

/* ============================================================
   MISC UTILITIES
   ============================================================ */

.rounded-sm {
  border-radius: var(--radius-sm);
}
.rounded-md {
  border-radius: var(--radius-input);
}
.rounded-lg {
  border-radius: var(--radius-card);
}
.rounded-pill {
  border-radius: var(--radius-pill);
}

.overflow-hidden {
  overflow: hidden;
}
.overflow-auto {
  overflow: auto;
}
.relative {
  position: relative;
}
.absolute {
  position: absolute;
}
.w-full {
  width: 100%;
}
.h-full {
  height: 100%;
}
.min-w-0 {
  min-width: 0;
}
.flex-1 {
  flex: 1;
}
.flex-shrink-0 {
  flex-shrink: 0;
}
.cursor-pointer {
  cursor: pointer;
}
.select-none {
  user-select: none;
}
.opacity-50 {
  opacity: 0.5;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Glow text ── */
.glow-text {
  text-shadow: 0 0 20px rgba(20, 184, 166, 0.4);
}

/* ── Separator ── */
.separator {
  height: 1px;
  background: rgba(20, 184, 166, 0.08);
  margin: 0.75rem 0;
}

/* ── Section header ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: 1rem;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

/* ── Stat row ── */
.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0;
  border-bottom: var(--border-subtle);
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-key {
  font-size: 0.82rem;
  color: var(--text-muted);
}
.stat-val {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ── Code / mono ── */
.mono {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.85em;
  color: var(--accent-light);
  background: var(--accent-soft);
  padding: 0.1em 0.4em;
  border-radius: 4px;
}

/* ============================================================
   ANIMATIONS & KEYFRAMES
   ============================================================ */

/* ── Rise in ── */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Fade in ── */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ── Pulse (status dot) ── */
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.5);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(52, 211, 153, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(52, 211, 153, 0);
  }
}

/* ── Bounce (typing dots) ── */
@keyframes bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.6;
  }
  30% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

/* ── Shimmer (skeleton) ── */
@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* ── Spin ── */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Glow pulse (accent) ── */
@keyframes glowPulse {
  0%,
  100% {
    box-shadow: 0 0 20px rgba(20, 184, 166, 0.15);
  }
  50% {
    box-shadow: 0 0 40px rgba(20, 184, 166, 0.35);
  }
}

/* ── Slide in right (drawer) ── */
@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ── Slide in up ── */
@keyframes slideInUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ── Stagger delays ── */
.anim-delay-1 {
  animation-delay: 0.05s;
}
.anim-delay-2 {
  animation-delay: 0.1s;
}
.anim-delay-3 {
  animation-delay: 0.15s;
}
.anim-delay-4 {
  animation-delay: 0.2s;
}
.anim-delay-5 {
  animation-delay: 0.25s;
}

/* Apply rise animation to metrics with stagger */
.metrics .metric:nth-child(1) {
  animation-delay: 0.05s;
}
.metrics .metric:nth-child(2) {
  animation-delay: 0.1s;
}
.metrics .metric:nth-child(3) {
  animation-delay: 0.15s;
}
.metrics .metric:nth-child(4) {
  animation-delay: 0.2s;
}

/* ============================================================
   DRAWER / SLIDE-OVER PANEL
   ============================================================ */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 20, 0.6);
  backdrop-filter: blur(4px);
  z-index: 8000;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 480px;
  max-width: 95vw;
  background: var(--bg-panel);
  border-left: var(--border-panel);
  box-shadow:
    var(--shadow-panel),
    -20px 0 60px rgba(0, 0, 0, 0.4);
  z-index: 8100;
  display: flex;
  flex-direction: column;
  animation: slideInRight 0.3s ease;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem;
  border-bottom: var(--border-panel-alt);
  flex-shrink: 0;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.drawer-footer {
  padding: 1rem 1.5rem;
  border-top: var(--border-panel-alt);
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  flex-shrink: 0;
}

/* ============================================================
   RESPONSIVE — TABLET & MOBILE
   ============================================================ */

@media (max-width: 1200px) {
  .metrics {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 1000px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: var(--border-panel);
    border-radius: var(--radius-card);
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0.5rem;
  }

  .nav-section {
    flex-direction: row;
    flex-wrap: wrap;
    margin-bottom: 0;
  }

  .nav-section-label {
    display: none;
  }

  .nav-link {
    padding: 0.5rem 0.75rem;
  }
}

@media (max-width: 768px) {
  .metrics {
    grid-template-columns: 1fr;
  }

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .card {
    padding: 1.1rem;
  }

  .sandbox-frame {
    width: 100%;
    max-width: 360px;
    height: 560px;
  }

  .drawer {
    width: 100%;
    max-width: 100%;
  }

  .modal {
    margin: 0;
    max-height: 95vh;
    border-radius: var(--radius-card) var(--radius-card) 0 0;
    animation: slideInUp 0.3s ease;
  }

  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }
}

@media (max-width: 480px) {
  :root {
    --radius-card: 12px;
  }

  body {
    font-size: 15px;
  }

  .login-card {
    padding: 1.75rem 1.25rem;
  }

  .brand {
    font-size: 1.4rem;
  }

  .metric-value {
    font-size: 1.8rem;
  }

  .nav-tabs {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
  }
}

/* ============================================================
   ADMIN-PLANE DESIGN SYSTEM HARMONIZATION
   Keep Tenant Business Centre layout, normalize shared primitives.
   ============================================================ */

body {
  background:
    radial-gradient(
      ellipse at 20% 0%,
      var(--accent-soft) 0%,
      transparent 50%
    ),
    radial-gradient(
      ellipse at 80% 100%,
      var(--accent-soft) 0%,
      transparent 50%
    ),
    var(--bg-base);
}

.app-shell::before,
.login-screen::before {
  background:
    radial-gradient(
      ellipse 80% 50% at 10% 20%,
      var(--accent-soft) 0%,
      transparent 60%
    ),
    radial-gradient(
      ellipse 60% 40% at 90% 80%,
      transparent 0%,
      transparent 60%
    );
}

.panel,
.card,
.metric,
.sidebar,
.hero,
.nav-tabs,
.login-panel,
.login-card,
.sandbox-frame,
.copilot-messages,
.copilot-side {
  border-color: var(--border-panel);
  box-shadow: var(--shadow-card);
}

.panel:hover,
.card:hover,
.metric:hover {
  box-shadow: var(--shadow-panel), var(--shadow-glow-soft);
}

.brand,
.login-brand,
.text-gradient {
  background: var(--grad-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.eyebrow,
.text-accent,
a,
.nav-link.active,
.tab-button.active,
.funnel-stage strong,
.metric-value,
.detail-stat strong,
.mono,
code {
  color: var(--accent-light);
}

a:hover {
  color: var(--accent);
}

.nav-link:hover,
.tab-button:hover,
.tenant-item:hover,
.tenant-item.active,
.stack-item:hover,
.user-profile:hover {
  background: var(--accent-soft);
}

.nav-link.active,
.tab-button.active {
  background: color-mix(in srgb, var(--accent) 24%, transparent);
  border-color: color-mix(in srgb, var(--accent) 38%, transparent);
}

input[type='text'],
input[type='email'],
input[type='password'],
input[type='search'],
input[type='url'],
input[type='tel'],
input[type='number'],
input[type='date'],
select,
textarea,
.copilot-input,
.sandbox-input {
  border-color: var(--border-input);
}

input:focus,
select:focus,
textarea:focus,
.copilot-input:focus,
.sandbox-input:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow-input);
}

.btn-primary,
.primary-button,
button:not(.ghost-button):not(.tab-button):not(.nav-link):not(.close-modal),
.copilot-send,
.sandbox-send {
  background: var(--grad-accent);
  color: #fff;
}

.ghost-button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.chip {
  background: var(--border-panel-alt);
}

.copilot-bubble.user,
.sandbox-bubble.user {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 28%, transparent);
}

.sandbox-frame {
  border-color: color-mix(in srgb, var(--accent) 32%, transparent);
  box-shadow:
    0 0 60px var(--accent-soft),
    0 0 0 1px var(--accent-soft),
    0 24px 60px rgba(0, 0, 0, 0.6);
}

.sandbox-frame::before {
  background: color-mix(in srgb, var(--accent) 24%, transparent);
}

.sandbox-header,
.sandbox-input-row {
  border-color: var(--border-panel);
}

.glow-text {
  text-shadow: 0 0 20px var(--accent-glow);
}

.upload-zone {
  border: 2px dashed color-mix(in srgb, var(--accent) 32%, transparent);
  border-radius: var(--radius-card);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--t-fast);
  background: var(--bg-surface);
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--bg-panel-solid);
  border: var(--border-panel);
  border-radius: var(--radius-sm);
  margin-top: 0.5rem;
}

.file-info {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.file-name {
  font-size: 0.88rem;
  font-weight: 600;
}

.file-size {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ============================================================
   PRINT
   ============================================================ */

@media print {
  .sidebar,
  .toast-container,
  .modal-backdrop,
  .drawer-backdrop,
  .btn {
    display: none !important;
  }

  .app-shell {
    grid-template-columns: 1fr;
    padding: 0;
  }

  .card {
    box-shadow: none;
    border: 1px solid #ccc;
  }

  body {
    background: #fff;
    color: #000;
  }
}

/* ============================================================
   CHATS / PIPELINE STYLES
   ============================================================ */
.chats-controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}
.chats-controls select {
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.view-toggle {
  padding: 0.4rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-size: 0.85rem;
}
.chats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.chats-table th, .chats-table td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.chats-table th {
  font-weight: 600;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
}
.stage-badge {
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: capitalize;
}
.stage-new_reply { background: #e3f2fd; color: #1565c0; }
.stage-engaged { background: #fff3e0; color: #e65100; }
.stage-proposal { background: var(--accent-soft); color: var(--color-primary); }
.stage-negotiating { background: #fff8e1; color: #f57f17; }
.stage-closed { background: #e8f5e9; color: #2e7d32; }

.chats-kanban {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding: 1rem 0;
}
.kanban-column {
  min-width: 200px;
  flex: 1;
  background: var(--surface);
  border-radius: 8px;
  padding: 0.75rem;
  border: 1px solid var(--border);
}
.kanban-column h4 {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  color: var(--muted);
}
.kanban-cards {
  min-height: 60px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.kanban-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem;
  cursor: grab;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.kanban-card.dragging {
  opacity: 0.5;
}
.kanban-cards.drag-over {
  background: var(--accent-soft);
  border: 2px dashed var(--primary);
  border-radius: 6px;
}

/* Unified Inbox */
.inbox-container {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 1rem;
  min-height: 400px;
}
.inbox-list {
  border-right: 1px solid var(--border);
  overflow-y: auto;
  max-height: 500px;
}
.inbox-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.inbox-item:hover { background: var(--surface); }
.inbox-item.active { background: var(--accent-soft); }
.inbox-channel { font-size: 1.2rem; }
.inbox-item-content { flex: 1; min-width: 0; }
.inbox-item-content p { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox-detail {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.inbox-messages {
  flex: 1;
  overflow-y: auto;
  max-height: 400px;
  padding: 0.75rem;
}
.inbox-reply-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem;
  border-top: 1px solid var(--border);
}
.inbox-reply-form input { flex: 1; }

/* Approvals */
.approvals-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.intent-tag {
  font-size: 0.75rem;
  color: var(--muted);
}
.ai-toggle-btn {
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 0.75rem;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
}
.ai-toggle-btn.active {
  background: #fff3e0;
  color: #e65100;
  border-color: #ffcc80;
}
.ai-toggle-btn.paused {
  background: #e8f5e9;
  color: #2e7d32;
  border-color: #a5d6a7;
}
.badge {
  display: none;
  background: #ef5350;
  color: #fff;
  font-size: 0.65rem;
  padding: 0.15rem 0.45rem;
  border-radius: 10px;
  margin-left: 0.3rem;
  font-weight: 700;
  vertical-align: super;
}
.assistant-suggestions {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.suggestion-btn {
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 0.82rem;
  transition: background 0.15s;
}
.suggestion-btn:hover {
  background: var(--bg);
}

/* ============================================================
   EPIC 53 — TENANT DASHBOARD REDESIGN
   Scoped under .kw- prefix for zero collision
   All colors from design-system.css tokens
   ============================================================ */

/* Epic 65.9 — light-mode contrast for the legacy accent palette.
   The dark-tuned accent-light (#a78bfa) measures 2.7:1 on light
   backgrounds — unreadable for active nav links and badges. The deep
   variant (#6d28d9) measures 7.1:1. Redefining the tokens under the
   light theme fixes every consumer at once (nav-link.active,
   tab-button.active, badges, inline links). */
html[data-theme="light"] body {
  --accent-light: var(--color-primary);
  --text-accent: var(--color-primary);
}

/* ── Navigation ── */
.kw-nav {
  position: fixed; top: 0; left: 0; width: 100%; z-index: 50;
  background: var(--color-surface-container);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-outline-variant);
  padding: 0 var(--space-4);
  height: 64px;
  display: flex; justify-content: space-between; align-items: center;
  box-sizing: border-box;
}
.kw-nav__left { display: flex; align-items: center; gap: var(--space-4); }
.kw-nav__right { display: flex; align-items: center; gap: var(--space-3); }
.kw-brand {
  font-size: var(--text-xl); font-weight: 800; color: var(--color-primary);
  text-decoration: none; letter-spacing: -0.5px;
}
.kw-nav__links { display: flex; align-items: center; gap: var(--space-1); }
.kw-nav__link {
  padding: var(--space-1) var(--space-3); border-radius: var(--radius-md);
  font-size: var(--text-sm); font-weight: 600; color: var(--color-on-surface-variant);
  text-decoration: none; transition: all var(--t-fast); white-space: nowrap;
}
.kw-nav__link:hover { background: var(--color-surface-variant); color: var(--color-on-surface); }
.kw-nav__link--active { background: var(--color-primary-container); color: var(--color-on-primary-container); }
.kw-hamburger {
  display: none; background: none; border: none; cursor: pointer;
  padding: var(--space-2); border-radius: var(--radius-sm); color: var(--color-on-surface-variant);
  min-width: 44px; min-height: 44px;
}
.kw-hamburger:hover { background: var(--color-surface-variant); }
.kw-tenant-name {
  font-size: var(--text-xs); font-weight: 700; color: var(--color-secondary);
  display: none;
}
.kw-icon-btn {
  background: none; border: none; cursor: pointer; padding: var(--space-2);
  border-radius: var(--radius-sm); color: var(--color-on-surface-variant);
  min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center;
}
.kw-icon-btn:hover { background: var(--color-surface-variant); color: var(--color-on-surface); }
.kw-credit-bar {
  display: flex; align-items: center; gap: var(--space-2);
  background: var(--color-surface-container-low); border-radius: var(--radius-md);
  padding: var(--space-1) var(--space-2); border: 1px solid var(--color-outline-variant);
  font-size: var(--text-xs);
}
.kw-credit-bar__label { color: var(--color-on-surface-variant); font-size: var(--text-xs); }
.kw-credit-bar__track { width: 48px; height: 6px; border-radius: var(--radius-full); background: var(--color-surface-container-highest); overflow: hidden; }
.kw-credit-bar__fill { height: 100%; background: var(--color-primary); border-radius: var(--radius-full); transition: width var(--t-slow); }
.kw-credit-bar__value { color: var(--color-primary); font-weight: 700; }

/* ── Portal Layout ── */
.kw-portal-layout {
  display: flex; margin-top: 64px; min-height: calc(100vh - 64px);
  visibility: hidden;
}
.kw-portal-main {
  flex: 1; padding: var(--space-6); max-width: 1280px; margin: 0 auto; width: 100%;
  box-sizing: border-box;
}

/* ── Sidebar (mobile slide-out) ── */
.kw-sidebar {
  position: fixed; top: 64px; left: 0; width: 280px; height: calc(100vh - 64px);
  background: var(--color-surface-container); border-right: 1px solid var(--color-outline-variant);
  z-index: 45; transform: translateX(-100%); transition: transform var(--t-base);
  overflow-y: auto; padding: var(--space-4); box-sizing: border-box;
}
.kw-sidebar--open { transform: translateX(0); }
.kw-sidebar-overlay {
  position: fixed; inset: 0; top: 64px; background: rgba(0,0,0,0.4); z-index: 44;
  opacity: 0; pointer-events: none; transition: opacity var(--t-base);
}
.kw-sidebar-overlay--visible { opacity: 1; pointer-events: auto; }
.kw-sidebar__links { display: flex; flex-direction: column; gap: var(--space-1); margin-bottom: var(--space-6); }
.kw-sidebar__link {
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-md);
  font-size: var(--text-sm); font-weight: 500; color: var(--color-on-surface-variant);
  text-decoration: none; transition: background var(--t-fast); min-height: 44px;
  display: flex; align-items: center;
}
.kw-sidebar__link:hover { background: var(--color-surface-variant); }
.kw-sidebar__link--active { background: var(--color-primary-container); color: var(--color-on-primary-container); font-weight: 600; }
.kw-sidebar__section-title {
  font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--color-primary); font-weight: 700; padding: var(--space-2) var(--space-4);
}
.kw-sidebar__verticals { display: flex; flex-direction: column; gap: var(--space-1); }

/* ── Pages ── */
.kw-page { animation: riseIn var(--t-base) forwards; }
.kw-page__title {
  font-size: var(--text-2xl); font-weight: 700; margin: 0 0 var(--space-5); color: var(--color-on-background);
}

/* ── Narrative Summary ── */
.kw-narrative {
  display: flex; align-items: flex-start; gap: var(--space-3);
  background: linear-gradient(135deg, var(--color-primary-container), var(--color-surface-container-high));
  border: 1px solid var(--color-primary); border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5); margin-bottom: var(--space-5);
}
.kw-narrative__icon { color: var(--color-primary); font-size: var(--text-lg); margin-top: 2px; }
.kw-narrative__text { font-size: var(--text-sm); color: var(--color-on-primary-container); line-height: 1.6; margin: 0; }

/* ── Welcome ── */
.kw-welcome { margin-bottom: var(--space-4); }
.kw-welcome__heading { font-size: var(--text-xl); font-weight: 700; margin: 0; color: var(--color-on-background); }
.kw-welcome__sub { font-size: var(--text-xs); color: var(--color-on-surface-variant); margin: var(--space-1) 0 0; }

/* ── Quick Actions ── */
.kw-quick-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--space-3); margin-bottom: var(--space-5); }
.kw-quick-action {
  display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3);
  background: var(--color-surface-container); border: 1px solid var(--color-outline-variant);
  border-radius: var(--radius-md); cursor: pointer; font-size: var(--text-sm);
  font-weight: 500; color: var(--color-on-surface); text-decoration: none;
  transition: all var(--t-fast); min-height: 44px; font-family: inherit;
}
.kw-quick-action:hover { border-color: var(--color-primary); background: var(--color-surface-container-high); transform: translateY(-1px); }
.kw-quick-action .material-symbols-outlined { font-size: var(--text-lg); }

/* ── Dashboard Rows ── */
.kw-dashboard { margin-bottom: var(--space-5); }
.kw-dashboard__row--stat-strip {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--space-3);
}

/* ── StatCard (portal variant — complements framework) ── */
.kw-statcard {
  background: var(--color-surface-container-high); border: 1px solid var(--color-outline-variant);
  border-radius: var(--radius-lg); padding: var(--space-4); transition: all var(--t-fast);
  cursor: pointer; position: relative; overflow: hidden;
}
.kw-statcard:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--color-primary); }
.kw-statcard--alert { border-color: var(--color-error); }
.kw-statcard--alert:hover { border-color: var(--color-error); }
.kw-statcard__icon {
  font-size: var(--text-sm); width: 40px; height: 40px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center; margin-bottom: var(--space-3);
}
.kw-statcard__icon .material-symbols-outlined { font-size: 18px; }
.kw-statcard__label {
  font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--color-on-surface-variant); margin: 0 0 var(--space-1); font-weight: 500;
}
.kw-statcard__value {
  font-size: var(--text-2xl); font-weight: 700; color: var(--color-on-surface); margin: 0;
}
.kw-statcard__sub {
  font-size: var(--text-xs); color: var(--color-on-surface-variant); margin: var(--space-1) 0 0;
}

/* ── Activity Row ── */
.kw-activity-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.kw-card {
  background: var(--color-surface-container); border: 1px solid var(--color-outline-variant);
  border-radius: var(--radius-lg); padding: var(--space-4);
}
.kw-card__heading {
  font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--color-primary); font-weight: 700; margin: 0 0 var(--space-3);
}
.kw-channels-card { }
.kw-activity-card { display: flex; flex-direction: column; max-height: 300px; overflow-y: auto; }

/* ── Channel Pills ── */
.kw-channels-strip { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.kw-channel-pill {
  display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3);
  background: var(--color-surface-container-low); border: 1px solid var(--color-outline-variant);
  border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: 600;
  cursor: pointer; transition: all var(--t-fast); color: var(--color-on-surface);
}
.kw-channel-pill:hover { border-color: var(--color-primary); }
.kw-channel-pill__dot { width: 7px; height: 7px; border-radius: 50%; }
.kw-channel-pill__dot--on { background: var(--state-online, var(--color-success)); box-shadow: 0 0 6px color-mix(in srgb, var(--state-online, var(--color-success)) 50%, transparent); }
.kw-channel-pill__dot--off { background: var(--state-offline); }

/* ── Copilot Presence (Epic 62.1) ── */
.kw-copilot-presence { width:10px;height:10px;border-radius:50%;display:inline-block;background:var(--state-idle); }
.kw-copilot-presence[data-presence-state='listening']{background:var(--state-busy);}
.kw-copilot-presence[data-presence-state='executing']{background:var(--state-online);}
.kw-copilot-presence[data-presence-state='complete']{background:var(--state-offline);}

/* ── Activity Feed ── */
.kw-activity-feed { display: flex; flex-direction: column; gap: var(--space-1); flex: 1; overflow-y: auto; }
.kw-activity-item {
  display: flex; gap: var(--space-3); padding: var(--space-2); border-radius: var(--radius-md);
  transition: background var(--t-fast);
}
.kw-activity-item:hover { background: var(--color-surface-container-high); }
.kw-activity-item__icon { color: var(--color-primary); font-size: var(--text-sm); margin-top: 2px; }
.kw-activity-item__text { font-size: var(--text-xs); color: var(--color-on-surface); margin: 0; }
.kw-activity-item__time { font-size: var(--text-xs); color: var(--color-on-surface-variant); }

/* ── Data Rows (insights) ── */
.kw-data-row {
  display: flex; justify-content: space-between; padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-outline-variant); font-size: var(--text-xs);
  color: var(--color-on-surface);
}
.kw-data-row:last-child { border-bottom: none; }
.kw-data-row__value { font-weight: 700; }

/* ── Empty State ── */
.kw-empty-text { font-size: var(--text-sm); color: var(--color-on-surface-variant); text-align: center; padding: var(--space-4); }

/* ── Copilot Sidebar ── */
.kw-copilot-sidebar {
  position: fixed; top: 64px; right: 0; width: 360px; height: calc(100vh - 64px);
  background: var(--color-surface-container-low); border-left: 1px solid var(--color-outline-variant);
  z-index: 40; transform: translateX(100%); transition: transform var(--t-base);
  display: flex; flex-direction: column;
}
.kw-copilot-sidebar--open { transform: translateX(0); }
.kw-copilot-sidebar__header {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--space-4); border-bottom: 1px solid var(--color-outline-variant);
}
.kw-copilot-sidebar__title {
  font-size: var(--text-sm); font-weight: 700; margin: 0; display: flex; align-items: center; gap: var(--space-2);
  color: var(--color-on-surface);
}
.kw-copilot-sidebar__actions { display: flex; gap: var(--space-1); }
.kw-copilot-sidebar__messages {
  flex: 1; overflow-y: auto; padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3);
}
.kw-copilot-sidebar__input { padding: var(--space-3); border-top: 1px solid var(--color-outline-variant); }
.kw-copilot-input-row { display: flex; gap: var(--space-2); }
.kw-copilot-input {
  flex: 1; background: var(--color-surface-container-highest); border: 1px solid var(--color-outline-variant);
  border-radius: var(--radius-md); padding: var(--space-2) var(--space-3); font-size: var(--text-sm);
  color: var(--color-on-surface); font-family: inherit; outline: none; min-height: 44px;
}
.kw-copilot-input:focus { border-color: var(--color-primary); }
.kw-copilot-send {
  background: var(--color-primary); color: var(--color-on-primary); border: none;
  border-radius: var(--radius-md); padding: var(--space-2) var(--space-3); cursor: pointer;
  min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center;
}
.kw-copilot-send:hover { filter: brightness(1.1); }

/* ── Copilot FAB ── */
.kw-copilot-fab {
  position: fixed; bottom: var(--space-6); right: var(--space-6); z-index: 39;
  width: 56px; height: 56px; border-radius: 50%; background: var(--color-primary);
  color: var(--color-on-primary); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-lg); transition: all var(--t-fast);
}
.kw-copilot-fab:hover { transform: scale(1.08); box-shadow: var(--shadow-xl); }
.kw-copilot-fab--hidden { opacity: 0; pointer-events: none; transform: scale(0.8); }

/* ── Chat Messages ── */
.kw-msg-bot {
  background: var(--color-primary-container); color: var(--color-on-primary-container);
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-md) var(--radius-md) var(--radius-md) var(--radius-xs);
  max-width: 90%; align-self: flex-start; font-size: var(--text-sm); line-height: 1.5;
}
.kw-msg-bot--error { background: var(--color-error-container); color: var(--color-on-error-container); }
.kw-msg-user {
  background: var(--color-secondary-container); color: var(--color-on-secondary-container);
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-md) var(--radius-md) var(--radius-xs) var(--radius-md);
  max-width: 90%; align-self: flex-end; font-size: var(--text-sm); line-height: 1.5; margin-left: auto;
}

/* ── Inbox Placeholder ── */
.kw-inbox-placeholder {
  text-align: center; padding: var(--space-8) var(--space-4);
}
.kw-inbox-placeholder__icon {
  font-size: 48px; color: var(--color-on-surface-variant); margin-bottom: var(--space-3);
}

/* ── Inbox (53.2-53.4) ── */
.kw-inbox { display: flex; height: calc(100vh - 140px); gap: 0; border-radius: var(--radius-lg); overflow: hidden; background: var(--color-surface-container); border: 1px solid var(--color-outline-variant); }

/* Left Pane */
.kw-inbox__left {
  width: 320px; min-width: 280px; border-right: 1px solid var(--color-outline-variant);
  display: flex; flex-direction: column; background: var(--color-surface-container-low);
}
.kw-inbox__search-bar { display: flex; align-items: center; padding: var(--space-3); border-bottom: 1px solid var(--color-outline-variant); gap: var(--space-2); }
.kw-inbox__search-icon { color: var(--color-on-surface-variant); font-size: 18px; }
.kw-inbox__search {
  flex: 1; background: transparent; border: none; outline: none; font-size: var(--text-sm);
  color: var(--color-on-surface); font-family: inherit;
}
.kw-inbox__search::placeholder { color: var(--color-on-surface-variant); }
.kw-inbox__filters { display: flex; gap: var(--space-1); padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--color-outline-variant); flex-wrap: wrap; }
.kw-inbox__filter {
  padding: var(--space-1) var(--space-3); border-radius: var(--radius-full); border: 1px solid var(--color-outline-variant);
  background: transparent; color: var(--color-on-surface-variant); font-size: var(--text-xs); cursor: pointer;
  font-family: inherit; min-height: 32px; white-space: nowrap;
}
.kw-inbox__filter:hover { border-color: var(--color-primary); }
.kw-inbox__filter--active { background: var(--color-primary-container); color: var(--color-on-primary-container); border-color: var(--color-primary); }
.kw-inbox__list { flex: 1; overflow-y: auto; }
.kw-inbox__empty { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: var(--space-8) var(--space-4); color: var(--color-on-surface-variant); text-align: center; height: 100%; }
.kw-inbox__empty .material-symbols-outlined { font-size: 40px; margin-bottom: var(--space-3); }
.kw-inbox__conv {
  padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-outline-variant);
  cursor: pointer; transition: background var(--t-fast); min-height: 48px;
}
.kw-inbox__conv:hover { background: var(--color-surface-container-high); }
.kw-inbox__conv--active { background: var(--color-primary-container); border-left: 3px solid var(--color-primary); }
.kw-inbox__conv-header { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-1); }
.kw-inbox__conv-name { font-size: var(--text-sm); font-weight: 600; color: var(--color-on-surface); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kw-inbox__unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-primary); flex-shrink: 0; }
.kw-inbox__conv-time { font-size: var(--text-xs); color: var(--color-on-surface-variant); flex-shrink: 0; }
.kw-inbox__conv-preview { font-size: var(--text-xs); color: var(--color-on-surface-variant); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: var(--space-1); }
.kw-inbox__conv-meta { display: flex; align-items: center; gap: var(--space-2); }
.kw-inbox__tag { font-size: 10px; padding: 2px 8px; border-radius: var(--radius-full); font-weight: 600; }
.kw-inbox__tag--needs-you { background: var(--color-warning-container); color: var(--color-on-warning-container); }
.kw-inbox__tag--handling { background: var(--color-surface-container-highest); color: var(--color-on-surface-variant); }
.kw-inbox__tag--resolved { opacity: 0.5; background: var(--color-surface-container-highest); color: var(--color-on-surface-variant); }
.kw-inbox__channel-badge { font-size: 10px; color: var(--color-on-surface-variant); }

/* Center Pane */
.kw-inbox__center {
  flex: 1; display: flex; flex-direction: column; min-width: 0;
  background: var(--color-surface-container);
}
.kw-inbox__center-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  flex: 1; color: var(--color-on-surface-variant); text-align: center;
}
.kw-inbox__center-empty .material-symbols-outlined { font-size: 48px; margin-bottom: var(--space-3); }
.kw-inbox__center-active { display: flex; flex-direction: column; flex: 1; }
.kw-inbox__thread-header {
  display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-outline-variant); min-height: 56px;
  background: var(--color-surface-container-low);
}
.kw-inbox__back {
  display: none; background: none; border: none; cursor: pointer; padding: var(--space-2);
  border-radius: var(--radius-sm); color: var(--color-on-surface-variant); min-width: 44px; min-height: 44px;
}
.kw-inbox__thread-info { flex: 1; min-width: 0; }
.kw-inbox__thread-name { font-size: var(--text-sm); font-weight: 600; margin: 0; color: var(--color-on-surface); }
.kw-inbox__thread-channel { font-size: var(--text-xs); color: var(--color-on-surface-variant); }
.kw-inbox__thread-messages { flex: 1; overflow-y: auto; padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); }
.kw-inbox__load-more { text-align: center; padding: var(--space-2); }
.kw-inbox__load-more-btn {
  background: var(--color-surface-container-high); border: 1px solid var(--color-outline-variant);
  border-radius: var(--radius-md); padding: var(--space-1) var(--space-3); font-size: var(--text-xs);
  color: var(--color-on-surface-variant); cursor: pointer; font-family: inherit;
}
.kw-inbox__bubble { max-width: 80%; padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); font-size: var(--text-sm); }
.kw-inbox__bubble--incoming { align-self: flex-start; background: var(--color-surface-container-highest); border-radius: var(--radius-md) var(--radius-md) var(--radius-md) var(--radius-xs); }
.kw-inbox__bubble--outgoing { align-self: flex-end; background: var(--color-primary-container); border-radius: var(--radius-md) var(--radius-md) var(--radius-xs) var(--radius-md); }
.kw-inbox__bubble-label { font-size: 10px; font-weight: 600; color: var(--color-primary); display: block; margin-bottom: var(--space-1); }
.kw-inbox__bubble-text { margin: 0; line-height: 1.5; color: var(--color-on-surface); }
.kw-inbox__bubble-time { font-size: 10px; color: var(--color-on-surface-variant); display: block; margin-top: var(--space-1); }
.kw-inbox__reply-bar {
  display: flex; gap: var(--space-2); padding: var(--space-3); border-top: 1px solid var(--color-outline-variant);
  background: var(--color-surface-container-low);
}
.kw-inbox__reply-input {
  flex: 1; background: var(--color-surface-container-highest); border: 1px solid var(--color-outline-variant);
  border-radius: var(--radius-md); padding: var(--space-2) var(--space-3); font-size: var(--text-sm);
  color: var(--color-on-surface); font-family: inherit; outline: none; min-height: 44px;
}
.kw-inbox__reply-input:focus { border-color: var(--color-primary); }

/* Draft */
.kw-inbox__draft { padding: var(--space-3); border-top: 1px dashed var(--color-warning); background: var(--color-warning-container); }
.kw-inbox__draft-bubble { max-width: 90%; }
.kw-inbox__draft-label { font-size: 10px; color: var(--color-on-warning-container); font-weight: 600; margin: 0 0 var(--space-1); }
.kw-inbox__draft-text { font-size: var(--text-sm); color: var(--color-on-surface); background: var(--color-surface-container); padding: var(--space-2); border-radius: var(--radius-sm); margin: 0 0 var(--space-2); }
.kw-inbox__draft-actions { display: flex; gap: var(--space-2); }

/* Right Pane (Context) */
.kw-inbox__right {
  width: 280px; min-width: 240px; border-left: 1px solid var(--color-outline-variant);
  background: var(--color-surface-container-low); overflow-y: auto;
}
.kw-inbox__right-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: var(--space-8) var(--space-4); color: var(--color-on-surface-variant); text-align: center; height: 100%;
}
.kw-inbox__right-empty .material-symbols-outlined { font-size: 40px; margin-bottom: var(--space-3); }
.kw-inbox__right-active { padding: var(--space-4); }
.kw-inbox__context-header { margin-bottom: var(--space-4); }
.kw-inbox__context-name { font-size: var(--text-sm); font-weight: 700; margin: 0; color: var(--color-on-surface); }
.kw-inbox__context-channel { font-size: var(--text-xs); color: var(--color-on-surface-variant); margin: var(--space-1) 0 0; }
.kw-inbox__context-section { margin-bottom: var(--space-4); }
.kw-inbox__context-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--color-primary); font-weight: 700; margin: 0 0 var(--space-2); }
.kw-inbox__context-stat { font-size: var(--text-xs); color: var(--color-on-surface); margin: var(--space-1) 0; }
.kw-inbox__context-tags { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.kw-inbox__context-tag {
  font-size: 10px; padding: 2px 8px; border-radius: var(--radius-full); border: 1px solid var(--color-outline-variant);
  color: var(--color-on-surface-variant); cursor: pointer;
}
.kw-inbox__context-tag:hover { border-color: var(--color-primary); color: var(--color-primary); }
.kw-inbox__context-pause { font-size: var(--text-xs); color: var(--color-on-warning-container); background: var(--color-warning-container); padding: var(--space-2); border-radius: var(--radius-sm); }
.kw-inbox__context-pause button { background: none; border: none; color: var(--color-primary); cursor: pointer; text-decoration: underline; font: inherit; padding: 0; }
.kw-inbox__context-notes {
  width: 100%; background: var(--color-surface-container-highest); border: 1px solid var(--color-outline-variant);
  border-radius: var(--radius-sm); padding: var(--space-2); font-size: var(--text-xs); color: var(--color-on-surface);
  font-family: inherit; resize: vertical; box-sizing: border-box;
}
.kw-inbox__context-notes:focus { border-color: var(--color-primary); outline: none; }
.kw-inbox__context-close {
  display: none; width: 100%; padding: var(--space-2); background: var(--color-surface-container-high);
  border: 1px solid var(--color-outline-variant); border-radius: var(--radius-md); color: var(--color-on-surface-variant);
  font-size: var(--text-xs); cursor: pointer; font-family: inherit; margin-top: var(--space-4);
}

/* Pipeline stages */
.kw-pipeline-stages { display: flex; align-items: center; gap: var(--space-1); font-size: 10px; flex-wrap: wrap; }
.kw-pipeline-stage { padding: 2px 6px; border-radius: var(--radius-full); background: var(--color-surface-container-highest); color: var(--color-on-surface-variant); }
.kw-pipeline-stage--active { background: var(--color-primary-container); color: var(--color-on-primary-container); }
.kw-pipeline-stage--current { background: var(--color-primary); color: var(--color-on-primary); font-weight: 600; }
.kw-pipeline-arrow { color: var(--color-on-surface-variant); font-size: 10px; }

/* Mobile inbox */
@media (max-width: 1023px) {
  .kw-inbox { flex-direction: column; height: calc(100vh - 120px); }
  .kw-inbox__left { width: 100%; min-width: 0; border-right: none; border-bottom: 1px solid var(--color-outline-variant); flex: 1; }
  .kw-inbox__center { display: none; width: 100%; }
  .kw-inbox__right { width: 100%; display: none; position: fixed; top: 64px; right: 0; height: calc(100vh - 64px); z-index: 35; }
  .kw-inbox__right--visible { display: block; }
  .kw-inbox__back { display: flex; }
  .kw-inbox__context-close { display: block; }
  .kw-inbox--thread-open .kw-inbox__left { display: none; }
  .kw-inbox--thread-open .kw-inbox__center { display: flex; }
}

/* ── Loading Dots ── */
.kw-loading-dots { display: inline-flex; gap: 4px; align-items: center; }
.kw-loading-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--color-on-surface-variant); animation: kw-bounce 1.4s infinite ease-in-out both; }
.kw-loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.kw-loading-dots span:nth-child(2) { animation-delay: -0.16s; }

/* ── Keyframes ── */
@keyframes riseIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes kw-bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }

/* ── Responsive: Mobile ── */
@media (max-width: 768px) {
  .kw-nav__links { display: none; }
  .kw-hamburger { display: flex; }
  .kw-tenant-name { display: inline; }
  .kw-credit-bar { display: none; }
  .kw-quick-actions { grid-template-columns: repeat(2, 1fr); }
  .kw-dashboard__row--stat-strip { grid-template-columns: 1fr; }
  .kw-activity-row { grid-template-columns: 1fr; }
  .kw-portal-main { padding: var(--space-4); }
  .kw-copilot-sidebar {
    width: 100%; top: auto; bottom: 0; height: 60vh;
    border-left: none; border-top: 1px solid var(--color-outline-variant);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transform: translateY(100%);
  }
  .kw-copilot-sidebar--open { transform: translateY(0); }
  .kw-copilot-fab { bottom: var(--space-4); right: var(--space-4); }
  .kw-statcard { padding: var(--space-3); }
  .kw-statcard__value { font-size: var(--text-lg); }
}

/* ── Responsive: Tablet ── */
@media (min-width: 769px) and (max-width: 1023px) {
  .kw-dashboard__row--stat-strip { grid-template-columns: repeat(2, 1fr); }
  .kw-quick-actions { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 769px) {
  .kw-tenant-name { display: inline; }
}

/* ── Verticals Grid ── */
.kw-verticals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-4);
}
.kw-vertical-card {
  background: var(--color-surface-container);
  border: 1px solid var(--color-outline-variant);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.kw-vertical-card--active {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 1px var(--color-primary);
}
.kw-vertical-card__header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-3);
}
.kw-vertical-card__icon {
  width: 40px; height: 40px; border-radius: var(--radius-md);
  background: var(--color-primary-container); color: var(--color-primary);
  display: flex; align-items: center; justify-content: center;
}
.kw-vertical-card__title { font-size: var(--text-base); font-weight: 600; margin-bottom: var(--space-1); }
.kw-vertical-card__desc { font-size: var(--text-sm); color: var(--color-on-surface-variant); line-height: 1.5; }

/* ── Toggle Switch ── */
.kw-toggle { position: relative; display: inline-block; width: 44px; height: 24px; }
.kw-toggle input { opacity: 0; width: 0; height: 0; }
.kw-toggle__slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--color-surface-container-highest);
  border-radius: var(--radius-full); transition: background var(--t-fast);
}
.kw-toggle__slider::before {
  content: ''; position: absolute; height: 18px; width: 18px;
  left: 3px; bottom: 3px; background: var(--color-on-surface-variant);
  border-radius: 50%; transition: transform var(--t-fast), background var(--t-fast);
}
.kw-toggle input:checked + .kw-toggle__slider { background: var(--color-primary); }
.kw-toggle input:checked + .kw-toggle__slider::before { transform: translateX(20px); background: var(--color-on-primary); }

/* ── Upload Zone ── */
.kw-upload-zone {
  border: 2px dashed var(--color-outline-variant);
  border-radius: var(--radius-lg); padding: var(--space-6);
  text-align: center; cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.kw-upload-zone:hover, .kw-upload-zone--active {
  border-color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 5%, transparent);
}

/* ── Format Pills ── */
.kw-format-pills { display: flex; gap: var(--space-2); justify-content: center; margin-top: var(--space-2); flex-wrap: wrap; }
.kw-format-pill {
  font-size: var(--text-xs); font-weight: 600; font-family: var(--font-mono, 'JetBrains Mono', monospace);
  padding: 2px 8px; border-radius: var(--radius-full);
  background: var(--color-surface-container-highest); color: var(--color-on-surface-variant);
}

/* ── Tables ── */
.kw-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.kw-table th {
  text-align: left; font-weight: 600; padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-outline-variant); color: var(--color-on-surface-variant);
  font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.05em;
}
.kw-table td { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--color-outline-variant); }
.kw-table tr:last-child td { border-bottom: none; }
.kw-table--compact th, .kw-table--compact td { padding: var(--space-1) var(--space-2); }
.kw-text-right { text-align: right; }

/* ── Badges ── */
.kw-badge {
  display: inline-flex; align-items: center; gap: var(--space-1);
  font-size: var(--text-xs); font-weight: 600; padding: 2px 8px;
  border-radius: var(--radius-full);
}
.kw-badge--success { background: var(--color-secondary-container); color: var(--color-secondary); }
.kw-badge--warning { background: var(--color-warning-container, hsl(45, 100%, 90%)); color: var(--color-warning, hsl(45, 90%, 35%)); }
.kw-badge--error { background: var(--color-error-container); color: var(--color-error); }

/* ── Empty State ── */
.kw-empty-state { text-align: center; padding: var(--space-6); }

/* ── Units Modal ── */
.kw-modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity var(--t-fast);
}
.kw-modal-overlay.open { opacity: 1; }
.kw-modal {
  background: var(--color-surface-container); border-radius: var(--radius-lg);
  width: 90%; max-width: 640px; max-height: 85vh; overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.3);
  transform: translateY(16px); transition: transform var(--t-fast);
}
.kw-modal-overlay.open .kw-modal { transform: translateY(0); }
.kw-modal__header {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--color-outline-variant);
  position: sticky; top: 0; background: var(--color-surface-container); z-index: 1;
}
.kw-modal__title { font-size: var(--text-lg); font-weight: 700; display: flex; align-items: center; }
.kw-modal__body { padding: var(--space-5); }
.kw-units-section { margin-bottom: var(--space-5); }
.kw-units-section h4 { font-size: var(--text-base); font-weight: 600; margin-bottom: var(--space-2); }
.kw-units-rule { font-size: var(--text-xl); font-weight: 800; color: var(--color-primary); margin-bottom: var(--space-1); }
.kw-code-block {
  display: block; font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: var(--text-sm); padding: var(--space-3);
  background: var(--color-surface-container-highest); border-radius: var(--radius-md);
  margin-bottom: var(--space-3); overflow-x: auto; white-space: pre-wrap;
}
.kw-units-factors { display: flex; gap: var(--space-3); flex-wrap: wrap; }
.kw-units-factor {
  flex: 1; min-width: 120px; padding: var(--space-2) var(--space-3);
  background: var(--color-surface-container-highest); border-radius: var(--radius-md);
  display: flex; flex-direction: column; gap: 2px;
}
.kw-units-factor__label { font-size: var(--text-xs); color: var(--color-on-surface-variant); }
.kw-estimate-result {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-3); background: var(--color-primary-container);
  border-radius: var(--radius-md); color: var(--color-on-primary-container);
}

/* ── Responsive for new components ── */
@media (max-width: 768px) {
  .kw-verticals-grid { grid-template-columns: 1fr; }
  .kw-modal { width: 95%; max-height: 90vh; }
  .kw-units-factors { flex-direction: column; }
}

/* ============================================================
   END OF PORTAL.CSS
   ============================================================ */
