:root {
  color-scheme: light;
  --font-body: "Aptos", "Segoe UI Variable Text", "Segoe UI", sans-serif;
  --font-display: "Aptos Display", "Segoe UI Variable Display", "Segoe UI", sans-serif;
  --bg: #f7fafc;
  --bg-strong: #eef4f8;
  --surface: #ffffff;
  --surface-muted: #f1f6f9;
  --surface-strong: #e5eef4;
  --ink: #0a1018;
  --ink-muted: #405366;
  --ink-soft: #64788a;
  --border: #d5e2ea;
  --border-strong: #a9bdca;
  --accent: #1d7fa6;
  --accent-strong: #166b8d;
  --accent-soft: #e2eff5;
  --focus: rgba(29, 127, 166, 0.24);
  --danger: #b23838;
  --danger-soft: #f8e7e7;
  --success: #19705c;
  --success-soft: #e4f4ef;
  --sidebar: #08101d;
  --sidebar-raised: #111827;
  --sidebar-line: rgba(255, 255, 255, 0.12);
  --sidebar-text: #f3f4f6;
  --sidebar-muted: #94a3b8;
  --shadow-subtle: none;
  --shadow-panel: none;
  --rail-width: 56px;
  --panel-width: 260px;
  --radius-xl: 8px;
  --radius-lg: 4px;
  --radius-md: 4px;
  --radius-sm: 2px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-soft: cubic-bezier(0.25, 1, 0.5, 1);
  --z-drawer: 20;
  --z-feedback: 30;
  --text-caption: 0.75rem;
  --text-small: 0.8125rem;
  --text-body: 0.875rem;
  --text-lead: 0.9375rem;
  --text-subhead: 1.125rem;
  --text-title: 1.25rem;
  /* Fluid rather than fixed: at 1.875rem a three-word page title filled a third of a
     375px screen before any content. Scales back up to the original size on desktop. */
  --text-display: clamp(1.375rem, 1.05rem + 1.4vw, 1.875rem);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

img {
  display: block;
}

[hidden] {
  display: none !important;
}

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

.skip-link {
  position: fixed;
  left: 16px;
  top: 16px;
  z-index: var(--z-feedback);
  transform: translateY(-160%);
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent-strong);
  box-shadow: none;
}

.skip-link:focus {
  transform: translateY(0);
}

.app-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  color: currentColor;
}

.app {
  height: 100vh;
  min-height: 100dvh;
  width: 100%;
  display: flex;
  align-items: stretch;
  overflow: hidden;
  background: var(--bg);
}

.sidebar-rail {
  flex: 0 0 var(--rail-width);
  width: var(--rail-width);
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 7px;
  background: var(--sidebar);
  border-right: 0;
  overflow: hidden;
  opacity: 1;
  transition:
    flex-basis 280ms var(--ease-soft),
    width 280ms var(--ease-soft),
    padding 280ms var(--ease-soft),
    opacity 220ms var(--ease-soft);
}

.app--sidebar-expanded .sidebar-rail {
  flex-basis: 0;
  width: 0;
  padding-right: 0;
  padding-left: 0;
  border-right: 0;
  opacity: 0;
  pointer-events: none;
}

.app--sidebar-collapsed .sidebar-rail .rail-button {
  display: inline-flex;
}

.rail-logo,
.rail-button {
  width: 40px;
  height: 40px;
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  background: transparent;
  color: var(--sidebar-muted);
  transition:
    background 160ms var(--ease-out),
    color 160ms var(--ease-out),
    border-color 160ms var(--ease-out);
}

.rail-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
  background: var(--accent-strong);
}

.rail-logo img {
  width: 25px;
  height: 25px;
  object-fit: contain;
}

.rail-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.sidebar-rail .rail-button {
  display: none;
}

.rail-button:hover,
.rail-button.is-active {
  border-color: transparent;
  background: rgba(255, 255, 255, 0.1);
  color: #f8fbff;
}

.rail-button.is-active {
  border-color: transparent;
}

.rail-button--bottom {
  margin-top: auto;
}

.sidebar-panel {
  flex: 0 0 var(--panel-width);
  width: var(--panel-width);
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  color: var(--sidebar-text);
  border-right: 1px solid var(--sidebar-line);
  overflow: hidden;
  opacity: 1;
  transition:
    flex-basis 280ms var(--ease-soft),
    width 280ms var(--ease-soft),
    opacity 220ms var(--ease-soft);
}

.app--sidebar-collapsed .sidebar-panel {
  flex-basis: 0;
  width: 0;
  border-right: 0;
  opacity: 0;
  pointer-events: none;
}

.sidebar-panel__header,
.sidebar-panel__footer {
  flex-shrink: 0;
  padding: 24px 20px;
}

.sidebar-panel__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--sidebar-line);
}

.sidebar-brand {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  min-width: 0;
}

.sidebar-brand__mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-lg);
  background: var(--accent-strong);
}

.sidebar-brand__mark img {
  width: 25px;
  height: 25px;
  object-fit: contain;
}

.sidebar-brand p {
  margin: 3px 0 0;
  color: rgba(188, 199, 222, 0.72);
  font-size: 12px;
  line-height: 1.3;
}

.sidebar-panel h2,
.topbar h1,
.page-hero h2,
.command-center h2,
.panel h3 {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: 0;
}

.sidebar-panel h2 {
  font-size: 22px;
  line-height: 1.2;
}

.sidebar-nav {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 18px 10px;
}

.sidebar-nav::-webkit-scrollbar,
.page-host::-webkit-scrollbar,
.recap-output::-webkit-scrollbar,
.json-block pre::-webkit-scrollbar {
  width: 10px;
}

.sidebar-nav::-webkit-scrollbar-thumb,
.page-host::-webkit-scrollbar-thumb,
.recap-output::-webkit-scrollbar-thumb,
.json-block pre::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
  background-color: rgba(101, 114, 130, 0.36);
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-group + .nav-group {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--sidebar-line);
}

.nav-group__label,
.eyebrow {
  margin: 0 0 8px;
  color: var(--sidebar-muted);
  /* 10px uppercase with 0.08em tracking is under the readable floor on a phone. */
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-item,
.nav-subitem {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  background: transparent;
  color: var(--sidebar-text);
  text-align: left;
  transition:
    background 160ms var(--ease-out),
    border-color 160ms var(--ease-out),
    color 160ms var(--ease-out);
}

.nav-item {
  min-height: 50px;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 700;
}

.nav-submenu {
  display: none;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 10px 0;
  padding-left: 22px;
}

.nav-submenu.is-open {
  display: flex;
  animation: submenuIn 160ms var(--ease-out) both;
}

.nav-subitem {
  min-height: 36px;
  padding: 0 12px;
  color: rgba(188, 199, 222, 0.72);
  font-size: 12px;
  font-weight: 700;
}

.nav-item--parent::after {
  width: 7px;
  height: 7px;
  margin-left: auto;
  border-right: 1.8px solid currentColor;
  border-bottom: 1.8px solid currentColor;
  content: "";
  opacity: 0.58;
  transform: rotate(45deg) translateY(-1px);
  transition: transform 180ms var(--ease-out);
}

.nav-item--parent.is-expanded::after {
  transform: rotate(-135deg) translate(-2px, -1px);
}

.nav-item:hover,
.nav-subitem:hover,
.nav-item.is-active,
.nav-subitem.is-active {
  border-color: transparent;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.nav-item.is-active,
.nav-subitem.is-active {
  background: var(--accent-strong);
  color: #ffffff;
  box-shadow: none;
}

.sidebar-panel__footer {
  border-top: 1px solid var(--sidebar-line);
}

.session-badge {
  margin: 0 0 12px;
  color: var(--sidebar-muted);
  font-size: 12px;
  line-height: 1.45;
}

.main-content {
  flex: 1;
  min-width: 0;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 64px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  -webkit-app-region: drag;
}

.topbar button,
.topbar input {
  -webkit-app-region: no-drag;
}

.topbar .eyebrow,
.page-hero .eyebrow,
.command-center .eyebrow,
.panel .eyebrow {
  color: var(--accent-strong);
}

.topbar__title {
  grid-column: 1 / 3;
  min-width: 0;
}

.app--sidebar-collapsed .topbar__title {
  grid-column: 2 / 3;
}

.topbar h1 {
  color: var(--ink);
  font-size: var(--text-title);
  font-weight: 700;
  line-height: 1.12;
}

.topbar__actions {
  grid-column: 3 / 4;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.topbar-action {
  display: inline-flex;
  border: 0;
  background: transparent;
}

.topbar__actions .window-close-button {
  margin-left: 2px;
}

.page-host {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 24px;
}

.page-host:focus,
.page-host:focus-visible,
.page-host:focus-within {
  outline: none;
}

.page {
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 1440px;
  margin: 0 auto;
  animation: pageIn 260ms var(--ease-out) both;
}

.page--narrow {
  max-width: 880px;
}

.auth-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 32px;
  background: var(--bg);
}

.auth-card {
  width: min(470px, 100%);
  padding: 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: none;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 34px;
}

.brand-mark img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.brand-mark h1,
.auth-card h2 {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: 0;
}

.auth-card h2 {
  font-size: 26px;
}

.auth-card__copy p:last-child {
  margin: 10px 0 0;
  max-width: 56ch;
  color: var(--ink-muted);
  line-height: 1.6;
}

.auth-form,
.form-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-form {
  margin-top: 24px;
}

.form-panel {
  width: min(680px, 100%);
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: none;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field span {
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 800;
}

.control {
  width: 100%;
  /* Was a flat 38px, two pixels shorter than the buttons it sits next to in every form.
     min-height also lets the coarse-pointer rule below raise it without a second override. */
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
  outline: none;
  transition:
    border-color 160ms var(--ease-out),
    box-shadow 160ms var(--ease-out),
    background 160ms var(--ease-out);
}

.control:focus {
  border-color: rgba(49, 95, 203, 0.52);
  box-shadow: 0 0 0 4px var(--focus);
}

.button,
.icon-button,
.window-close-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 14px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  transition:
    background 160ms var(--ease-out),
    border-color 160ms var(--ease-out),
    color 160ms var(--ease-out),
    transform 160ms var(--ease-out);
}

.button:hover:not(:disabled),
.icon-button:hover:not(:disabled),
.window-close-button:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--surface-strong);
}

.button:active:not(:disabled),
.icon-button:active:not(:disabled),
.window-close-button:active:not(:disabled),
.rail-button:active,
.nav-item:active,
.nav-subitem:active {
  transform: translateY(1px);
}

.button:focus-visible,
.icon-button:focus-visible,
.window-close-button:focus-visible,
.rail-button:focus-visible,
.nav-item:focus-visible,
.nav-subitem:focus-visible,
.route-card:focus-visible,
.control:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.button--primary,
.button--accent {
  border-color: var(--accent);
  background: var(--accent);
  color: #f8fbff;
}

.button--primary:hover:not(:disabled),
.button--accent:hover:not(:disabled) {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.button--ghost {
  background: var(--surface);
  color: var(--ink);
}

.sidebar-panel .button--ghost {
  width: 100%;
  border-color: var(--sidebar-line);
  background: var(--surface-muted);
  color: var(--sidebar-text);
}

.button--danger {
  border-color: rgba(178, 56, 56, 0.22);
  background: var(--danger-soft);
  color: var(--danger);
}

.button--text {
  /* "Retirer" was 38px wide with zero padding: a text label with no hit area worth the name.
     Keeping the button metrics and dropping only the border keeps the link look. */
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  box-shadow: none;
}

.button--text:hover:not(:disabled) {
  border-color: transparent;
  box-shadow: none;
}

.icon-button {
  width: 42px;
  padding: 0;
  display: none;
}

.window-close-button {
  width: 34px;
  min-height: 34px;
  flex: 0 0 34px;
  padding: 0;
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink-muted);
}

.window-close-button:hover:not(:disabled) {
  border-color: rgba(178, 56, 56, 0.24);
  background: var(--danger-soft);
  color: var(--danger);
}

.auth-close-button {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: var(--z-feedback);
}

.sidebar-panel__header .icon-button,
.app--sidebar-collapsed .topbar > .icon-button {
  display: inline-flex;
}

.topbar > .icon-button {
  grid-column: 1 / 2;
}

.page-hero,
.command-center,
.panel,
.metric-card,
.entity-card,
.route-card {
  border: 1px solid var(--border);
  background: var(--surface);
}

.page-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  box-shadow: none;
}

.page-hero--compact {
  align-items: center;
}

.page-hero h2 {
  max-width: 720px;
  color: var(--ink);
  font-size: var(--text-display);
  font-weight: 720;
  line-height: 1.2;
  text-wrap: balance;
}

.page-hero p:last-child {
  max-width: 68ch;
  margin: 0.375rem 0 0;
  color: var(--ink-muted);
  font-size: var(--text-small);
  line-height: 1.45;
}

.dashboard-page {
  gap: 32px;
}

.command-center {
  position: relative;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: end;
  overflow: visible;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.command-center::after {
  content: "";
  display: none;
}

.command-center__copy {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 24px;
}

.command-center h2 {
  max-width: 780px;
  font-size: var(--text-display);
  font-weight: 800;
  line-height: 1.16;
  text-wrap: balance;
}

.command-center__copy p:last-child {
  max-width: 62ch;
  margin: 4px 0 0;
  color: var(--ink-muted);
  font-size: 13px;
  line-height: 1.45;
}

.command-actions,
.quick-action-grid,
.settings-actions,
.danger-actions,
.logo-uploader__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.dashboard-main-column {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  grid-column: span 2;
}

.metric-card {
  display: grid;
  gap: 8px;
  min-height: 180px;
  padding: 16px;
  border-radius: var(--radius-lg);
  box-shadow: none;
}

.metric-card span,
.metric-card small {
  color: var(--ink-muted);
  font-size: var(--text-small);
  font-weight: 700;
  line-height: 1.35;
}

.metric-card strong {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 2rem;
  font-variant-numeric: tabular-nums;
  font-weight: 820;
  line-height: 1.05;
  letter-spacing: 0;
}

.metric-card[data-tone="strong"] {
  border-color: var(--border);
  background: var(--surface);
  color: var(--accent);
}

.metric-card[data-tone="strong"] span,
.metric-card[data-tone="strong"] small,
.metric-card[data-tone="strong"] strong {
  color: inherit;
}

.dashboard-grid,
.workbench-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(310px, 0.72fr);
  gap: 14px;
  align-items: start;
}

.dashboard-section-grid {
  display: none;
}

.panel-stack,
.list-stack,
.entity-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.panel {
  padding: 20px;
  border-radius: var(--radius-lg);
  box-shadow: none;
  content-visibility: auto;
  contain-intrinsic-size: 360px;
}

.panel-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.dashboard-view-all {
  width: 100%;
  justify-content: center;
  min-height: 48px;
  margin-top: 12px;
  border-top: 1px solid var(--border);
  color: var(--accent);
}

.panel--large {
  min-height: 420px;
}

.panel--flush {
  padding: 0;
  overflow: hidden;
}

.panel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.panel h3 {
  color: var(--ink);
  font-size: var(--text-subhead);
  font-weight: 800;
  line-height: 1.2;
}

.report-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}

.report-toolbar__field {
  margin: 0;
}

.report-toolbar__metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.report-toolbar__metrics .metric-card {
  min-height: 0;
  padding: 1.125rem;
}

.report-toolbar__metrics .metric-card strong {
  font-size: 1.85rem;
}

.client-report {
  display: grid;
  gap: 16px;
}

.client-report__title {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.client-report__title h3 {
  font-size: var(--text-subhead);
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.client-report__title p:last-child {
  margin: 4px 0 0;
  color: var(--ink-muted);
  font-size: var(--text-small);
}

.client-report__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.client-report__summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.report-summary-block {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-muted);
}

.report-summary-block h4 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: var(--text-small);
  font-weight: 820;
  line-height: 1.35;
}

.report-summary-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  color: var(--ink-muted);
  font-size: var(--text-small);
  line-height: 1.35;
}

.report-summary-row:first-of-type {
  border-top: 0;
}

.report-summary-row span {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-weight: 760;
}

.report-summary-row strong {
  color: var(--accent-strong);
  font-variant-numeric: tabular-nums;
}

.report-summary-row small {
  /* Default `smaller` on an already-13px parent lands at 10.8px. Pin it instead. */
  font-size: 11px;
  white-space: nowrap;
}

.client-report__copy {
  margin-top: 0;
}

.client-report__text {
  margin-top: 12px;
}

.entity-card,
.list-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  box-shadow: none;
  transition:
    border-color 160ms var(--ease-out),
    background 160ms var(--ease-out);
}

.entity-card:hover {
  border-color: var(--border-strong);
  background: var(--surface-muted);
}

.entity-card--timer {
  border-color: rgba(49, 95, 203, 0.22);
  background: var(--accent-soft);
}

.entity-card__body {
  min-width: 0;
}

/* These carry user-entered names. A client called "ZZZZ…" with no space cannot wrap on its
   own, so the card grew past the viewport and made .page-host scroll sideways. */
.entity-card__title {
  margin: 0;
  color: var(--ink);
  font-weight: 720;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.entity-card__meta,
.entity-card__note {
  margin: 4px 0 0;
  color: var(--ink-muted);
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.entity-card__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.entity-card__side-value {
  align-self: center;
  color: var(--ink);
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  white-space: nowrap;
}

.category-manager {
  grid-column: 2 / -1;
  display: grid;
  gap: 9px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.category-manager__label,
.category-manager__empty {
  margin: 0;
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 820;
}

.category-manager__empty {
  font-weight: 650;
}

.category-row,
.category-add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.category-row__name {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-mark {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  background: var(--surface-strong);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 900;
  overflow: hidden;
}

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

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 820;
  font-variant-numeric: tabular-nums;
}

.chip--active {
  border-color: rgba(49, 95, 203, 0.22);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.details-block {
  grid-column: 1 / -1;
  margin-top: 2px;
}

.details-block > summary,
.json-block > summary {
  display: inline-flex;
  min-height: 31px;
  align-items: center;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 850;
  cursor: pointer;
  transition:
    border-color 160ms var(--ease-out),
    background 160ms var(--ease-out),
    color 160ms var(--ease-out);
}

.details-block > summary:hover,
.json-block > summary:hover {
  border-color: rgba(49, 95, 203, 0.28);
  background: var(--accent-soft);
}

.details-block dl {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.details-block dl div {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
}

.details-block dt {
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.details-block dd {
  margin: 5px 0 0;
  color: var(--ink);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.recap-output,
.json-block pre {
  width: 100%;
  max-height: 520px;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-muted);
  color: var(--ink);
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow: auto;
}

.route-card-grid,
.support-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.route-card {
  position: relative;
  min-height: 150px;
  padding: 20px;
  border-radius: var(--radius-lg);
  text-align: left;
  overflow: hidden;
  transition:
    border-color 180ms var(--ease-out),
    background 180ms var(--ease-out);
}

.dashboard-actions-panel .quick-action-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.dashboard-actions-panel .button {
  min-height: 96px;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
  border-color: transparent;
  background: var(--surface-muted);
  color: var(--ink);
  font-size: 14px;
}

.dashboard-actions-panel .button:hover:not(:disabled),
.dashboard-actions-panel .button:focus-visible {
  border-color: rgba(29, 127, 166, 0.28);
  background: var(--surface);
  color: var(--accent);
}

.dashboard-actions-panel .app-icon {
  width: 24px;
  height: 24px;
}

.route-card::after {
  content: none;
}

.route-card:hover {
  border-color: rgba(49, 95, 203, 0.28);
  background: var(--surface);
}

.route-card span {
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 850;
}

.route-card > .app-icon {
  width: 24px;
  height: 24px;
  color: var(--accent-strong);
}

.route-card strong {
  display: block;
  margin-top: 22px;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 0;
}

.route-card small,
.support-grid p {
  display: block;
  margin-top: 8px;
  color: var(--ink-muted);
  font-size: 13px;
  line-height: 1.6;
}

.support-grid article {
  min-width: 0;
}

.storage-info,
.settings-list {
  display: grid;
  gap: 10px;
}

.storage-info code,
.settings-list code {
  display: inline-block;
  max-width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--ink);
  overflow-wrap: anywhere;
}

.logo-uploader {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-muted);
}

.logo-uploader__preview {
  width: 78px;
  height: 78px;
  border-radius: var(--radius-lg);
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 900;
  overflow: hidden;
}

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

.logo-uploader__body p {
  margin: 4px 0 12px;
  color: var(--ink-muted);
  font-size: 12px;
  line-height: 1.5;
}

.empty-state,
.form-feedback {
  color: var(--ink-muted);
  font-size: 13px;
  line-height: 1.55;
}

.empty-state {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 18px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-muted);
}

.empty-state::after {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
  opacity: 0.28;
  content: "";
}

.empty-state strong {
  display: block;
  color: var(--ink);
  margin-bottom: 4px;
}

.empty-state__icon {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 13px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.empty-state p {
  margin: 0;
}

.app-notifications {
  position: fixed;
  top: 72px;
  right: clamp(16px, 2.2vw, 28px);
  z-index: var(--z-feedback);
  display: grid;
  gap: 8px;
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}

.app-toast {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  gap: 11px;
  align-items: start;
  padding: 12px 12px 12px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 16px 36px rgb(18 24 38 / 12%);
  pointer-events: auto;
  animation: toastIn 160ms ease-out both;
}

.app-toast.is-leaving {
  animation: toastOut 160ms ease-in both;
}

.app-toast__status {
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 999px;
  background: var(--accent);
}

.app-toast--success .app-toast__status {
  background: #16a36a;
}

.app-toast--error .app-toast__status {
  background: #d94747;
}

.app-toast p {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.45;
}

.app-toast__close {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.app-toast__close:hover {
  background: var(--surface-muted);
  color: var(--ink);
}

body.density-compact .page-host {
  padding: 14px;
}

body.density-compact .page {
  gap: 13px;
}

body.density-compact .entity-card,
body.density-compact .panel,
body.density-compact .metric-card {
  padding: 13px;
}

@keyframes pageIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-5px) scale(0.98);
  }
}

@keyframes submenuIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1260px) {
  .dashboard-layout {
    grid-template-columns: 1fr;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-column: auto;
  }

  .dashboard-grid,
  .workbench-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-section-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-section-grid > .panel:nth-child(1),
  .dashboard-section-grid > .panel:nth-child(2),
  .dashboard-section-grid > .panel:nth-child(3) {
    grid-column: 1 / -1;
    grid-row: auto;
  }

  .dashboard-actions-panel .quick-action-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1160px) {
  .app.app--sidebar-expanded .sidebar-rail,
  .app.app--sidebar-collapsed .sidebar-rail {
    flex: 0 0 var(--rail-width);
    width: var(--rail-width);
    padding: 14px 8px;
    border-right: 0;
    opacity: 1;
    pointer-events: auto;
  }

  .app.app--sidebar-expanded .sidebar-panel,
  .app.app--sidebar-collapsed .sidebar-panel {
    flex: 0 0 var(--panel-width);
    width: var(--panel-width);
    border-right: 0;
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar-rail .rail-button {
    display: inline-flex;
  }

  .app:has(.sidebar-panel.is-open) .sidebar-rail .rail-button {
    opacity: 0;
    pointer-events: none;
  }

  .sidebar-panel {
    position: fixed;
    inset: 0 auto 0 var(--rail-width);
    z-index: var(--z-drawer);
    transform: translateX(-120%);
    transition: transform 220ms var(--ease-out);
    box-shadow: none;
  }

  .sidebar-panel.is-open {
    transform: translateX(0);
  }

  .icon-button {
    display: inline-flex;
  }

  .command-center {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .route-card-grid,
  .support-grid {
    grid-template-columns: 1fr;
  }

  .report-toolbar,
  .client-report__summary {
    grid-template-columns: 1fr;
  }

  .report-toolbar__metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 780px) {
  .app {
    flex-direction: column;
  }

  /* Specificity has to match the <=1160px rules above, which pin the rail to --rail-width
     with `.app.app--sidebar-expanded .sidebar-rail`. Source order alone loses to them, which
     left the rail as a 56px vertical stub holding 334px of buttons: an inner horizontal
     scrollbar and a dark stump over the content instead of a bottom bar. */
  .sidebar-rail,
  .app.app--sidebar-expanded .sidebar-rail,
  .app.app--sidebar-collapsed .sidebar-rail {
    order: 2;
    flex: 0 0 66px;
    width: 100%;
    height: 66px;
    flex-direction: row;
    justify-content: space-around;
    gap: 6px;
    padding: 8px;
    border-top: 1px solid var(--sidebar-line);
    border-right: 0;
    /* The buttons now fit; keeping auto would re-introduce a stray scrollbar on 320px. */
    overflow-x: clip;
  }

  .rail-logo {
    display: none;
  }

  .rail-button {
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
  }

  .rail-button--bottom {
    margin-top: 0;
    margin-left: 0;
  }

  .main-content {
    order: 1;
    height: calc(100% - 66px);
  }

  /* Same specificity fix as the rail: the <=1160px rules pin the panel width otherwise. */
  .sidebar-panel,
  .app.app--sidebar-expanded .sidebar-panel,
  .app.app--sidebar-collapsed .sidebar-panel {
    inset: 0 auto 66px 0;
    flex: none;
    width: min(360px, 92vw);
  }

  /* Actions used to wrap onto a second row, so the header ate 133px of a 667px screen
     before any content. With the Electron-only close button gone there are two icons
     left, which fit beside the title. */
  .topbar {
    min-height: auto;
    align-items: center;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    gap: 10px;
    padding: 12px 15px;
  }

  .topbar__title {
    grid-column: 2 / 3;
    flex: 1;
    min-width: 0;
  }

  .topbar__actions {
    grid-column: 3 / 4;
    width: auto;
    justify-content: flex-end;
  }

  .page-host {
    padding: 15px;
  }

  .app-notifications {
    top: 14px;
    right: 12px;
    left: 12px;
    width: auto;
  }

  .command-center,
  .page-hero {
    border-radius: var(--radius-xl);
    padding: 0;
  }

  .command-center h2 {
    font-size: 1.45rem;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-actions-panel .quick-action-grid {
    grid-template-columns: 1fr;
  }

  .report-toolbar__metrics {
    grid-template-columns: 1fr;
  }

  .client-report .panel__head,
  .client-report__actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .report-summary-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 3px;
  }

  .entity-card {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .entity-card__actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .category-manager {
    grid-column: 1 / -1;
  }

  .logo-uploader {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .auth-screen {
    padding: 16px;
  }

  .auth-card {
    padding: 22px;
    border-radius: var(--radius-xl);
  }

  .button,
  .icon-button {
    min-height: 44px;
  }

  .command-actions,
  .quick-action-grid,
  .settings-actions,
  .danger-actions {
    flex-direction: column;
  }

  .command-actions .button,
  .quick-action-grid .button,
  .settings-actions .button,
  .danger-actions .button {
    width: 100%;
  }

  .client-mark {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
    border-radius: 13px;
  }
}

/* Touch, not width, is what makes a 38px control hard to hit: a phone in landscape is 812px
   wide and still driven by a thumb. The width rules above only ever covered .button. */
@media (pointer: coarse) {
  .button,
  .icon-button,
  .window-close-button,
  .control,
  .details-block > summary,
  .json-block > summary {
    min-height: 44px;
  }

  .rail-button {
    min-width: 44px;
    min-height: 44px;
  }

  /* .icon-button pins width: 42px, so min-height alone leaves it two pixels narrow. */
  .icon-button,
  .window-close-button {
    min-width: 44px;
    width: 44px;
  }

  .chip {
    min-height: 26px;
  }
}

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

/* Enterprise brand shell using the Webside blue palette. */
.sidebar-rail,
.sidebar-panel {
  background: #08101d !important;
  color: #f3f4f6;
}

.sidebar-panel__header,
.sidebar-panel__footer {
  background: #08101d;
}

.nav-item,
.nav-subitem {
  color: rgba(243, 244, 246, 0.62);
}

.nav-group__label,
.sidebar-panel .eyebrow,
.session-badge {
  color: rgba(148, 163, 184, 0.9);
}

.rail-button,
.sidebar-panel .icon-button,
.sidebar-panel .button--ghost {
  border-color: rgba(255, 255, 255, 0.08);
}

.sidebar-panel .button--ghost {
  background: rgba(143, 174, 199, 0.08);
  color: rgba(243, 244, 246, 0.9);
}

.sidebar-panel .button--ghost:hover:not(:disabled) {
  border-color: rgba(143, 174, 199, 0.24);
  background: rgba(143, 174, 199, 0.14);
  color: #f3f4f6;
}

.sidebar-panel .button--ghost:disabled {
  opacity: 0.72;
  color: rgba(243, 244, 246, 0.82);
}
