:root {
    color-scheme: light;
    --topbar: #37474f;
    --sidebar: #263238;
    --sidebar-active: #26a69a;
    --line: #dddddd;
    --soft-line: #eeeeee;
    --text: #333333;
    --muted: #999999;
    --primary: #5b94e5;
    --success: #65ad57;
    --danger: #ef6339;
    font-family: "Roboto", "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 13px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-width: 320px; min-height: 100%; color: var(--text); background: #fff; }
body { line-height: 1.5384616; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.portal-shell { min-height: 100vh; }
.topbar {
    position: fixed; z-index: 30; inset: 0 0 auto 0; display: flex; align-items: center;
    height: 46px; color: #fff; background: var(--topbar);
}
.brand { display: flex; align-items: center; width: 260px; height: 46px; padding: 0 20px; color: #fff; font-weight: 600; font-size: 14px; }
.sidebar-toggle { display: grid; gap: 3px; width: 46px; height: 46px; padding: 14px; border: 0; color: #fff; background: transparent; }
.sidebar-toggle span { display: block; height: 2px; background: currentColor; }
.account-menu { position: relative; margin-left: auto; height: 46px; }
.account-menu summary { display: flex; align-items: center; height: 46px; padding: 0 25px; list-style: none; cursor: pointer; font-weight: 600; }
.account-menu summary::-webkit-details-marker { display: none; }
.caret { margin-left: 5px; font-size: 12px; }
.account-dropdown { position: absolute; top: 46px; right: 12px; min-width: 130px; padding: 5px 0; border: 1px solid #d5d5d5; background: white; box-shadow: 0 3px 8px rgba(0,0,0,.16); }
.account-dropdown button { width: 100%; padding: 7px 15px; border: 0; color: #333; text-align: left; background: transparent; }
.account-dropdown button:hover { background: #f5f5f5; }

.portal-workspace { min-height: 100vh; padding-top: 46px; }
.sidebar { position: fixed; z-index: 20; inset: 46px auto 0 0; width: 260px; overflow: auto; background: var(--sidebar); transition: width .15s ease; }
.sidebar nav { padding-top: 13px; }
.sidebar-link { display: flex; align-items: center; min-height: 44px; padding: 10px 20px; color: #c8d0d4; white-space: nowrap; }
.sidebar-link:hover { color: #fff; background: rgba(255,255,255,.04); }
.sidebar-link.active { color: #fff; background: var(--sidebar-active); }
.portal-icon { width: 18px; height: 18px; flex: 0 0 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-link .portal-icon { margin-right: 15px; }
.sidebar-link .portal-icon circle { fill: currentColor; stroke: none; }
.page { min-height: calc(100vh - 46px); margin-left: 260px; padding: 20px 20px 60px; transition: margin-left .15s ease; }
.sidebar-collapsed .sidebar { width: 54px; }
.sidebar-collapsed .sidebar-link { padding-left: 18px; }
.sidebar-collapsed .sidebar-link span { display: none; }
.sidebar-collapsed .page { margin-left: 54px; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 34px; padding: 7px 12px; border: 1px solid transparent; border-radius: 2px; color: #333; background: #f5f5f5; }
.button:disabled { opacity: .55; cursor: default; }
.button.primary { color: #fff; background: var(--primary); }
.button.success { color: #fff; background: var(--success); font-weight: 500; }
.button.danger, .square-button.danger { color: #fff; background: var(--danger); }
.plus { margin-right: 6px; font-size: 23px; font-weight: 700; line-height: 12px; }

.data-table-shell { border: 1px solid var(--line); background: #fff; }
.table-toolbar { display: flex; align-items: center; min-height: 72px; padding: 19px 20px; border-bottom: 1px solid var(--line); }
.search-control { position: relative; width: 212px; }
.search-control input { width: 100%; height: 35px; padding: 7px 34px 7px 12px; border: 1px solid var(--line); }
.search-glyph { position: absolute; top: 5px; right: 10px; font-size: 23px; font-weight: 700; transform: rotate(-15deg); }
.filter-toggle { height: 35px; padding: 7px 12px; border: 0; background: transparent; }
.filter-caret { font-size: 9px; }
.toolbar-spacer { flex: 1; }
.page-size-label { margin-right: 13px; }
.page-size { width: 68px; height: 35px; padding: 6px 9px; border: 1px solid var(--line); background: #fff; }
.table-toolbar .button.success { margin-left: 20px; }
.legacy-filters { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) 2fr; gap: 20px; padding: 20px; border-bottom: 1px solid var(--line); background: #f5f5f5; }
.legacy-filters .reset-filter { align-self: end; justify-self: end; width: 150px; }
.field { display: flex; flex-direction: column; min-width: 0; }
.field label { display: block; margin-bottom: 6px; }
.field input, .field select, input, select { width: 100%; height: 35px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 2px; color: var(--text); background: #fff; }
.field input:focus, .field select:focus, input:focus, select:focus { outline: 0; border-color: #9dbfe9; box-shadow: 0 0 0 1px rgba(91,148,229,.15); }
.table-scroll { overflow-x: auto; }
.legacy-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.legacy-table th, .legacy-table td { padding: 13px 20px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; font-weight: 400; overflow-wrap: anywhere; }
.legacy-table th { height: 42px; }
.legacy-table tbody tr { height: 45px; }
.legacy-table tr.clickable { cursor: pointer; }
.legacy-table tr.clickable:hover { background: #fafafa; }
.companies-table th:nth-child(1), .companies-table td:nth-child(1) { width: 8.5%; }
.companies-table th:nth-child(2), .companies-table td:nth-child(2) { width: 20%; }
.companies-table th:nth-child(3), .companies-table td:nth-child(3) { width: 42%; }
.companies-table th:nth-child(4), .companies-table td:nth-child(4) { width: 19%; }
.companies-table th:nth-child(5), .companies-table td:nth-child(5) { width: 10.5%; }
.reports-table th:nth-child(1), .reports-table td:nth-child(1) { width: 4.5%; }
.reports-table th:nth-child(2), .reports-table td:nth-child(2) { width: 22%; }
.reports-table th:nth-child(3), .reports-table td:nth-child(3) { width: 15%; }
.reports-table th:nth-child(4), .reports-table td:nth-child(4) { width: 43%; }
.reports-table th:nth-child(5), .reports-table td:nth-child(5) { width: 7%; }
.reports-table th:nth-child(6), .reports-table td:nth-child(6) { width: 8.5%; }
.reports-table td:nth-child(4) { line-height: 1.45; }
.status { display: inline-block; padding: 2px 5px; border-radius: 2px; color: #fff; font-size: 10px; line-height: 16px; white-space: nowrap; background: #999; }
.status.active { background: #62ad55; }
.table-footer { display: flex; align-items: center; justify-content: space-between; min-height: 64px; padding: 12px 20px; color: #555; }
.pager { display: flex; align-items: center; gap: 2px; }
.pager button, .pager .page-ellipsis { display: grid; place-items: center; min-width: 32px; height: 32px; border: 0; border-radius: 3px; color: #333; background: transparent; }
.pager button:hover:not(:disabled):not(.active) { background: #f1f3f4; }
.pager button:disabled { color: #c5c5c5; cursor: default; }
.pager .page-number.active { color: #fff; background: #455a64; }
.pager .page-ellipsis { min-width: 24px; }
.report-toolbar { min-height: 72px; }

.legacy-editor-form { width: 100%; }
.editor-heading { padding: 19px 15px 17px; }
.editor-heading h1 { margin: 0 0 11px; font-size: 24px; line-height: 1.25; font-weight: 400; }
.editor-title-input { width: min(720px, 100%); height: auto; padding: 0; border: 0; border-bottom: 1px solid transparent; border-radius: 0; color: #333; background: transparent; font-size: 24px; font-weight: 400; }
.editor-title-input:focus { border-bottom-color: #9dbfe9; box-shadow: none; }
.switch-line { display: inline-flex; align-items: center; gap: 9px; }
.legacy-switch { position: relative; display: inline-block; width: 45px; min-width: 45px; height: 23px; flex: 0 0 auto; }
.legacy-switch input, .field .legacy-switch input { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; opacity: 0; }
.legacy-switch > span { position: absolute; inset: 0; border: 1px solid #ddd; border-radius: 14px; background: #fff; box-shadow: inset 0 1px 2px rgba(0,0,0,.06); transition: .15s; }
.legacy-switch > span::after { content: ""; position: absolute; top: 0; left: 0; width: 21px; height: 21px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.32); transition: .15s; }
.legacy-switch input:checked + span { border-color: var(--success); background: var(--success); }
.legacy-switch input:checked + span::after { left: 22px; }
.editor-panel { border: 1px solid var(--soft-line); background: #fff; }
.legacy-tabs { display: flex; height: 58px; padding-left: 20px; border-bottom: 1px solid var(--line); }
.legacy-tabs button { align-self: end; height: 39px; padding: 10px 15px; border: 1px solid transparent; border-bottom: 0; color: #999; background: transparent; }
.legacy-tabs button.active { color: #333; border-color: var(--line); background: #fff; }
.company-form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; padding: 20px; min-height: 455px; align-content: start; }
.company-form-grid .wide-3 { grid-column: span 3; }
.switch-field { min-height: 59px; }
.collection-field { align-items: flex-start; }
.compact-card { position: relative; display: grid; gap: 7px; width: 100%; max-width: 310px; padding: 10px 43px 10px 10px; margin-bottom: 8px; border: 1px solid var(--line); }
.compact-card .square-button { position: absolute; top: 10px; right: 0; }
.input-action-row { display: flex; width: 100%; margin-bottom: 6px; }
.input-action-row > input, .input-action-row > select { flex: 1; min-width: 0; }
.square-button { display: inline-grid; place-items: center; width: 40px; height: 35px; padding: 0; border: 0; border-radius: 2px; color: #fff; font-size: 24px; font-weight: 700; line-height: 1; }
.square-button.success { background: var(--success); }
.company-reports-grid { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(280px, 1fr) 2fr; gap: 20px; min-height: 175px; padding: 20px; }
.report-picker input { min-height: 94px; }
.form-actions { margin-top: 50px; }
.form-actions .button { min-width: 86px; }

.report-settings { padding: 20px; min-height: 690px; }
.report-editor-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.report-column { min-width: 0; }
.folder-list, .binding-list { margin-top: 37px; }
.binding-card { padding: 20px; margin-bottom: 20px; border: 1px solid var(--line); box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.binding-card .input-action-row { margin: 0 0 18px; }
.regions-list { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 7px; }
.region-chip { padding: 3px 7px; border: 1px solid #ddd; border-radius: 2px; background: #f7f7f7; }
.region-picker { display: flex; }
.region-picker select { flex: 1; min-width: 0; }
.region-picker button { padding: 0 9px; border: 1px solid var(--line); border-left: 0; background: #f5f5f5; }
.reserved-column { padding-top: 2px; color: #aaa; }
.reserved-column p { max-width: 310px; margin: 0; }

.alert { margin: 15px 0; padding: 10px 12px; border: 1px solid #efc0c0; }
.alert.error { color: #a94442; background: #f2dede; }
.empty-state { padding: 35px; color: #999; text-align: center; }

.login-page { min-height: 100vh; padding-top: 40px; background: #fff; }
.login-card { width: 320px; margin: 0 auto; padding: 27px 10px 40px; border: 1px solid #e5e5e5; border-radius: 2px; text-align: center; }
.login-icon { display: grid; place-items: center; width: 78px; height: 78px; margin: 0 auto 20px; border: 3px solid #9aa7ae; border-radius: 50%; color: #9aa7ae; }
.login-icon .portal-icon { width: 36px; height: 36px; stroke-width: 1.7; }
.login-heading { margin-bottom: 18px; }
.login-heading h1 { margin: 0 0 2px; font-size: 18px; font-weight: 400; }
.login-heading p { margin: 0; color: #999; }
.login-input { position: relative; margin-bottom: 18px; text-align: left; }
.login-input .portal-icon { position: absolute; z-index: 1; top: 9px; left: 11px; width: 16px; height: 16px; color: #999; }
.login-input input { height: 35px; padding-left: 36px; background: #edf3ff; }
.login-input label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.login-submit { width: 100%; }

.startup { display: grid; place-items: center; min-height: 70vh; color: #999; }
.startup-error { display: grid; justify-items: center; gap: 12px; color: #a94442; }
.startup-error p { margin: 0; }
#blazor-error-ui { display: none; position: fixed; z-index: 1000; inset: auto 20px 20px; padding: 10px 15px; color: #a94442; border: 1px solid #ebccd1; background: #f2dede; }
#blazor-error-ui .dismiss { float: right; border: 0; background: transparent; }
#blazor-error-ui .login-recovery { margin-left: 10px; padding: 4px 9px; color: #fff; border: 0; border-radius: 2px; background: var(--primary); cursor: pointer; }
.alert .session-login { margin-left: 12px; color: #fff; background: var(--primary); }

@media (max-width: 900px) {
    .brand { width: 210px; }
    .sidebar { width: 210px; }
    .page { margin-left: 210px; }
    .legacy-filters, .company-form-grid, .report-editor-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .company-form-grid .wide-3 { grid-column: span 1; }
    .reserved-column { display: none; }
}

@media (max-width: 620px) {
    .brand { width: auto; flex: 1; }
    .account-menu summary { max-width: 145px; overflow: hidden; text-overflow: ellipsis; }
    .sidebar { width: 54px; }
    .sidebar-link { padding-left: 18px; }
    .sidebar-link span { display: none; }
    .page { margin-left: 54px; padding: 10px; }
    .table-toolbar { flex-wrap: wrap; gap: 8px; }
    .toolbar-spacer { display: none; }
    .legacy-filters, .company-form-grid, .company-reports-grid, .report-editor-grid { grid-template-columns: 1fr; }
    .legacy-table { min-width: 780px; }
}
