/* Ethical Amplifier — Global UI foundation
 * Scope: tokens and reusable components only.
 * Shell geometry belongs to ea-shell-compact.css.
 */

:root {
    --ea-primary: #7c3aed;
    --ea-primary-hover: #6d28d9;
    --ea-primary-soft: #f5f3ff;
    --ea-text: #0f172a;
    --ea-muted: #64748b;
    --ea-subtle: #94a3b8;
    --ea-bg: #f6f7fb;
    --ea-surface: #ffffff;
    --ea-surface-soft: #f8fafc;
    --ea-border: #e7e5eb;
    --ea-border-strong: #d8d5df;
    --ea-success: #16a34a;
    --ea-warning: #d97706;
    --ea-danger: #dc2626;
    --ea-info: #0284c7;
    --ea-radius-sm: 10px;
    --ea-radius-md: 16px;
    --ea-radius-lg: 20px;
    --ea-shadow-sm: 0 4px 14px rgba(15, 23, 42, .035);
    --ea-shadow-md: 0 12px 32px rgba(15, 23, 42, .06);
    --ea-focus: 0 0 0 .2rem rgba(124, 58, 237, .14);
}

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

html { color-scheme: light; }

body {
    margin: 0;
    color: var(--ea-text);
    background: var(--ea-bg);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
        "Segoe UI", sans-serif;
    font-size: .875rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--ea-primary); }
a:hover { color: var(--ea-primary-hover); }
button, input, select, textarea { font: inherit; }

/* Compatibility tokens/classes retained for existing views. */
.ea-accent { color: var(--ea-primary) !important; }
.ea-sub, .ea-footer { color: var(--ea-muted); font-size: .75rem; }
.ea-kpi { color: var(--ea-text); font-size: 1.35rem; font-weight: 750; }
.ea-logo-img { display: block; width: auto; height: 42px; }
.ea-logo-img-lg, .ea-logo-login { height: 56px; }

/* Buttons */
.btn {
    border-radius: var(--ea-radius-sm);
    font-size: .78rem;
    font-weight: 650;
    box-shadow: none;
}

.btn-sm { min-height: 34px; padding: .36rem .7rem; }

.btn-primary, .ea-btn {
    color: #fff;
    background: var(--ea-primary);
    border-color: var(--ea-primary);
}

.btn-primary:hover, .btn-primary:focus, .ea-btn:hover {
    color: #fff;
    background: var(--ea-primary-hover);
    border-color: var(--ea-primary-hover);
}

.btn-outline-primary { color: var(--ea-primary); border-color: #c4b5fd; }
.btn-outline-primary:hover { color: #fff; background: var(--ea-primary); border-color: var(--ea-primary); }
.btn:focus-visible { box-shadow: var(--ea-focus); }
.ea-btn-pill { padding-inline: 14px; border-radius: 999px; }

/* Forms */
.form-label { margin-bottom: .35rem; color: #334155; font-size: .72rem; font-weight: 700; }
.form-control, .form-select, .input-group-text {
    min-height: 38px;
    border-color: var(--ea-border-strong);
    border-radius: var(--ea-radius-sm);
    font-size: .78rem;
}
.form-control, .form-select { color: var(--ea-text); background-color: #fff; }
.form-control::placeholder { color: var(--ea-subtle); }
.form-control:focus, .form-select:focus {
    border-color: #a78bfa;
    box-shadow: var(--ea-focus);
}
.input-group-text { color: var(--ea-muted); background: var(--ea-surface-soft); }
.input-group > :not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.input-group > :not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }

/* Surfaces */
.card, .ea-card {
    color: var(--ea-text);
    background: var(--ea-surface);
    border: 1px solid var(--ea-border);
    border-radius: var(--ea-radius-md);
    box-shadow: var(--ea-shadow-sm);
}
.ea-card { padding: 1rem; }
.card-header, .card-footer { background: transparent; border-color: #f0eef3; }

/* Page hierarchy */
.ea-page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}
.ea-page-title { min-width: 0; }
.ea-brand { margin: 0; color: var(--ea-text); font-size: 1.35rem; font-weight: 780; letter-spacing: -.025em; }
.ea-section-title { margin: 0; color: var(--ea-text); font-size: .92rem; font-weight: 750; letter-spacing: -.01em; }
.ea-section-sub { margin: 3px 0 0; color: var(--ea-muted); font-size: .74rem; line-height: 1.45; }

/* Compact filters and toolbars */
.ea-filterbar { min-width: 0; overflow-x: auto; scrollbar-width: thin; }
.ea-filterform, .ea-toolbar, .ea-toolbar-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.ea-filterform, .ea-toolbar-row { flex-wrap: nowrap; white-space: nowrap; }
.ea-toolbar-scroll { min-width: 0; flex: 1 1 auto; overflow-x: auto; overflow-y: hidden; }
.ea-toolbar-title { flex: 0 0 auto; font-weight: 750; }
.ea-toolbar-row > * { flex: 0 0 auto; width: auto; }
.ea-toolbar-row .ea-search { min-width: 240px; flex: 1 1 300px !important; }
.ea-input-w { width: 210px; }
.ea-select-w { width: 160px; }
.ea-w-130 { width: 130px !important; }
.ea-w-150 { width: 150px !important; }
.ea-w-180 { width: 180px !important; }

/* KPI compatibility */
.ea-kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.ea-kpi-card { position: relative; overflow: hidden; padding: 14px 16px; border-radius: var(--ea-radius-md); }
.ea-kpi-card::after { content: ""; position: absolute; inset: auto 0 0; height: 3px; background: var(--ea-primary); opacity: .7; }
.ea-kpi-head { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.ea-kpi-icon { color: var(--ea-primary); font-size: 1rem; }
.ea-kpi-label { color: var(--ea-muted); font-size: .67rem; font-weight: 700; letter-spacing: .055em; text-transform: uppercase; }
.ea-kpi-value { color: var(--ea-text); font-size: 1.65rem; font-weight: 760; line-height: 1.15; }
.ea-kpi-meta { margin-top: 4px; color: var(--ea-muted); font-size: .72rem; }
.ea-kpi-danger::after { background: var(--ea-danger); }
.ea-kpi-success::after { background: var(--ea-success); }
.ea-kpi-info::after { background: var(--ea-info); }
.ea-kpi-primary::after { background: var(--ea-primary); }
.ea-kpi-pos { border-left: 3px solid var(--ea-pos, #22c55e); }
.ea-kpi-net { border-left: 3px solid var(--ea-net, #3b82f6); }
.ea-kpi-neg { border-left: 3px solid var(--ea-neg, #ef4444); }
.ea-kpi-mini { min-height: 104px; }
.ea-kpi-big { grid-column: 4; grid-row: 1 / span 2; min-height: 232px; }
.ea-spark-wrap { width: 100%; height: 72px; padding: 8px; border-radius: 12px; background: var(--ea-surface-soft); }
.ea-card canvas { display: block; max-width: 100%; }

/* Tables and DataTables */
.table { --bs-table-color: var(--ea-text); --bs-table-bg: transparent; margin-bottom: 0; font-size: .76rem; }
.table > :not(caption) > * > * { padding: .7rem .75rem; border-bottom-color: #eef0f4; vertical-align: middle; }
.table thead th { color: var(--ea-muted); background: #fafbfc; font-size: .66rem; font-weight: 750; letter-spacing: .045em; text-transform: uppercase; white-space: nowrap; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: #faf8ff; }
.table-responsive { border-radius: 14px; }
.dataTables_wrapper .dataTables_info, .dataTables_wrapper .dataTables_length, .dataTables_wrapper .dataTables_filter { color: var(--ea-muted); font-size: .72rem; }
.page-link { color: var(--ea-primary); border-color: var(--ea-border); font-size: .72rem; }
.active > .page-link, .page-link.active { background: var(--ea-primary); border-color: var(--ea-primary); }

/* Modal: one coherent Bootstrap layer; no extreme z-index hacks. */
.modal { z-index: 1060; }
.modal-backdrop { z-index: 1055; }
.modal-dialog { pointer-events: none; }
.modal-content {
    color: var(--ea-text);
    background: #fff;
    border: 1px solid var(--ea-border);
    border-radius: var(--ea-radius-lg);
    box-shadow: 0 24px 70px rgba(15, 23, 42, .18);
}
.modal-header, .modal-footer { padding: 14px 16px; border-color: #f0eef3; }
.modal-body { padding: 16px; }
.modal-title { font-size: .95rem; font-weight: 750; }
body.modal-open .ea-sidebar-backdrop { display: none !important; pointer-events: none !important; }

/* Center header */
.ea-center-header {
    --ea-center-accent: var(--ea-primary);
    position: relative;
    overflow: hidden;
    margin: 0 0 12px;
    padding: 14px 16px;
    background: linear-gradient(120deg, color-mix(in srgb, var(--ea-center-accent) 7%, #fff), #fff 38%);
    border: 1px solid var(--ea-border);
    border-radius: var(--ea-radius-md);
    box-shadow: var(--ea-shadow-sm);
}
.ea-center-header::before { content: ""; position: absolute; top: 0; left: 18px; width: 64px; height: 3px; background: var(--ea-center-accent); border-radius: 0 0 999px 999px; }
.ea-center-header-main { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.ea-center-header-identity { display: flex; min-width: 0; align-items: center; gap: 12px; }
.ea-center-header-icon { display: grid; width: 42px; height: 42px; flex: 0 0 42px; place-items: center; color: var(--ea-center-accent); background: color-mix(in srgb, var(--ea-center-accent) 9%, #fff); border: 1px solid color-mix(in srgb, var(--ea-center-accent) 18%, #fff); border-radius: 13px; }
.ea-center-header-copy { min-width: 0; }
.ea-center-breadcrumb { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; color: var(--ea-subtle); font-size: .62rem; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; }
.ea-center-breadcrumb-parent { color: var(--ea-center-accent); }
.ea-center-breadcrumb-current { overflow: hidden; color: var(--ea-muted); text-overflow: ellipsis; white-space: nowrap; }
.ea-center-title-row { display: flex; align-items: center; gap: 8px; }
.ea-center-title { margin: 0; overflow: hidden; color: var(--ea-text); font-size: clamp(1.08rem, 2vw, 1.32rem); font-weight: 760; letter-spacing: -.025em; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
.ea-center-title-accent { width: 6px; height: 6px; flex: 0 0 6px; background: var(--ea-center-accent); border-radius: 50%; box-shadow: 0 0 0 4px color-mix(in srgb, var(--ea-center-accent) 12%, transparent); }
.ea-center-description { max-width: 820px; margin: 4px 0 0; color: var(--ea-muted); font-size: .74rem; line-height: 1.45; }
.ea-center-header-actions { display: flex; flex: 0 0 auto; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 7px; }
.ea-center-header-actions .btn { min-height: 34px; padding-inline: 12px; }
.ea-center-header-actions .dropdown-menu { padding: 7px; border: 1px solid var(--ea-border); border-radius: 13px; box-shadow: var(--ea-shadow-md); }
.ea-center-header-actions .dropdown-item { padding: 8px 10px; color: #334155; border-radius: 8px; font-size: .74rem; font-weight: 600; }

/* Feedback */
.ea-flash-alert { position: relative; display: flex; align-items: flex-start; gap: 10px; margin: 0 0 12px; padding: 11px 42px 11px 12px; overflow: hidden; border-width: 1px; border-radius: 14px; box-shadow: var(--ea-shadow-sm); }
.ea-flash-alert::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: currentColor; opacity: .7; }
.ea-flash-icon { display: grid; width: 30px; height: 30px; flex: 0 0 30px; place-items: center; background: rgba(255,255,255,.6); border-radius: 9px; }
.ea-flash-title { display: block; font-size: .72rem; font-weight: 750; }
.ea-flash-message { margin-top: 2px; color: #475569; font-size: .72rem; }
.ea-flash-alert.alert-success { color: #15803d; background: #f0fdf4; border-color: #bbf7d0; }
.ea-flash-alert.alert-danger { color: #b91c1c; background: #fef2f2; border-color: #fecaca; }
.ea-flash-alert.alert-warning { color: #b45309; background: #fffbeb; border-color: #fde68a; }
.ea-flash-alert.alert-info { color: #0369a1; background: #f0f9ff; border-color: #bae6fd; }

/* Login remains independent from the application shell. */
.ea-login-bg { min-height: 100vh; background: radial-gradient(circle at 16% 12%, rgba(124,58,237,.15), transparent 30%), linear-gradient(135deg, #f8fafc, #fff); }
.ea-login-card { border-radius: 20px; }
.ea-logo-mark { width: 42px; height: 42px; border-radius: 14px; background: linear-gradient(135deg, #7c3aed, #4f46e5); }

@media (max-width: 1199.98px) {
    .ea-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ea-kpi-big { grid-column: 1 / -1; grid-row: auto; min-height: 200px; }
}

@media (max-width: 767.98px) {
    .ea-page-head { flex-direction: column; }
    .ea-filterbar { width: 100%; }
    .ea-filterform { flex-wrap: wrap; }
    .ea-filterform > * { flex: 1 1 150px; }
    .ea-center-header { padding: 13px; }
    .ea-center-header-main { align-items: stretch; flex-direction: column; }
    .ea-center-header-identity { align-items: flex-start; }
    .ea-center-title { white-space: normal; }
    .ea-center-header-actions { width: 100%; justify-content: flex-start; }
}

@media (max-width: 575.98px) {
    .ea-kpi-grid { grid-template-columns: 1fr; }
    .ea-toolbar-row .ea-search { min-width: 190px; }
    .ea-center-header-actions, .ea-center-header-actions > *, .ea-center-header-actions form, .ea-center-header-actions .btn { width: 100%; }
}

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