:root {
  color-scheme: light;
  --ink: #202a35;
  --muted: #78838f;
  --line: #e8ebee;
  --paper: #fff;
  --canvas: #f5f6f8;
  --blue: #2874e8;
  --blue-dark: #1d5fc6;
  --blue-pale: #edf4ff;
  --green: #2ca66f;
  --red: #d34b50;
  --amber: #c08325;
  --shadow: 0 14px 36px rgba(27, 39, 54, .055);
  font-family: "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--canvas); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 11px; color: var(--blue); font-size: 10px; font-weight: 800; letter-spacing: .16em; }

.login-layout { display: grid; min-height: 100vh; place-items: center; background: var(--paper); }
.brand-mark { display: grid; width: 44px; height: 44px; flex: 0 0 auto; place-items: center; border-radius: 14px; color: #fff; background: linear-gradient(145deg, #58a0ff, #2670e7); box-shadow: 0 6px 16px rgba(24,93,195,.23); font-family: "Manrope", sans-serif; font-size: 22px; font-weight: 800; }
.login-panel { display: grid; width: 100%; min-height: 100vh; place-items: center; padding: 32px; }
.login-card { width: min(390px, 100%); }
.login-card h2 { margin: 0; font-family: "Manrope", sans-serif; font-size: 30px; letter-spacing: -.035em; }
.login-card .muted { margin: 8px 0 31px; font-size: 14px; }
label { display: block; margin: 0 0 8px; color: #34404d; font-size: 12px; font-weight: 700; }
input, select, textarea { width: 100%; min-height: 42px; padding: 10px 12px; border: 1px solid #dfe4e9; border-radius: 8px; outline: none; color: var(--ink); background: #fff; transition: border-color .16s, box-shadow .16s; }
input:focus, select:focus, textarea:focus { border-color: #83b1f5; box-shadow: 0 0 0 3px rgba(40,116,232,.11); }
textarea { min-height: 76px; resize: vertical; }
.login-card input { height: 47px; margin-bottom: 20px; }
.login-card label { margin-bottom: 8px; }
.button { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; gap: 9px; padding: 0 15px; border: 1px solid transparent; border-radius: 8px; font-size: 12px; font-weight: 700; transition: background .16s, transform .16s, border-color .16s; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .48; }
.button.primary { color: #fff; background: var(--blue); box-shadow: 0 5px 12px rgba(40,116,232,.16); }
.button.primary:hover:not(:disabled) { background: var(--blue-dark); }
.button.secondary { border-color: #e3e7ec; color: #4a5663; background: #fff; }
.button.secondary:hover { border-color: #c8d1dc; background: #fafbfd; }
.button.full { width: 100%; height: 46px; }
.login-card .button { margin-top: 4px; }
.login-card .button span { margin-left: auto; font-size: 17px; }
.form-error { min-height: 17px; margin: 8px 0 0; color: var(--red); font-size: 12px; }
.login-note { margin: 14px 0 0; color: #8a939d; text-align: center; font-size: 11px; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar { position: fixed; z-index: 4; display: flex; width: 242px; height: 100vh; flex-direction: column; padding: 24px 15px 16px; border-right: 1px solid var(--line); background: #fff; }
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 29px; color: var(--ink); text-decoration: none; }
.sidebar-brand strong { display: block; font-family: "Manrope", sans-serif; font-size: 16px; letter-spacing: -.03em; }
.sidebar-brand small { display: block; margin-top: 3px; color: #96a0aa; font-size: 8px; font-weight: 700; letter-spacing: .11em; }
.nav-caption { margin: 4px 11px 9px; color: #a0a9b2; font-size: 9px; font-weight: 800; letter-spacing: .15em; }
.main-nav { display: grid; gap: 4px; }
.nav-item { display: flex; min-height: 42px; align-items: center; gap: 11px; padding: 0 11px; border: 0; border-radius: 8px; color: #697582; background: transparent; text-align: left; font-size: 12px; font-weight: 600; }
.nav-item:hover { color: #334154; background: #f6f8fb; }
.nav-item.active { color: var(--blue); background: var(--blue-pale); font-weight: 700; }
.nav-icon { display: grid; width: 19px; place-items: center; font-size: 17px; }
.sidebar-bottom { margin-top: auto; }
.help-card { display: grid; grid-template-columns: 27px 1fr; gap: 4px 8px; padding: 13px 10px; border: 1px solid #e8edf5; border-radius: 10px; background: #f9fbfe; }
.help-symbol { display: grid; width: 24px; height: 24px; grid-row: span 2; place-items: center; border-radius: 8px; color: var(--blue); background: var(--blue-pale); font-size: 13px; font-weight: 800; }
.help-card strong { align-self: end; font-size: 11px; }
.help-card span:last-child { color: var(--muted); font-size: 9px; line-height: 1.5; }
.sidebar-version { display: flex; justify-content: space-between; margin: 15px 4px 0; color: #98a2ad; font-size: 10px; }
.sidebar-version span { color: #b1bac3; }
.workspace { width: calc(100% - 242px); min-height: 100vh; margin-left: 242px; }
.topbar { position: sticky; z-index: 3; top: 0; display: flex; height: 61px; align-items: center; justify-content: space-between; padding: 0 34px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(12px); }
.breadcrumbs { display: flex; align-items: center; gap: 10px; color: #919ba5; font-size: 11px; }
.breadcrumbs b { color: #c1c8cf; font-weight: 400; }
.breadcrumbs strong { color: #384453; font-weight: 700; }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.user-copy { text-align: right; }
.user-copy strong, .user-copy span { display: block; }
.user-copy strong { font-size: 11px; }
.user-copy span { margin-top: 2px; color: #89939d; font-size: 9px; }
.avatar { display: grid; width: 31px; height: 31px; place-items: center; border-radius: 50%; color: #2874e8; background: #e9f1ff; font-size: 12px; font-weight: 800; }
.icon-button { display: grid; width: 32px; height: 32px; place-items: center; border: 0; border-radius: 7px; color: #818d98; background: transparent; font-size: 19px; }
.icon-button:hover { color: var(--ink); background: #f2f4f7; }
.page-content { max-width: 1440px; margin: 0 auto; padding: 31px 34px 50px; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 21px; }
.page-heading h1 { margin: 0; font-family: "Manrope", sans-serif; font-size: 26px; letter-spacing: -.045em; }
.page-heading .muted { margin: 6px 0 0; font-size: 12px; }
.panel { border: 1px solid var(--line); border-radius: 11px; background: var(--paper); box-shadow: var(--shadow); }
.filter-panel { display: flex; align-items: end; gap: 14px; padding: 13px 15px; }
.filter-group { width: 180px; }
.filter-group label { margin-bottom: 6px; color: #7a8591; font-size: 10px; }
.filter-group select { min-height: 37px; padding: 7px 10px; font-size: 11px; }
.filter-refresh { margin-left: auto; min-height: 37px; }
.results-heading { display: flex; align-items: center; justify-content: space-between; margin: 20px 2px 10px; }
.results-heading strong { font-size: 12px; }
.results-heading span { font-size: 10px; }
.request-list { display: grid; gap: 10px; }
.request-card { padding: 15px 17px; border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: 0 5px 17px rgba(27,39,54,.025); }
.request-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; }
.request-title-wrap { display: flex; align-items: flex-start; gap: 10px; }
.request-symbol { display: grid; width: 31px; height: 31px; flex: 0 0 auto; place-items: center; border-radius: 9px; color: var(--blue); background: var(--blue-pale); font-size: 14px; }
.request-symbol.manual { color: #987137; background: #fff5e3; }
.request-card h3 { margin: 1px 0 5px; font-size: 13px; line-height: 1.4; }
.request-meta { display: flex; flex-wrap: wrap; gap: 7px 12px; color: var(--muted); font-size: 10px; }
.request-meta span { display: inline-flex; align-items: center; gap: 4px; }
.badge { display: inline-flex; align-items: center; min-height: 21px; padding: 0 8px; border-radius: 99px; color: #66717e; background: #f0f2f5; white-space: nowrap; font-size: 9px; font-weight: 700; }
.badge.active { color: #218255; background: #e7f7ef; }
.badge.pending-confirmation { color: #9a671b; background: #fff3d8; }
.badge.archived { color: #6d7781; background: #eff1f3; }
.badge.manual-tag { color: #987137; background: #fff5e3; }
.request-description { margin: 13px 0 11px 41px; color: #55616d; font-size: 11px; line-height: 1.6; }
.request-footer { display: flex; align-items: end; justify-content: space-between; gap: 15px; padding-top: 11px; border-top: 1px solid #f0f2f4; }
.request-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.source-master-label { color: #647181; font-size: 10px; }
.request-controls select { width: 160px; min-height: 32px; padding: 5px 8px; font-size: 10px; }
.check-control { display: inline-flex; align-items: center; gap: 5px; margin: 0; color: #687481; white-space: nowrap; font-size: 10px; font-weight: 500; }
input[type="checkbox"] { width: 14px; min-height: 14px; height: 14px; accent-color: var(--blue); }
.request-comment { width: min(245px, 26vw); min-height: 32px; height: 32px; padding: 6px 9px; font-size: 10px; }
.complete-button { min-height: 31px; padding: 0 10px; font-size: 10px; }
.empty-state { display: grid; min-height: 220px; place-content: center; justify-items: center; border: 1px dashed #dce2e8; border-radius: 10px; color: #566270; background: rgba(255,255,255,.55); text-align: center; }
.empty-state > span { margin-bottom: 11px; color: #7eabed; font-size: 24px; }
.empty-state strong { font-size: 13px; }
.empty-state p { margin: 6px 0 0; color: var(--muted); font-size: 11px; }
.loading-state { padding: 28px 14px; color: var(--muted); text-align: center; font-size: 12px; }
.selection-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 14px 0; padding: 11px 14px; border: 1px solid #d9e7fc; border-radius: 10px; color: #335b93; background: #f0f6ff; font-size: 11px; font-weight: 700; }
.toolbar-actions { display: flex; align-items: center; gap: 10px; }
.toolbar-actions select { width: 180px; min-height: 35px; font-size: 10px; }
.balance-groups { display: grid; gap: 12px; }
.balance-group { overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: 0 5px 17px rgba(27,39,54,.025); }
.group-header { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 13px 16px; border-bottom: 1px solid #eff1f3; }
.group-heading { display: flex; align-items: center; gap: 10px; }
.house-icon { display: grid; width: 31px; height: 31px; place-items: center; border-radius: 9px; color: var(--blue); background: var(--blue-pale); font-size: 15px; }
.group-heading strong { display: block; font-size: 12px; }
.group-heading small { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; }
.group-count { color: #7b8691; font-size: 10px; }
.account-table { width: 100%; border-collapse: collapse; }
.account-table th { padding: 9px 13px; color: #929ca6; background: #fbfcfd; text-align: left; font-size: 9px; font-weight: 700; }
.account-table td { padding: 9px 13px; border-top: 1px solid #f1f3f5; color: #4e5a67; font-size: 10px; }
.account-table tr:hover td { background: #fbfdff; }
.balance-amount { color: #354251 !important; font-weight: 700; }
.status-chip { display: inline-flex; padding: 4px 7px; border-radius: 99px; color: #677481; background: #f0f2f5; font-size: 9px; }
.admin-grid { display: grid; grid-template-columns: minmax(270px, .74fr) minmax(400px, 1.26fr); align-items: start; gap: 15px; }
.create-user-panel, .users-panel { padding: 18px; }
.section-title { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.section-title h2 { margin: 0; font-size: 14px; }
.section-title .muted { margin: 4px 0 0; font-size: 10px; }
.section-icon { display: grid; width: 32px; height: 32px; flex: 0 0 auto; place-items: center; border-radius: 9px; color: var(--blue); background: var(--blue-pale); font-size: 17px; }
.create-user-panel > label { margin-top: 14px; }
.create-user-panel > input, .create-user-panel > select { min-height: 38px; font-size: 11px; }
.optional { float: right; color: #a0a8b0; font-size: 9px; font-weight: 500; }
.role-options { display: flex; flex-wrap: wrap; gap: 9px 12px; margin: 16px 0; padding: 12px 0 0; border: 0; border-top: 1px solid #eef0f2; }
.role-options legend { padding: 10px 0 8px; color: #34404d; font-size: 11px; font-weight: 700; }
.role-options label { display: inline-flex; align-items: center; gap: 5px; margin: 0; color: #66717e; font-size: 10px; font-weight: 500; }
.role-options input { width: 14px; min-height: 14px; height: 14px; }
.users-panel .section-title { margin-bottom: 11px; }
.small-button { min-height: 31px; margin-left: auto; padding: 0 9px; font-size: 10px; }
.user-row { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-top: 1px solid #f0f2f4; }
.user-row .avatar { flex: 0 0 auto; }
.user-row-info { min-width: 0; flex: 1; }
.user-row-info strong, .user-row-info span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-row-info strong { font-size: 11px; }
.user-row-info span { margin-top: 3px; color: var(--muted); font-size: 9px; }
.user-status { color: #258257; font-size: 9px; }
.user-status.inactive { color: #9aa2aa; }
.masters-admin-grid { display: grid; grid-template-columns: minmax(250px, .7fr) minmax(400px, 1.3fr); align-items: start; gap: 15px; }
.source-masters-panel { min-width: 0; padding: 18px; }
.source-masters-panel .section-title { margin-bottom: 11px; }
.source-masters-list { display: grid; gap: 18px; }
.source-master-site h3 { margin: 0; padding: 10px 0 7px; border-bottom: 1px solid var(--line); color: var(--blue); font-size: 11px; letter-spacing: .08em; }
.source-master-row { display: flex; align-items: center; gap: 14px; padding: 11px 0; border-bottom: 1px solid #f0f2f4; }
.source-master-info { min-width: 0; flex: 1; }
.source-master-info strong, .source-master-info span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-master-info strong { font-size: 11px; }
.source-master-info span { margin-top: 4px; color: var(--muted); font-size: 9px; }
.source-master-row select { width: min(230px, 45%); min-height: 36px; font-size: 10px; }
.toast { position: fixed; z-index: 10; top: 74px; right: 28px; max-width: min(420px, calc(100vw - 32px)); padding: 12px 16px; border: 1px solid #cdebdc; border-radius: 9px; color: #236d4b; background: #effaf4; box-shadow: var(--shadow); font-size: 12px; }
.toast.error { border-color: #f2d1d2; color: #a43c42; background: #fff4f4; }
.modal { width: min(600px, calc(100vw - 30px)); max-height: calc(100vh - 30px); padding: 0; overflow: auto; border: 0; border-radius: 14px; box-shadow: 0 25px 90px rgba(20,35,55,.24); }
.modal::backdrop { background: rgba(23,33,45,.42); backdrop-filter: blur(3px); }
.modal-card { padding: 24px; }
.modal-heading { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; }
.modal-heading h2 { margin: 0; font-family: "Manrope", sans-serif; font-size: 21px; letter-spacing: -.03em; }
.modal-card > label { margin-top: 13px; }
.modal-card input, .modal-card textarea, .modal-card select { font-size: 11px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.form-grid label { margin-bottom: 6px; }
.check-row { display: flex; gap: 18px; margin-top: 14px; }
.check-row label { display: inline-flex; align-items: center; gap: 6px; margin: 0; color: #66717e; font-size: 10px; font-weight: 500; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 13px; }

@media (max-width: 1000px) {
  .sidebar { width: 205px; }
  .workspace { width: calc(100% - 205px); margin-left: 205px; }
  .page-content { padding-right: 22px; padding-left: 22px; }
  .topbar { padding-right: 22px; padding-left: 22px; }
  .admin-grid { grid-template-columns: 1fr; }
  .masters-admin-grid { grid-template-columns: 1fr; }
  .request-footer { align-items: flex-start; flex-direction: column; }
  .request-comment { width: min(320px, 40vw); }
}
@media (max-width: 700px) {
  .login-panel { min-height: 100vh; padding: 24px; }
  .sidebar { position: static; z-index: auto; width: 0; height: 0; flex: 0 0 0; padding: 0; overflow: visible; border: 0; background: transparent; }
  .sidebar-brand, .nav-caption, .sidebar-bottom { display: none; }
  .main-nav { position: fixed; z-index: 20; right: 0; bottom: 0; left: 0; display: flex; width: 100%; height: calc(72px + env(safe-area-inset-bottom)); align-items: stretch; justify-content: space-around; gap: 4px; padding: 6px 10px calc(6px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(255,255,255,.98); box-shadow: 0 -7px 22px rgba(27,39,54,.08); }
  .nav-item { display: flex; min-width: 60px; min-height: 56px; height: 100%; flex: 1; flex-direction: column; justify-content: center; gap: 4px; padding: 5px 3px; border-radius: 8px; color: #78838f; font-size: 11px; line-height: 1.2; text-align: center; }
  .nav-item.active { color: var(--blue); background: transparent; }
  .nav-icon { width: auto; font-size: 21px; line-height: 1; }
  .workspace { width: 100%; margin-left: 0; padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  .topbar { height: 58px; padding: 0 15px; }
  .breadcrumbs { gap: 7px; font-size: 10px; }
  .user-copy { display: none; }
  .page-content { padding: 25px 15px 40px; }
  .page-heading { align-items: flex-start; }
  .page-heading h1 { font-size: 24px; }
  .page-heading .muted { max-width: 310px; font-size: 12px; line-height: 1.5; }
  .page-heading > .button { min-height: 42px; padding: 0 11px; white-space: nowrap; font-size: 11px; }
  .filter-panel { align-items: stretch; flex-wrap: wrap; gap: 10px; padding: 13px; }
  .filter-group { width: calc(50% - 5px); }
  .filter-group label { margin-bottom: 7px; font-size: 11px; }
  .filter-group select { min-height: 42px; padding: 8px 10px; font-size: 12px; }
  .filter-refresh { width: 100%; min-height: 42px; margin: 0; font-size: 12px; }
  .results-heading { margin-top: 20px; }
  .results-heading strong { font-size: 13px; }
  .results-heading span { font-size: 11px; }
  .request-card { padding: 14px; }
  .request-card h3 { font-size: 14px; }
  .request-meta { gap: 7px 10px; font-size: 11px; }
  .badge { min-height: 23px; padding: 0 9px; font-size: 10px; }
  .request-description { margin-left: 0; }
  .request-controls { gap: 9px; }
  .source-master-label { width: 100%; font-size: 11px; }
  .request-controls select { width: 100%; min-height: 42px; font-size: 12px; }
  .check-control { gap: 7px; font-size: 11px; }
  .request-comment { width: 100%; min-height: 42px; height: 42px; font-size: 12px; }
  .request-footer { gap: 10px; }
  .complete-button, .confirm-button { min-height: 40px; padding: 0 12px; font-size: 11px; }
  .selection-toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-actions { align-items: stretch; flex-direction: column; }
  .toolbar-actions select { width: 100%; min-height: 42px; font-size: 12px; }
  .toolbar-actions .button { min-height: 42px; font-size: 12px; }
  .source-master-row { align-items: stretch; flex-direction: column; gap: 7px; }
  .source-master-row select { width: 100%; min-height: 42px; font-size: 12px; }
  .source-master-info strong { font-size: 12px; }
  .source-master-info span { font-size: 10px; }
  .group-header { padding: 11px; }
  .group-heading strong { font-size: 13px; }
  .group-heading small { font-size: 10px; }
  .group-count { font-size: 11px; }
  .account-table th, .account-table td { padding: 10px 7px; font-size: 10px; }
  .account-table th:nth-child(4), .account-table td:nth-child(4) { display: none; }
  .form-grid { gap: 9px; }
  .modal-card { padding: 18px; }
  .button { min-height: 42px; font-size: 12px; }
}

@media (max-width: 370px) {
  .page-content { padding-right: 12px; padding-left: 12px; }
  .page-heading { gap: 8px; }
  .page-heading > .button { min-height: 33px; padding: 0 7px; font-size: 9px; }
  .filter-panel { gap: 8px; padding: 9px; }
  .filter-group { width: calc(50% - 4px); }
  .request-badges { display: flex; flex-direction: column; gap: 4px; }
  .form-grid { grid-template-columns: 1fr; }
}
