/**
 * OMNISENTIENT Institutional Design Tokens v4.0 (Phase 1 Approved)
 * Strict standards for high-assurance, data-dense environments.
 */

:root {
    /* --- Foundation Palette (Slate/Zinc Deep Dark) --- */
    --color-bg-primary: #020617;
    /* Slate-950: The Void (Shell) */
    --color-bg-secondary: #0f172a;
    /* Slate-900: Deep Layer */
    --color-bg-card: #020617;
    /* Cards match background, separated by borders */
    --color-bg-surface: rgba(255, 255, 255, 0.03);
    /* Hover/Active states */
    --color-bg-surface-hover: rgba(255, 255, 255, 0.06);

    /* --- Status & Semantic Palette --- */
    --color-brand-primary: #6366f1;
    /* Indigo-500: System Actions */
    --color-brand-indigo-soft: rgba(99, 102, 241, 0.1);

    --color-success: #10b981;
    /* Emerald-500: Protected/Verified */
    --color-warning: #f59e0b;
    /* Amber-500: Scanning/At Risk */
    --color-error: #ef4444;
    /* Red-500: Breach/Danger */

    --color-success-dim: rgba(16, 185, 129, 0.15);
    --color-warning-dim: rgba(245, 158, 11, 0.15);
    --color-error-dim: rgba(239, 68, 68, 0.15);

    /* --- Typography Colors --- */
    --color-text-strong: #f8fafc;
    /* Slate-50: High Emphasis */
    --color-text-primary: #cbd5e1;
    /* Slate-300: Medium Emphasis */
    --color-text-muted: #94a3b8;
    /* Slate-400: Low Emphasis */
    --color-text-ghost: #64748b;
    /* Slate-500: Disabled/Meta */

    /* --- Borders & Dividers --- */
    --color-border-subtle: rgba(255, 255, 255, 0.08);
    --color-border-strong: rgba(255, 255, 255, 0.15);

    /* --- Spacing Rhythm (Strict 4px/8px baseline) --- */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-8: 48px;

    /* --- Border Radius --- */
    --r-sm: 4px;
    --r-md: 6px;
    --r-lg: 8px;

    /* --- Institutional Typography Scale --- */
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;

    --fs-h1: 24px;
    --fs-h2: 18px;
    --fs-h3: 14px;
    --fs-body: 13px;
    /* Dense Data Standard */
    --fs-small: 12px;
    --fs-micro: 11px;

    --lh-tight: 1.2;
    --lh-base: 1.5;
}

/* --- Foundation Overrides --- */
body {
    background-color: var(--color-bg-primary);
    color: var(--color-text-primary);
    font-family: var(--font-sans);
    font-size: var(--fs-body);
    line-height: var(--lh-base);
    -webkit-font-smoothing: antialiased;
}

/* --- Typography Utilities --- */
.t-h1 {
    font-size: var(--fs-h1);
    font-weight: 600;
    color: var(--color-text-strong);
    letter-spacing: -0.01em;
}

.t-h2 {
    font-size: var(--fs-h2);
    font-weight: 600;
    color: var(--color-text-strong);
}

.t-h3 {
    font-size: var(--fs-h3);
    font-weight: 600;
    color: var(--color-text-strong);
}

.t-body {
    font-size: var(--fs-body);
    color: var(--color-text-primary);
}

.t-small {
    font-size: var(--fs-small);
    color: var(--color-text-muted);
}

.t-micro {
    font-size: var(--fs-micro);
    color: var(--color-text-ghost);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.t-mono {
    font-family: var(--font-mono);
    font-size: 12px;
}

/* Status Utilities */
.text-success {
    color: var(--color-success) !important;
}

.text-warning {
    color: var(--color-warning) !important;
}

.text-danger {
    color: var(--color-error) !important;
}

.text-brand {
    color: var(--color-brand-primary) !important;
}

.text-ghost {
    color: var(--color-text-ghost) !important;
}

/* --- Strict Button System --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    /* Dense height */
    padding: 0 var(--space-3);
    border-radius: var(--r-sm);
    font-size: var(--fs-body);
    font-weight: 500;
    transition: all 0.15s ease;
    cursor: pointer;
    text-decoration: none;
    border: 1px solid transparent;
    gap: var(--space-2);
    white-space: nowrap;
}

.btn:disabled,
.btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Primary Action - Limited to ONE per context */
.btn-primary {
    background: var(--color-brand-primary);
    color: #ffffff;
}

.btn-primary:hover {
    filter: brightness(1.1);
}

/* Secondary Action */
.btn-secondary {
    background: transparent;
    border-color: var(--color-border-strong);
    color: var(--color-text-strong);
}

.btn-secondary:hover {
    background: var(--color-bg-surface);
}

/* Danger Action */
.btn-danger {
    background: var(--color-error-dim);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--color-error);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.25);
}

/* Ghost Action */
.btn-ghost {
    background: transparent;
    color: var(--color-text-muted);
}

.btn-ghost:hover {
    background: var(--color-bg-surface);
    color: var(--color-text-strong);
}

/* --- Container & Card Primitives --- */
.ui-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--r-md);
    padding: var(--space-5);
}

.data-table-container {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--r-md);
    background: var(--color-bg-card);
}

/* Linear-style data tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th {
    padding: var(--space-3) var(--space-4);
    font-size: var(--fs-micro);
    font-weight: 600;
    color: var(--color-text-ghost);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--color-border-subtle);
    background: rgba(255, 255, 255, 0.01);
    white-space: nowrap;
}

.data-table td {
    padding: var(--space-3) var(--space-4);
    font-size: var(--fs-body);
    color: var(--color-text-primary);
    border-bottom: 1px solid var(--color-border-subtle);
    vertical-align: middle;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover {
    background: var(--color-bg-surface);
}

/* --- Severity / Status Chips --- */
.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: 1px solid transparent;
}

.status-chip::before {
    content: "";
    display: block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.status-chip.success {
    background: var(--color-success-dim);
    color: var(--color-success);
    border-color: rgba(16, 185, 129, 0.2);
}

.status-chip.success::before {
    background: var(--color-success);
}

.status-chip.warning {
    background: var(--color-warning-dim);
    color: var(--color-warning);
    border-color: rgba(245, 158, 11, 0.2);
}

.status-chip.warning::before {
    background: var(--color-warning);
}

.status-chip.danger {
    background: var(--color-error-dim);
    color: var(--color-error);
    border-color: rgba(239, 68, 68, 0.2);
}

.status-chip.danger::before {
    background: var(--color-error);
}

.status-chip.neutral {
    background: var(--color-bg-surface);
    color: var(--color-text-muted);
    border-color: var(--color-border-subtle);
}

.status-chip.neutral::before {
    background: var(--color-text-ghost);
}

/* --- App Shell Layout Specifics --- */
.shell-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.shell-sidebar {
    width: 240px;
    background: var(--color-bg-card);
    border-right: 1px solid var(--color-border-subtle);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.shell-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--color-bg-primary);
}

.shell-header {
    height: 56px;
    /* Dense header */
    border-bottom: 1px solid var(--color-border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-6);
    background: var(--color-bg-card);
    flex-shrink: 0;
}

.shell-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-6);
}

/* States */
.state-empty,
.state-degraded {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-8);
    text-align: center;
    border: 1px dashed var(--color-border-strong);
    border-radius: var(--r-md);
    background: rgba(255, 255, 255, 0.01);
}

.state-icon {
    font-size: 32px;
    color: var(--color-text-ghost);
    margin-bottom: var(--space-4);
}

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