/* UI tokens (--ui-*), loaded on every page. Accent, radius, font and density become tenant settings later. */

:root {
    /* --- neutrals --- */
    --ui-bg: #f5f6f8;
    --ui-surface: #ffffff;
    --ui-surface-2: #f9fafb;
    --ui-surface-hover: #f3f5f8;
    --ui-border: #e4e7ec;
    --ui-border-strong: #d0d5dd;
    --ui-text: #101828;
    --ui-text-2: #344054;
    --ui-text-3: #667085;
    --ui-text-4: #98a2b3;
    --ui-text-inverse: #ffffff; /* on accent and dark fills */
    --ui-border-hover: #98a2b3;
    --ui-surface-sunken: #eaecf0;

    /* --- accent (tenant branding) --- */
    --ui-accent: var(--color-primary, #2563eb);
    --ui-accent-dark: var(--color-primary-dark, #1d4ed8);
    --ui-accent-tint: var(--color-primary-tint, rgba(37, 99, 235, 0.1));
    --ui-focus: 0 0 0 3px var(--color-primary-shadow, rgba(37, 99, 235, 0.3));

    /* --- status semantics: text, background, dot --- */
    --ui-neutral-fg: #475467;  --ui-neutral-bg: #f2f4f7;  --ui-neutral-dot: #98a2b3;
    --ui-info-fg: #175cd3;     --ui-info-bg: #eff8ff;     --ui-info-dot: #2e90fa;
    --ui-success-fg: #067647;  --ui-success-bg: #ecfdf3;  --ui-success-dot: #17b26a;
    --ui-warning-fg: #b54708;  --ui-warning-bg: #fffaeb;  --ui-warning-dot: #f79009;
    --ui-danger-fg: #b42318;   --ui-danger-bg: #fef3f2;   --ui-danger-dot: #f04438;
    --ui-change-fg: #5925dc;   --ui-change-bg: #f4f3ff;   --ui-change-dot: #7a5af8;
    --ui-info-border: #b2ddff;
    --ui-success-border: #abefc6;
    --ui-warning-border: #fec84b;
    --ui-danger-border: #fecdca;

    /* --- type --- */
    --ui-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --ui-font-mono: 'IBM Plex Mono', 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    --ui-fs-2xs: 0.6875rem; /* 11px, small labels */
    --ui-fs-xs: 0.75rem;   /* 12px */
    --ui-fs-sm: 0.8125rem; /* 13px */
    --ui-fs-md: 0.875rem;  /* 14px */
    --ui-fs-lg: 1rem;      /* 16px */
    --ui-fs-title: 1.125rem; /* 18px, page titles */
    --ui-fs-xl: 1.25rem;   /* 20px */
    --ui-fs-2xl: 1.625rem; /* 26px */

    /* --- icon sizes (glyph font-size) --- */
    --ui-icon-2xs: 0.6rem;
    --ui-icon-xs: 0.65rem;
    --ui-icon-sm: 0.7rem;
    --ui-icon-md: 0.75rem;
    --ui-icon-lg: 0.8rem;
    --ui-icon-xl: 0.875rem;
    --ui-icon-2xl: 1rem;
    --ui-icon-3xl: 1.2rem;
    --ui-icon-hero: 1.75rem;

    /* --- spacing, 4px grid (padding, margin, gap) --- */
    --ui-space-0-5: 2px;
    --ui-space-1: 4px;
    --ui-space-1-5: 6px;
    --ui-space-2: 8px;
    --ui-space-2-5: 10px;
    --ui-space-3: 12px;
    --ui-space-3-5: 14px;
    --ui-space-4: 16px;
    --ui-space-5: 20px;
    --ui-space-6: 24px;
    --ui-space-8: 32px;
    --ui-space-10: 40px;
    --ui-space-12: 48px;
    --ui-space-14: 56px;
    --ui-space-16: 64px;
    --ui-space-18: 72px;

    /* --- shape and depth --- */
    --ui-radius-sm: 6px;
    --ui-radius: 8px;
    --ui-radius-lg: 12px;
    --ui-shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
    --ui-shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
    --ui-shadow-lg: 0 12px 24px -6px rgba(16, 24, 40, 0.14), 0 4px 8px -4px rgba(16, 24, 40, 0.06);
    --ui-shadow-paper: 0 1px 3px rgba(16, 24, 40, 0.12), 0 8px 24px -8px rgba(16, 24, 40, 0.18);
    --ui-scrim: rgba(16, 24, 40, 0.35);
    --ui-scrim-strong: rgba(16, 24, 40, 0.45);

    /* --- sizing --- */
    --ui-topbar-h: 70px; /* fixed app top bar; 60px on phones, see chrome.css */
    --ui-control-h: 36px;
    --ui-control-h-sm: 30px;
    --ui-control-icon-inset: 34px; /* text start after a leading icon */
    --ui-control-arrow-inset: 30px; /* text end before a select arrow */
    --ui-search-max-w: 600px;
    --ui-select-arrow-size: 14px;
    /* stroke = --ui-text-3 */
    --ui-select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23667085' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.75' d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
    --ui-table-head-py: 9px;  /* list density: */
    --ui-table-cell-py: 11px; /* every row pays for a change here */
    --ui-field-py: 7px;       /* form density, same reason */
    --ui-field-label-gap: 5px;
    --ui-ease: cubic-bezier(0.2, 0, 0, 1);
}

/* Dark scope for full-screen operations views (dispatch control centre).
   Remaps the same tokens, so every .ui-* component inside follows. */
.ui-theme-dark {
    color-scheme: dark;
    --ui-bg: #0d0f12;
    --ui-surface: #1a1e26;
    --ui-surface-2: #13161b;
    --ui-surface-hover: #20252f;
    --ui-surface-sunken: #0f1217;
    --ui-border: #262c38;
    --ui-border-strong: #3a4455;
    --ui-border-hover: #4a5568;
    --ui-text: #e8ecf2;
    --ui-text-2: #c3cad6;
    --ui-text-3: #7a8799;
    --ui-text-4: #4a5568;
    --ui-select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%237a8799' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.75' d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
    --ui-text-inverse: #0d0f12;
    --ui-accent: #4a90d9;
    --ui-accent-dark: #2a5a99;
    --ui-accent-tint: rgba(74, 144, 217, 0.16);
    --ui-focus: 0 0 0 3px rgba(74, 144, 217, 0.35);
    --ui-neutral-fg: #c3cad6;  --ui-neutral-bg: #20252f;  --ui-neutral-dot: #4a5568;
    --ui-info-fg: #7db4ec;     --ui-info-bg: #13243a;     --ui-info-dot: #4a90d9;
    --ui-success-fg: #4ade80;  --ui-success-bg: #0f2a1a;  --ui-success-dot: #22c55e;
    --ui-warning-fg: #fbbf24;  --ui-warning-bg: #2a1f08;  --ui-warning-dot: #f59e0b;
    --ui-danger-fg: #f87171;   --ui-danger-bg: #2a0f0f;   --ui-danger-dot: #ef4444;
    --ui-change-fg: #a78bfa;   --ui-change-bg: #1f1838;   --ui-change-dot: #7a5af8;
    --ui-info-border: #1e3a5c;
    --ui-success-border: #1a4a2a;
    --ui-warning-border: #4a3510;
    --ui-danger-border: #4a1a1a;
    --ui-shadow-xs: none;
    --ui-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --ui-shadow-lg: 0 12px 24px -6px rgba(0, 0, 0, 0.6);
    --ui-scrim: rgba(0, 0, 0, 0.55);
    --ui-scrim-strong: rgba(0, 0, 0, 0.7);
    background: var(--ui-bg);
    color: var(--ui-text);
}
