/* Cargoo Design System (Rebrand) for the invoice audit dashboard.
   Values from the Rebrand design system (frontend tailwind.config.ts and
   @cargoo-com/cargoo-ui 3.1.27): brand #3355FF, brand-gray scale, Roboto,
   white page and header. The dashboard page (content/audit-dashboard.html)
   is written against the claude.ai Dashboard tokens (--color-*, --cds-*,
   --font-anthropic-*); they are mapped to Cargoo values here. */

:root {
  color-scheme: light;

  /* Cargoo scales */
  --brand-50: #ebf2ff;
  --brand-100: #d1e2ff;
  --brand-200: #9dc0ff;
  --brand-500: #3355ff;
  --brand-600: #2644d9;
  --brand-700: #2238aa;
  --gray-50: #fafafa;
  --gray-100: #f4f5f5;
  --gray-200: #ededef;
  --gray-300: #e3e4e6;
  --gray-400: #d7d8da;
  --gray-500: #a1a3a7;
  --gray-600: #6f7278;
  --gray-700: #4a4d55;
  --gray-800: #2d303a;
  --gray-900: #1f2131;
  --error-100: #fee2e2;
  --error-500: #dc2626;
  --error-700: #971717;
  --success-100: #dcf1da;
  --success-500: #36b044;
  --success-700: #256f2c;
  --warning-100: #fcedd4;
  --warning-500: #ffbb33;
  --warning-600: #d39512;
  --warning-700: #ac7d1b;
  --input-ring: #e1e1e1;
  --shadow-header-scrolled: 0 4px 25.7px -7px rgba(34, 41, 58, 0.36);
  --shadow-dropdown: 0 4px 19.6px 0 rgba(34, 41, 58, 0.1);
  --shadow-menu-current: 0 2px 2px -1px rgba(91, 37, 239, 0.15);

  /* Dashboard tokens the page uses, mapped to Cargoo */
  --font-anthropic-sans: Roboto, system-ui, sans-serif;
  --font-anthropic-serif: Roboto, system-ui, sans-serif;
  --color-fg: var(--gray-900);
  --color-fg-muted: var(--gray-600);
  --color-bg: var(--gray-100);
  --color-panel: #ffffff;
  --color-border-line: var(--gray-300);
  --color-ok: var(--success-500);
  --color-warn: var(--warning-600);
  --color-bad: var(--error-500);

  --cds-border: var(--gray-300);
  --cds-text-secondary: var(--gray-700);
  --cds-chart-axis: var(--gray-600);
  --cds-chart-grid: var(--gray-200);
  --cds-chart-muted: var(--gray-500);
  --cds-surface-popover: #ffffff;
  --cds-shadow-popover: var(--shadow-dropdown);
  --cds-radius: 6px;
  --cds-dur-slow: 300ms;
  --cds-font-size-caption: 12px;
  --cds-font-size-body: 14px;
  --cds-font-size-heading: 18px;
  --cds-font-size-title: 28px;
  --cds-font-weight-medium: 500;
  --cds-gap-xs: 4px;
  --cds-gap-sm: 8px;
  --cds-gap-md: 12px;
  --cds-gap-xl: 24px;
  --cds-pad-xs: 4px;
  --cds-pad-sm: 6px;
  --cds-pad-md: 12px;
  --cds-pad-lg: 16px;
}

/* ── App shell ─────────────────────────────────────────────────────── */
body.cg {
  margin: 0;
  background: #ffffff;
  color: var(--gray-900);
  font: 400 14px/20px Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.cg *, .cg *::before, .cg *::after { box-sizing: border-box; }

.cg-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 40px;
  padding: 16px 24px;
  background: #ffffff;
  transition: box-shadow 150ms;
}
.cg-header.is-scrolled { box-shadow: var(--shadow-header-scrolled); }
.cg-logo { display: inline-flex; flex: none; }
.cg-logo img { display: block; width: 108px; height: auto; }
.cg-menu { display: flex; gap: 12px; min-width: 0; }
.cg-menu-item {
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--gray-900);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.cg-menu-item:hover { background: var(--brand-500); color: #ffffff; }
.cg-menu-item.is-current { background: var(--gray-200); box-shadow: var(--shadow-menu-current); }
.cg-menu-item.is-current:hover { background: var(--brand-500); color: #ffffff; }
.cg-user { margin-left: auto; display: flex; align-items: center; gap: 12px; min-width: 0; }
.cg-avatar {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 9999px;
  display: grid;
  place-items: center;
  background: var(--brand-100);
  color: var(--brand-700);
  font-weight: 500;
}
.cg-user-text { display: grid; min-width: 0; }
.cg-user-name { font-weight: 500; color: var(--gray-900); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cg-user-org { color: var(--gray-600); }

.cg-crumbs { display: flex; gap: 8px; padding: 20px 24px 16px; color: var(--gray-600); }
.cg-main { padding: 0 24px 40px; }

@media (max-width: 640px) {
  .cg-header { gap: 16px; padding: 12px 16px; }
  .cg-menu, .cg-user-text { display: none; }
  .cg-crumbs { padding: 16px 16px 12px; }
  .cg-main { padding: 0 16px 32px; }
}

/* Buttons (cargoo-ui CargooButton, md) */
.cg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 14px;
  border-radius: 6px;
  font: 500 13px/18px Roboto, system-ui, sans-serif;
  text-decoration: none;
  cursor: pointer;
  border: 0;
}
.cg-btn-primary { background: var(--brand-500); color: #ffffff; }
.cg-btn-primary:hover { background: var(--brand-600); }

/* Sign-in */
.cg-signin { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--gray-100); }
.cg-signin-card {
  width: 100%;
  max-width: 420px;
  display: grid;
  gap: 16px;
  justify-items: start;
  padding: 32px;
  background: #ffffff;
  border: 1px solid var(--gray-300);
  border-radius: 16px;
}
.cg-signin-card h1 { margin: 8px 0 0; font-size: 24px; line-height: 32px; font-weight: 700; letter-spacing: -0.24px; }
.cg-signin-card p { margin: 0; color: var(--gray-700); }
.cg-error { color: var(--error-500) !important; }

/* ── Dashboard page, restyled to the Cargoo look ───────────────────── */
#dash-root .ia { --cargoo: var(--brand-500); --d365: var(--warning-600); }
#dash-root .ia h1 {
  font-family: Roboto, system-ui, sans-serif;
  font-size: 32px;
  line-height: 40px;
  font-weight: 700;
  letter-spacing: -0.32px;
}
#dash-root .ia h2 { font-size: 18px; line-height: 1.2; }
#dash-root .ia .card { border-radius: 8px; }
#dash-root .ia .tile { border-radius: 8px; }
#dash-root .ia .tile .val { font-weight: 500; }

/* Tabs (CargooTabs): 2px bottom border, brand when active */
#dash-root .ia .tab:hover { color: var(--gray-900); }
#dash-root .ia .tab[aria-selected="true"] { color: var(--gray-900); border-bottom-color: var(--brand-500); }

/* Segmented switch */
#dash-root .ia .seg button:hover { background: var(--gray-100); color: var(--gray-900); }
#dash-root .ia .seg button[aria-pressed="true"] { background: var(--brand-500); color: #ffffff; }

/* Focus and selection in brand blue */
#dash-root .ia .tab:focus-visible,
#dash-root .ia .seg button:focus-visible,
#dash-root .ia .node:focus-visible { outline: 2px solid var(--brand-500); }
#dash-root .ia .tile.pick[aria-pressed="true"] { outline: 2px solid var(--brand-500); background: var(--brand-50); }
#dash-root .ia td.pick.on { background: var(--brand-50); box-shadow: inset 0 0 0 2px var(--brand-500); color: var(--brand-700); }
#dash-root .ia a { color: var(--brand-500); }

/* Tables: gray-100 header, gray-300 lines, row hover */
#dash-root .ia th { background: var(--gray-100); color: var(--gray-700); }
#dash-root .ia tbody tr:hover td { background: var(--gray-100); }

/* Selects (cargoo-ui input, xs): inset ring, brand focus */
#dash-root .ia select {
  height: 28px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  background: #ffffff;
  box-shadow: inset 0 0 0 1px var(--input-ring), 0 1px 2px rgba(34, 41, 58, 0.05);
}
#dash-root .ia select:focus-visible { outline: none; box-shadow: inset 0 0 0 1px var(--brand-500), 0 0 0 3px var(--brand-100); }

/* Loading placeholders (the Dashboard type's skeleton class) */
#dash-root .dash-skeleton {
  color: transparent !important;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--gray-100), var(--gray-200), var(--gray-100));
  background-size: 200% 100%;
  animation: cg-shimmer 1.2s linear infinite;
}
#dash-root [data-dash-source-state="loading"] { opacity: 0.6; }
#dash-root [data-dash-source-state="error"] { outline: 1px dashed var(--error-500); outline-offset: 2px; }
@keyframes cg-shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { #dash-root .dash-skeleton { animation: none; } }

/* Runtime notices (a script or a dataset failed) */
.cg-notice {
  margin: 0 0 16px;
  padding: 10px 14px;
  border-radius: 6px;
  background: var(--error-100);
  color: var(--error-700);
  font-size: 13px;
}

/* The Dashboard host hides [hidden] even where page CSS sets a display. */
#dash-root [hidden] { display: none !important; }
