/* ── Design tokens (matching etransactionM1) ──────────────────── */
:root {
    --bg:        #f7f9fc;
    --surface:   #ffffff;
    --surface-2: #f1f5f9;
    --fg:        #0f172a;
    --muted:     #475569;
    --brand:     #0b67d0;
    --brand-600: #0a5ab6;
    --brand-700: #084a96;
    --ok:        #15803d;
    --warn:      #b45309;
    --danger:    #b91c1c;
    --radius:    10px;
    --border:    #d4d8e1;
    --shadow:    0 1px 2px rgba(15,23,42,.06), 0 6px 20px rgba(15,23,42,.06);
    --shadow-lg: 0 4px 6px rgba(15,23,42,.07), 0 12px 28px rgba(15,23,42,.10);
}

/* ── Base ─────────────────────────────────────────────────────── */
html, body {
    font-family: 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 14px;
    color: var(--fg);
    background: var(--bg);
    margin: 0; padding: 0; height: 100%;
}

/* ── Shell layout ─────────────────────────────────────────────── */
.rui-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────────── */
.rui-sidebar {
    width: 230px;
    flex-shrink: 0;
    background: #0f172a;
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.rui-logo {
    padding: 1.25rem 1rem;
    font-size: 1rem;
    font-weight: 700;
    color: #f8fafc;
    border-bottom: 1px solid #1e293b;
    letter-spacing: .01em;
}

.rui-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    background: var(--bg);
}

/* ── Nav ──────────────────────────────────────────────────────── */
.rui-nav {
    list-style: none;
    padding: .5rem 0;
    margin: 0;
    flex: 1;
}

.rui-nav li { margin: 0; }

.rui-nav-section {
    padding: .75rem 1rem .2rem;
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: #475569;
}

.rui-nav-link {
    display: flex;
    align-items: center;
    padding: .45rem 1rem;
    color: #94a3b8;
    text-decoration: none;
    font-size: .82rem;
    font-weight: 500;
    border-radius: 6px;
    margin: 1px 6px;
    transition: background .15s, color .15s;
}

.rui-nav-link:hover, .rui-nav-link.active {
    background: #1e3a5f;
    color: #f1f5f9;
}

/* ── Sidebar footer (user block) ──────────────────────────────── */
.rui-sidebar-footer {
    padding: .85rem 1rem;
    border-top: 1px solid #1e293b;
    display: flex;
    align-items: center;
    gap: .65rem;
    cursor: pointer;
    transition: background .15s;
}

.rui-sidebar-footer:hover { background: #1e293b; }

.rui-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    font-size: .75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.rui-user-avatar-lg {
    width: 44px;
    height: 44px;
    font-size: .95rem;
}

.rui-sidebar-footer-info { flex: 1; min-width: 0; }
.rui-user  { color: #f1f5f9; font-weight: 600; font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rui-org   { color: #64748b; font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.rui-footer-more { color: #64748b; font-size: 1rem; flex-shrink: 0; }

/* ── User popup ───────────────────────────────────────────────── */
.rui-popup-backdrop {
    position: fixed; inset: 0; z-index: 900;
}

.rui-user-popup {
    position: fixed;
    bottom: 5rem;
    left: 1rem;
    width: 220px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 910;
    padding: .5rem 0;
}

.rui-user-popup-hdr {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1rem;
}

.rui-user-popup-name { font-weight: 700; font-size: .875rem; color: var(--fg); }
.rui-user-popup-org  { font-size: .75rem; color: var(--muted); }
.rui-user-popup-pkg  { font-size: .7rem; color: var(--brand); font-weight: 600; margin-top: 1px; }
.rui-user-popup-divider { height: 1px; background: var(--border); margin: .25rem 0; }

.rui-user-popup-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: .5rem 1rem;
    background: none;
    border: none;
    font-size: .82rem;
    color: var(--fg);
    cursor: pointer;
    text-align: left;
    transition: background .12s;
}

.rui-user-popup-item:hover { background: var(--surface-2); }
.rui-user-popup-danger, .rui-user-popup-danger:hover { color: var(--danger) !important; }

/* ── Page header ──────────────────────────────────────────────── */
.rui-page-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: .75rem;
}

.rui-page-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--fg);
}

/* ── Cards ────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border) !important;
    border-radius: 14px !important;
    box-shadow: var(--shadow);
}

.card-header {
    background: var(--surface-2) !important;
    border-bottom: 1px solid var(--border) !important;
    border-radius: 14px 14px 0 0 !important;
    padding: .65rem 1rem !important;
    font-weight: 600;
    font-size: .875rem;
    color: var(--fg);
}

/* ── Filter bar ───────────────────────────────────────────────── */
.rui-filter-bar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: .85rem 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

/* ── KPI cards ────────────────────────────────────────────────── */
.rui-kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.1rem 1.25rem;
    border-left: 4px solid var(--border);
    box-shadow: var(--shadow);
    transition: box-shadow .15s;
}

.rui-kpi-card:hover { box-shadow: var(--shadow-lg); }
.rui-kpi-blue   { border-left-color: #3b82f6; }
.rui-kpi-green  { border-left-color: #22c55e; }
.rui-kpi-teal   { border-left-color: #14b8a6; }
.rui-kpi-orange { border-left-color: #f97316; }
.rui-kpi-purple { border-left-color: #a855f7; }

.rui-kpi-label { font-size: .75rem; font-weight: 600; color: var(--muted); margin-bottom: .3rem; text-transform: uppercase; letter-spacing: .04em; }
.rui-kpi-value { font-size: 1.5rem; font-weight: 700; color: var(--fg); line-height: 1.2; }

/* ── Shortcut cards ───────────────────────────────────────────── */
.rui-shortcut-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.5rem 1rem;
    text-decoration: none;
    color: var(--fg);
    gap: .5rem;
    box-shadow: var(--shadow);
    transition: box-shadow .15s, transform .1s;
}

.rui-shortcut-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
    color: var(--fg);
}

.rui-shortcut-icon { font-size: 2rem; color: var(--brand); }

/* ── Login ────────────────────────────────────────────────────── */
.rui-login-wrap {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.rui-login-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 2.25rem 2rem;
    width: 100%;
    max-width: 390px;
    box-shadow: 0 20px 60px rgba(0,0,0,.35);
}

.rui-login-logo {
    text-align: center;
    margin-bottom: 1.75rem;
}

.rui-login-logo .bi {
    font-size: 2.5rem;
    color: var(--brand);
    display: block;
    margin-bottom: .5rem;
}

/* ── Pivot field panel ────────────────────────────────────────── */
.rui-pivot-fieldpanel {
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
}

/* ── Pivot field chips ────────────────────────────────────────── */
.rui-field-group {
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--muted);
    letter-spacing: .08em;
    margin: .75rem 0 .25rem;
}

.rui-field-chip {
    display: inline-block;
    padding: .2rem .65rem;
    border-radius: 9999px;
    font-size: .775rem;
    font-weight: 500;
    margin: .15rem;
    cursor: grab;
    user-select: none;
    transition: opacity .15s;
}

.rui-field-dim     { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
.rui-field-dim:hover { background: #bfdbfe; }
.rui-field-measure { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; cursor: default; }

/* ── Pivot drop zone ──────────────────────────────────────────── */
.rui-dropzone {
    min-height: 52px;
    border: 2px dashed var(--border);
    border-radius: 10px;
    padding: .5rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .25rem;
    transition: border-color .2s, background .2s;
}

.rui-dropzone:hover, .rui-dropzone--active {
    border-color: var(--brand);
    background: #eff6ff;
}

/* ── Pivot grouped table ──────────────────────────────────────── */
.rui-pivot-group td { background: #f1f5f9 !important; }

.rui-pivot-toggle {
    background: none;
    border: none;
    padding: 0 .25rem 0 0;
    cursor: pointer;
    color: var(--brand);
    font-size: .75rem;
    line-height: 1;
    vertical-align: middle;
}

.rui-pivot-toggle:hover { color: var(--brand-700); }

.rui-pivot-table {
    font-size: .72rem;
    table-layout: fixed;
    width: 100%;
}

.rui-pivot-th-measure {
    width: 75px;
    min-width: 55px;
    text-align: center;
    vertical-align: bottom;
    white-space: normal;
    word-break: break-word;
    line-height: 1.2;
    resize: horizontal;
    overflow: auto;
}

.rui-pivot-th-dim {
    width: 110px;
    min-width: 70px;
    text-align: center;
    vertical-align: bottom;
    white-space: normal;
    word-break: break-word;
    line-height: 1.2;
    resize: horizontal;
    overflow: auto;
}

.rui-pivot-table td {
    text-align: center;
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rui-pivot-td-group { text-align: left !important; }

/* ── Export bar ───────────────────────────────────────────────── */
.rui-export-bar { display: inline-flex; align-items: center; margin-left: auto; }

/* ── Print ────────────────────────────────────────────────────── */
@media print {
    .rui-sidebar,
    .rui-filter-bar,
    .rui-export-bar,
    #blazor-error-ui          { display: none !important; }

    .rui-shell                { display: block !important; height: auto !important; overflow: visible !important; }
    .rui-content              { padding: .5rem !important; overflow: visible !important; background: #fff !important; }
    .rui-page-header          { border-bottom: 1px solid #000 !important; margin-bottom: .5rem !important; }

    .card                     { border: none !important; box-shadow: none !important; }
    .btn, .btn-group          { display: none !important; }
    .badge                    { border: 1px solid #000 !important; color: #000 !important; background: #fff !important; }
    a                         { text-decoration: none !important; color: #000 !important; }

    table                     { width: 100% !important; border-collapse: collapse !important; font-size: .75rem !important; }
    thead th                  { background: #1e293b !important; color: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    td, th                    { border: 1px solid #cbd5e1 !important; padding: .2rem .4rem !important; }
}

/* ── Misc ─────────────────────────────────────────────────────── */
.valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; }
.invalid { outline: 1px solid #e11d48; }

#blazor-error-ui {
    background: #fff3cd;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0,0,0,.2);
    display: none;
    left: 0;
    padding: .6rem 1.25rem .7rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }
