:root {
    --erp-primary: #1F4E79;
    --erp-border: rgba(0, 0, 0, .10);
    --erp-muted: #5B6675;
    --erp-surface: #ffffff;
    --erp-bar: #1F4E79;
    --erp-bar-track: rgba(31, 78, 121, .08);
}

.mud-theme-dark, .mud-dark {
    --erp-border: rgba(255, 255, 255, .12);
    --erp-muted: #9AA7B6;
    --erp-surface: #18202B;
    --erp-bar: #6FA8DC;
    --erp-bar-track: rgba(111, 168, 220, .12);
}

html, body { font-family: Inter, "Segoe UI", Roboto, sans-serif; }

.erp-content { padding: 20px 24px 40px; max-width: 1600px; }
@media (max-width: 600px) { .erp-content { padding: 12px 16px 32px; } }

.erp-brand { font-weight: 700; letter-spacing: .02em; }
.erp-user-chip { background: rgba(255, 255, 255, .15) !important; color: inherit !important; }
.erp-drawer { border-right: 1px solid var(--erp-border); }
.erp-nav .mud-nav-link { font-size: .84rem; }

.erp-page-head { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: flex-end; margin-bottom: 16px; }

/* tables */
.erp-table-scroll { overflow-x: auto; }
.erp-table table { font-size: .82rem; }
.erp-table th { font-weight: 600; white-space: nowrap; color: var(--erp-muted); text-transform: uppercase; font-size: .7rem; letter-spacing: .04em; }
.erp-table td { vertical-align: middle; }
.erp-row { cursor: pointer; }
.erp-cell-title { font-weight: 600; }
.erp-cell-sub { color: var(--erp-muted); font-size: .75rem; }
.erp-empty { text-align: center; color: var(--erp-muted); padding: 24px !important; }
.erp-edit-table td { padding: 2px 6px !important; }
.erp-edit-table .mud-input-control { margin-top: 0; }
.erp-audit { font-size: .75rem; color: var(--erp-muted); max-width: 700px; }
.text-nowrap { white-space: nowrap; }
.text-right { text-align: right !important; }

.erp-status { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 500; }
.erp-status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--status); }

/* permission matrix */
.erp-matrix-scroll { max-height: 62vh; overflow: auto; }
.erp-matrix-group td { background: var(--erp-bar-track); font-weight: 600; font-size: .78rem; }
.erp-matrix .mud-checkbox { margin: 0; }

/* dashboard */
.erp-kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.erp-kpi { display: block; padding: 16px 18px; border: 1px solid var(--erp-border); border-radius: 8px; background: var(--erp-surface); color: inherit; text-decoration: none; transition: border-color .15s; }
.erp-kpi:hover { border-color: var(--erp-bar); }
.erp-kpi-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--erp-muted); }
.erp-kpi-value { font-size: 1.9rem; font-weight: 700; line-height: 1.2; margin-top: 4px; }
.erp-kpi-sub { font-size: .78rem; color: var(--erp-muted); }

.erp-bars { display: flex; flex-direction: column; gap: 8px; }
.erp-bar-row { display: grid; grid-template-columns: minmax(90px, 36%) 1fr 44px; align-items: center; gap: 10px; font-size: .8rem; }
.erp-bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.erp-bar-track { background: var(--erp-bar-track); border-radius: 4px; height: 14px; }
.erp-bar { background: var(--erp-bar); height: 100%; border-radius: 4px; }
.erp-bar-value { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

/* sign-in */
.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px;
    background: linear-gradient(135deg, #1F4E79 0%, #16395A 55%, #0F2A44 100%); font-family: Inter, "Segoe UI", sans-serif; }
.auth-card { width: 100%; max-width: 400px; background: #fff; border-radius: 12px; padding: 32px 28px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.auth-logo { width: 44px; height: 44px; border-radius: 10px; background: #1F4E79; color: #fff; font-weight: 700; font-size: 1.4rem; display: flex; align-items: center; justify-content: center; }
.auth-title { font-size: 1.25rem; font-weight: 700; color: #1C2430; }
.auth-sub { font-size: .8rem; color: #5B6675; }
.auth-form { display: flex; flex-direction: column; }
.auth-form label { font-size: .8rem; font-weight: 600; color: #1C2430; margin: 10px 0 4px; }
.auth-form input { padding: 10px 12px; border: 1px solid #C9D1DB; border-radius: 6px; font-size: .95rem; font-family: inherit; }
.auth-form input:focus { outline: 2px solid #1F4E79; outline-offset: 0; border-color: #1F4E79; }
.auth-form button { margin-top: 20px; padding: 11px; border: 0; border-radius: 6px; background: #1F4E79; color: #fff; font-weight: 600; font-size: .95rem; cursor: pointer; }
.auth-form button:hover { background: #16395A; }
.auth-error { margin-top: 12px; padding: 8px 10px; border-radius: 6px; background: #FDECEA; color: #B71C1C; font-size: .85rem; }

/* billing */
.erp-kpi-warn { border-left: 4px solid #EF6C00; }
.erp-kpi-danger { border-left: 4px solid #C62828; }
.erp-kpi-info { border-left: 4px solid #1565C0; }
.erp-amount-due { color: #C62828; font-weight: 600; }
.erp-amount-info { color: #1565C0; font-weight: 600; }
.erp-row-due td { background: rgba(239, 108, 0, .06); }
.mud-theme-dark .erp-amount-due, .mud-dark .erp-amount-due { color: #EF9A9A; }
.mud-theme-dark .erp-amount-info, .mud-dark .erp-amount-info { color: #90CAF9; }

/* letters */
.erp-editor { border: 1px solid var(--erp-border); border-radius: 6px; background: var(--erp-surface); }
.erp-editor-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 4px 6px; border-bottom: 1px solid var(--erp-border); }
.erp-editor-area { min-height: 360px; max-height: 70vh; overflow: auto; padding: 14px 18px; outline: none; font-family: "Segoe UI", Arial, sans-serif; font-size: 11pt; line-height: 1.45; color: #111; background: #fff; }
.erp-editor-ro .erp-editor-area { background: #fafafa; }
.erp-editor-area table { border-collapse: collapse; }
.erp-editor-area td, .erp-editor-area th { border: 1px solid #bbb; padding: 3px 6px; }
.erp-editor-source { width: 100%; min-height: 360px; font-family: Consolas, monospace; font-size: 12px; border: 0; padding: 10px; box-sizing: border-box; }
.erp-placeholders { max-height: 60vh; overflow: auto; border: 1px solid var(--erp-border); border-radius: 6px; }
.erp-placeholder { padding: 5px 8px; border-bottom: 1px solid var(--erp-border); cursor: pointer; display: flex; flex-direction: column; }
.erp-placeholder:hover { background: var(--erp-bar-track); }
.erp-placeholder code { font-size: .78rem; color: var(--erp-bar); }
.erp-placeholder span { font-size: .72rem; color: var(--erp-muted); }
.erp-letter-frame { width: 100%; height: 78vh; border: 1px solid var(--erp-border); border-radius: 6px; background: #fff; }
.erp-dl { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; margin: 0; font-size: .85rem; }
.erp-dl dt { color: var(--erp-muted); }
.erp-dl dd { margin: 0; }

/* notifications */
.erp-notify { width: 340px; max-height: 70vh; overflow: auto; }
.erp-notify-item { padding: 8px 12px; border-bottom: 1px solid var(--erp-border); cursor: pointer; }
.erp-notify-item:hover { background: var(--erp-bar-track); }
.erp-notify-item.unread { border-left: 3px solid var(--erp-bar); }
.auth-info { font-size: .85rem; color: #5B6675; margin-bottom: 4px; }
.auth-link { margin-top: 14px; text-align: center; font-size: .85rem; color: #1F4E79; text-decoration: none; }
.auth-link:hover { text-decoration: underline; }
.auth-success { padding: 10px 12px; border-radius: 6px; background: #E8F5E9; color: #1B5E20; font-size: .9rem; }
.auth-button-link { display: block; margin-top: 16px; padding: 11px; border-radius: 6px; background: #1F4E79; color: #fff; text-align: center; font-weight: 600; text-decoration: none; }
