:root {
  --font-scale: 1;
  --bg: #f3f5f9;
  --surface: #fff;
  --surface-soft: #f7f8fb;
  --line: #e5e8ef;
  --text: #222736;
  --muted: #7c8392;
  --navy: #20283c;
  --brand: #5753d8;
  --brand-soft: #efeffd;
  --red: #cf4b58;
  --amber: #bd801c;
  --green: #278661;
  --shadow: 0 10px 34px rgba(29, 36, 55, .07);
}

html[data-theme="dark"] {
  --bg: #111622;
  --surface: #1a202e;
  --surface-soft: #232a3a;
  --line: #30394d;
  --text: #edf0f7;
  --muted: #a5adbd;
  --navy: #0b0f18;
  --brand-soft: #30305c;
  --shadow: 0 12px 38px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
html { font-size: calc(16px * var(--font-scale)); }
body { margin: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; line-height: 1.5; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button, .primary, .secondary, .ghost, .danger { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 25px 18px 18px; background: linear-gradient(180deg, var(--navy), #1a2132); color: #f7f8fc; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 7px 26px; text-decoration: none; }
.brand > img { width: 43px; height: 43px; display: block; filter: drop-shadow(0 8px 18px rgba(92,87,220,.3)); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 1rem; letter-spacing: .075em; }
.brand small { margin-top: 3px; color: #aeb5c7; font-size: .75rem; }
.sidebar nav { display: grid; gap: 4px; }
.nav-item { min-height: 44px; display: grid; grid-template-columns: 15px 1fr auto; align-items: center; gap: 9px; padding: 0 12px; border-radius: 10px; color: #bdc4d2; text-decoration: none; font-size: .84rem; font-weight: 650; }
.nav-item:hover, .nav-item.active { background: rgba(116,111,234,.15); color: #fff; }
.nav-item.active { box-shadow: inset 3px 0 #7c77ee; }
.nav-dot { width: 7px; height: 7px; border: 1.5px solid #8690a7; border-radius: 2px; }
.nav-item.active .nav-dot { border-color: #8c87f1; background: #8c87f1; }
.nav-item b { min-width: 23px; padding: 3px 7px; border-radius: 20px; background: rgba(255,255,255,.08); color: #d0d5df; font-size: .68rem; text-align: center; }
.user-card { display: grid; grid-template-columns: 35px 1fr; align-items: center; gap: 10px; margin-top: auto; padding: 16px 7px 2px; border-top: 1px solid rgba(255,255,255,.08); }
.user-card > span, .user-card > img { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 10px; background: #6870c9; object-fit: cover; font-size: .72rem; font-weight: 700; }
.user-card strong, .user-card small { display: block; }
.user-card strong { font-size: .78rem; }
.user-card small { margin-top: 3px; color: #a5adbf; font-size: .7rem; }

.workspace { min-width: 0; padding: 29px 34px 35px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-bottom: 24px; }
.topbar p { margin: 0 0 5px; color: var(--muted); font-size: .72rem; font-weight: 650; letter-spacing: .025em; text-transform: uppercase; }
.topbar h1 { margin: 0; font-size: 1.55rem; letter-spacing: -.025em; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.top-actions form { margin: 0; }

.primary, .secondary, .ghost, .danger { min-height: 41px; display: inline-flex; align-items: center; justify-content: center; padding: 0 15px; border-radius: 9px; text-decoration: none; font-size: .82rem; font-weight: 650; line-height: 1.2; letter-spacing: 0; }
.primary { border: 0; background: var(--brand); color: #fff; box-shadow: 0 7px 18px rgba(87,83,216,.19); }
.secondary { border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.ghost { border: 0; background: transparent; color: var(--muted); }
.danger { border: 1px solid #efd0d4; background: #fff5f6; color: #b9404d; }
html[data-theme="dark"] .danger { border-color: #633943; background: #34252c; color: #ef9aa4; }

.flash { margin: -8px 0 18px; padding: 12px 15px; border: 1px solid #bfe5d3; border-radius: 10px; background: #edf9f3; color: #267857; font-size: .82rem; font-weight: 650; }
.flash.error { border-color: #efcbd0; background: #fff1f3; color: #b63e4b; }
.flash.warning { margin: 0; border-color: #efd59b; background: #fff8e8; color: #8b641b; }

.weather-strip { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 13px; padding: 11px 16px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); color: var(--muted); font-size: .76rem; }
.weather-summary, .currency-rates { display: flex; align-items: baseline; gap: 11px; }
.weather-city { color: var(--text); font-size: 1.02rem; font-weight: 750; }
.weather-summary > strong { color: #d19020; font-size: 1.12rem; }
.currency-rates { justify-content: flex-end; }
.currency-rates > span { color: var(--muted); font-size: .72rem; font-weight: 650; }
.currency-rates > span strong { margin-left: 3px; color: var(--text); font-size: .86rem; }
.currency-rates > small { padding-left: 10px; border-left: 1px solid var(--line); color: var(--muted); font-size: .68rem; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 13px; margin-bottom: 18px; }
.metrics .metric-card { min-height: 104px; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: 0 4px 14px rgba(30,37,56,.025); color: var(--text); text-decoration: none; transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease; }
.metrics .metric-card:hover { transform: translateY(-2px); border-color: #bbb9ee; box-shadow: 0 9px 24px rgba(30,37,56,.08); }
.metrics small, .metrics strong, .metrics span { display: block; }
.metrics small { color: var(--muted); font-size: .77rem; font-weight: 650; }
.metrics strong { margin: 6px 0 4px; font-size: 1.45rem; line-height: 1; }
.metrics span { color: var(--muted); font-size: .71rem; }
.metric-red strong { color: var(--red); }
.metric-amber strong { color: var(--amber); }
.metric-green strong { color: var(--green); }

.panel { margin-bottom: 18px; overflow: hidden; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); box-shadow: var(--shadow); }
.panel-head { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 15px 19px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0 0 4px; font-size: .92rem; }
.panel-head p { margin: 0; color: var(--muted); font-size: .76rem; }
.panel-head > a:not(.primary), .panel-head > form button { font-size: .78rem; }
.panel-body { padding: 18px 19px; }
.panel-foot { min-height: 45px; display: flex; justify-content: flex-end; align-items: center; padding: 0 19px; color: var(--muted); font-size: .76rem; }
.panel-foot a { color: var(--brand); text-decoration: none; font-weight: 700; }
.empty { padding: 45px 20px; color: var(--muted); text-align: center; font-size: .72rem; }
.empty.compact { padding: 22px 10px; }

.deal-row { min-height: 76px; display: grid; grid-template-columns: 36px minmax(220px,1.55fr) minmax(170px,1.2fr) minmax(130px,.8fr) 95px 20px; align-items: center; gap: 13px; padding: 11px 19px; border-bottom: 1px solid var(--line); text-decoration: none; transition: .15s; }
.deal-row:hover { background: var(--surface-soft); }
.client-badge { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: var(--brand-soft); color: var(--brand); font-size: .72rem; font-weight: 750; }
.client-badge.large { width: 51px; height: 51px; border-radius: 14px; font-size: .8rem; }
.deal-client, .deal-stage, .deal-owner { min-width: 0; }
.deal-client strong, .deal-client small, .deal-stage strong, .deal-stage small, .deal-owner strong, .deal-owner small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deal-client strong, .deal-stage strong, .deal-owner strong { font-size: .78rem; }
.deal-client small, .deal-stage small, .deal-owner small { margin-top: 4px; color: var(--muted); font-size: .68rem; }
.deal-stage i, .client-facts article > i { height: 3px; display: block; overflow: hidden; margin-top: 7px; border-radius: 4px; background: var(--line); }
.deal-stage i b, .client-facts article > i b { height: 100%; display: block; border-radius: inherit; background: var(--brand); }
.status { justify-self: start; padding: 5px 9px; border-radius: 20px; font-size: .68rem; font-weight: 700; }
.status.paid { background: #eaf8f1; color: var(--green); }
.status.partial { background: #fff6df; color: var(--amber); }
.status.waiting { background: #faecee; color: var(--red); }
.arrow { color: var(--muted); font-size: 1.2rem; }

.search-form { display: flex; gap: 9px; flex: 1; min-width: 0; max-width: none; }
.search-form input:not([type="hidden"]) { flex: 2 1 430px; min-width: 300px; }
.search-form select { flex: 0 1 180px; }
input, select, textarea { width: 100%; min-height: 41px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; outline: 0; background: var(--surface); color: var(--text); font-size: .82rem; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #8a86e7; box-shadow: 0 0 0 3px rgba(87,83,216,.1); }
.form-page { display: grid; gap: 0; }
.form-section { box-shadow: none; }
.form-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 15px; padding: 20px; }
.form-grid label, .form-stack label { display: grid; gap: 6px; color: var(--muted); font-size: .78rem; font-weight: 650; }
.form-grid .wide { grid-column: 1/-1; }
.form-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 2px; }
.form-stack { display: grid; gap: 13px; }
.form-stack fieldset { display: grid; gap: 8px; margin: 2px 0; padding: 13px; border: 1px solid var(--line); border-radius: 10px; }
.form-stack legend { padding: 0 5px; color: var(--muted); font-size: .76rem; font-weight: 700; }
.check-option { display: flex !important; grid-template-columns: 17px 1fr; align-items: center; gap: 8px !important; color: var(--text) !important; font-weight: 500 !important; }
.check-option input { width: 16px; min-height: 16px; }

.client-hero { display: grid; grid-template-columns: 51px 1fr auto; align-items: center; gap: 14px; margin-bottom: 15px; }
.client-hero p, .client-hero h2, .client-hero span { margin: 0; }
.client-hero p { color: var(--muted); font-size: .7rem; font-weight: 700; text-transform: uppercase; }
.client-hero h2 { margin: 3px 0; font-size: 1.15rem; }
.client-hero span { color: var(--muted); font-size: .78rem; }
.client-facts { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 10px; margin-bottom: 16px; }
.client-facts article { min-height: 96px; padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.client-facts small, .client-facts strong, .client-facts span { display: block; }
.client-facts small { color: var(--muted); font-size: .7rem; }
.client-facts strong { margin: 6px 0 5px; font-size: .8rem; line-height: 1.4; }
.client-facts span { color: var(--muted); font-size: .68rem; }
.client-layout { display: grid; grid-template-columns: minmax(0,1.75fr) minmax(280px,.8fr); gap: 15px; align-items: start; }
.advance-box { text-align: right; }
.advance-box form { margin: 0 0 4px; }
.advance-box small { color: var(--muted); font-size: .68rem; }
.stages { display: grid; gap: 8px; padding: 14px; }
.stage-card { overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); }
.stage-card summary { min-height: 60px; display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 10px; padding: 9px 13px; cursor: pointer; list-style: none; }
.stage-card summary::-webkit-details-marker { display: none; }
.stage-card summary > span { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 9px; background: var(--brand-soft); color: var(--brand); font-size: .72rem; font-weight: 750; }
.stage-card summary strong, .stage-card summary small { display: block; }
.stage-card summary strong { font-size: .79rem; }
.stage-card summary small { margin-top: 3px; color: var(--muted); font-size: .68rem; }
.stage-card summary > b { color: var(--muted); font-size: .68rem; }
.stage-items { border-top: 1px solid var(--line); background: var(--surface); }
.check-row { min-height: 51px; display: grid; grid-template-columns: 28px 1fr; align-items: center; gap: 9px; margin: 0; padding: 8px 13px; border-bottom: 1px solid var(--line); }
.check-row:last-child { border-bottom: 0; }
.check-row > button { width: 25px; height: 25px; padding: 0; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: #fff; }
.check-row.done > button { border-color: var(--green); background: var(--green); }
.check-row strong, .check-row small { display: block; }
.check-row strong { font-size: .76rem; }
.check-row small { margin-top: 3px; color: var(--muted); font-size: .67rem; }
.check-row.done strong { color: var(--muted); text-decoration: line-through; }

.upload-form, .inline-form { display: grid; grid-template-columns: 140px 1fr auto; gap: 8px; margin-bottom: 15px; padding-bottom: 15px; border-bottom: 1px solid var(--line); }
.inline-form { grid-template-columns: 130px 145px 1fr auto; }
.file-row { min-height: 55px; display: grid; grid-template-columns: 27px 1fr auto; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.file-row:last-child { border-bottom: 0; }
.file-row > span { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 8px; background: var(--brand-soft); color: var(--brand); font-size: .72rem; }
.file-row strong, .file-row small { display: block; }
.file-row strong { font-size: .77rem; }
.file-row small { margin-top: 3px; color: var(--muted); font-size: .67rem; }
.file-row > a { color: var(--brand); font-size: .72rem; font-weight: 700; }
.payment-row { min-height: 49px; display: grid; grid-template-columns: 130px 1fr; align-items: center; border-bottom: 1px solid var(--line); }
.payment-row > strong { font-size: .79rem; }
.payment-row > span { color: var(--muted); font-size: .7rem; }
.payment-row small { display: block; margin-top: 2px; }
.details-list { display: grid; grid-template-columns: 100px 1fr; margin: 0; padding: 15px 18px; font-size: .76rem; }
.details-list dt, .details-list dd { margin: 0; padding: 8px 0; border-bottom: 1px solid var(--line); }
.details-list dt { color: var(--muted); }
.details-list dd { overflow-wrap: anywhere; font-weight: 700; }
.events { padding: 15px 18px; }
.event-row { display: grid; grid-template-columns: 9px 1fr; gap: 9px; padding-bottom: 15px; }
.event-row > i { width: 7px; height: 7px; margin-top: 4px; border-radius: 50%; background: var(--brand); }
.event-row strong, .event-row small { display: block; }
.event-row strong { font-size: .75rem; }
.event-row small { margin-top: 3px; color: var(--muted); font-size: .66rem; }

.two-column { display: grid; grid-template-columns: 1.3fr .9fr; gap: 16px; align-items: start; }
.employee-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; padding: 14px; }
.employee-card { padding: 14px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-soft); }
.employee-head { display: grid; grid-template-columns: 35px 1fr auto; align-items: center; gap: 9px; }
.employee-head > span, .employee-head > img { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 10px; background: var(--brand-soft); color: var(--brand); object-fit: cover; font-size: .72rem; font-weight: 750; }
.employee-head strong, .employee-head small { display: block; }
.employee-head strong { font-size: .78rem; }
.employee-head small { margin-top: 3px; color: var(--muted); font-size: .67rem; }
.employee-head > b { padding: 4px 7px; border-radius: 20px; font-size: .65rem; }
.employee-head > b.online { background: #eaf8f1; color: var(--green); }
.employee-head > b.pending { background: #fff6df; color: var(--amber); }
.employee-head > b.disabled { background: #faecee; color: var(--red); }
.employee-actions { display: flex; justify-content: flex-end; margin-top: 12px; }
.security-label { align-self: center; color: var(--muted); font-size: .7rem; font-weight: 700; }
.env-admin-note { padding: 14px; border: 1px solid #c9c8f1; border-radius: 10px; background: var(--brand-soft); }
.env-admin-note strong, .env-admin-note p { display: block; margin: 0; }
.env-admin-note strong { font-size: .7rem; }
.env-admin-note p { margin-top: 6px; color: var(--muted); font-size: .74rem; line-height: 1.55; }
.avatar-section { border-top: 1px solid var(--line); }
.avatar-upload { display: grid; grid-template-columns: 58px minmax(160px,1fr) auto; align-items: center; gap: 10px; }
.avatar-upload .employee-avatar.large { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 14px; background: var(--brand-soft); color: var(--brand); object-fit: cover; font-size: .72rem; font-weight: 900; }
.avatar-upload label { display: grid; gap: 5px; color: var(--muted); font-size: .74rem; font-weight: 700; }
.avatar-upload small { grid-column: 2 / -1; color: var(--muted); font-size: .66rem; }
.session-row { min-height: 59px; display: flex; justify-content: space-between; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.session-row strong, .session-row small { display: block; }
.session-row strong { max-width: 520px; overflow: hidden; font-size: .76rem; text-overflow: ellipsis; white-space: nowrap; }
.session-row small { margin-top: 3px; color: var(--muted); font-size: .67rem; }

.settings-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(340px,.85fr); gap: 16px; align-items: start; }
.backup-summary > form { margin-top: 16px; }
.backup-summary .details-list { padding: 0; }
.form-help { margin: 4px 0 8px; color: var(--muted); font-size: .7rem; line-height: 1.5; }
.restore-warning { padding: 13px; border: 1px solid #efcbd0; border-radius: 10px; background: #fff4f5; }
.restore-warning strong { display: block; color: #b63e4b; font-size: .8rem; }
.restore-warning p { margin: 6px 0 0; color: var(--muted); font-size: .72rem; line-height: 1.5; }
html[data-theme="dark"] .restore-warning { border-color: #633943; background: #34252c; }
.restore-panel form > small { color: var(--muted); font-size: .68rem; line-height: 1.5; }

.backup-modal-backdrop { position: fixed; z-index: 1000; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(20,25,38,.62); backdrop-filter: blur(3px); }
.backup-modal { position: relative; width: min(520px,100%); padding: 28px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: 0 30px 80px rgba(13,18,31,.3); text-align: center; }
.backup-modal-close { position: absolute; top: 10px; right: 12px; width: 36px; height: 36px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 1.45rem; line-height: 1; }
.backup-modal-close:hover, .backup-modal-close:focus-visible { background: var(--surface-soft); color: var(--text); outline: 0; }
.backup-modal-icon { width: 54px; height: 54px; display: grid; place-items: center; margin: 0 auto 14px; border-radius: 16px; background: var(--brand-soft); color: var(--brand); font-size: 1.5rem; font-weight: 900; }
.backup-modal h2 { margin: 0 0 9px; font-size: 1.1rem; }
.backup-modal p { margin: 0 auto; color: var(--muted); font-size: .8rem; line-height: 1.65; }
.backup-modal-actions { display: flex; justify-content: center; gap: 9px; margin: 20px 0 13px; }
.backup-modal-actions form { margin: 0; }
.backup-modal small { display: block; color: var(--muted); font-size: .68rem; line-height: 1.5; }

.report-toolbar { overflow: visible; }
.report-period-form { display: grid; grid-template-columns: minmax(230px,1fr) 165px 165px auto auto; align-items: end; gap: 10px; padding: 16px 19px; }
.report-period-form > div strong, .report-period-form > div small { display: block; }
.report-period-form > div strong { font-size: .9rem; }
.report-period-form > div small { margin-top: 4px; color: var(--muted); font-size: .7rem; }
.report-period-form label { display: grid; gap: 5px; color: var(--muted); font-size: .7rem; font-weight: 700; }
.report-period-form input { min-width: 0; }
.excel-button::before { content: "↧"; margin-right: 6px; font-size: 1rem; }
.report-kpis { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 13px; margin-bottom: 18px; }
.report-kpis article { min-height: 112px; padding: 17px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: 0 4px 14px rgba(30,37,56,.025); }
.report-kpis small, .report-kpis strong, .report-kpis span { display: block; }
.report-kpis small { color: var(--muted); font-size: .72rem; font-weight: 700; }
.report-kpis strong { margin: 8px 0 5px; color: var(--brand); font-size: 1.2rem; line-height: 1.15; }
.report-kpis span { color: var(--muted); font-size: .68rem; }
.report-kpi-amber strong { color: var(--amber); }
.report-kpi-green strong { color: var(--green); }
.report-chart-legend { display: flex; flex-wrap: wrap; gap: 15px; margin-bottom: 16px; color: var(--muted); font-size: .7rem; font-weight: 650; }
.report-chart-legend span { display: flex; align-items: center; gap: 6px; }
.report-chart-legend i { width: 10px; height: 10px; display: inline-block; border-radius: 3px; background: var(--brand); }
.report-chart-legend i.payments { background: var(--green); }
.report-chart-scroll { overflow-x: auto; padding: 0 2px 4px; }
.report-chart { height: 270px; display: flex; align-items: stretch; gap: 6px; padding: 12px 9px 0; border-bottom: 1px solid var(--line); background: repeating-linear-gradient(to bottom, transparent 0, transparent 63px, var(--line) 64px); }
.report-chart-group { min-width: 42px; flex: 1; display: grid; grid-template-rows: 1fr 28px; gap: 5px; }
.report-chart-bars { min-height: 0; display: flex; align-items: end; justify-content: center; gap: 3px; }
.report-bar { width: min(14px,42%); display: block; border-radius: 4px 4px 1px 1px; background: var(--brand); box-shadow: 0 2px 8px rgba(87,83,216,.18); }
.report-bar.payments { background: var(--green); box-shadow: 0 2px 8px rgba(39,134,97,.18); }
.report-chart-group small { overflow: hidden; color: var(--muted); font-size: .61rem; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.report-distributions { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.report-distributions h3 { margin: 0 0 15px; font-size: .83rem; }
.distribution-row { margin-bottom: 12px; }
.distribution-row > span { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 5px; font-size: .7rem; }
.distribution-row > span b { font-weight: 650; }
.distribution-row > span em { color: var(--muted); font-style: normal; font-weight: 700; }
.distribution-row > i { height: 7px; display: block; overflow: hidden; border-radius: 8px; background: var(--surface-soft); }
.distribution-row > i b { height: 100%; display: block; border-radius: inherit; background: var(--brand); }
.distribution-row.red > i b { background: var(--red); }
.distribution-row.amber > i b { background: var(--amber); }
.distribution-row.green > i b { background: var(--green); }
.table-subline { display: block; margin-top: 3px; color: var(--muted); font-size: .65rem; }
.money-cell { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.debt-cell { color: var(--amber); font-weight: 700; }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .75rem; }
th, td { padding: 11px 13px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: var(--surface-soft); color: var(--muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .025em; }
td a { color: var(--brand); font-weight: 650; text-decoration: none; }

.login-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 10%, #ecebff, transparent 35%), var(--bg); }
.login-card { width: min(420px,100%); padding: 32px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: 0 25px 65px rgba(31,38,58,.14); }
.login-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 28px; }
.login-brand > img { width: 46px; height: 46px; display: block; }
.login-brand strong, .login-brand small { display: block; }
.login-brand strong { letter-spacing: .055em; }
.login-brand small { margin-top: 3px; color: var(--muted); font-size: .74rem; }
.login-card h1 { margin: 0 0 6px; font-size: 1.45rem; }
.login-card > p { margin: 0 0 22px; color: var(--muted); font-size: .71rem; }
.login-card .primary { width: 100%; }
.security-note { display: block; margin-top: 18px; color: var(--muted); font-size: .68rem; line-height: 1.5; text-align: center; }

.clients-toolbar { align-items: stretch; }
.clients-toolbar > .primary { flex: 0 0 auto; }
.client-filter { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 11px 19px; border-bottom: 1px solid var(--line); background: var(--brand-soft); font-size: .76rem; }
.client-filter a { color: var(--brand); font-weight: 700; text-decoration: none; }
.show-password { display: flex !important; align-items: center; gap: 8px !important; color: var(--text) !important; font-weight: 500 !important; cursor: pointer; }
.show-password input { width: 17px; height: 17px; min-height: 17px; margin: 0; accent-color: var(--brand); }
.password-reset-section { border-top: 1px solid var(--line); }
.password-reset-section h3 { margin: 0; font-size: .92rem; }
.password-reset-section > p { margin: 4px 0 14px; color: var(--muted); font-size: .73rem; }
.login-logout { display: flex; justify-content: center; margin-top: 10px; }
.error-actions { display: flex; gap: 9px; margin-top: 18px; }
.error-actions > a { flex: 1; }
html[data-theme="dark"] .flash.warning { border-color: #69562c; background: #332d20; color: #e5c779; }

button, .primary, .secondary, .ghost, .danger { white-space: nowrap; }

@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 210px 1fr; }
  .workspace { padding: 25px 20px; }
  .deal-row { grid-template-columns: 34px minmax(180px,1.4fr) minmax(150px,1fr) minmax(115px,.8fr) 85px 16px; gap: 8px; }
  .client-facts { grid-template-columns: 1fr 1fr; }
  .client-layout { grid-template-columns: 1fr; }
  .report-period-form { grid-template-columns: 1fr 1fr; }
  .report-period-form > div { grid-column: 1/-1; }
  .report-kpis { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 780px) {
  .app-shell { display: block; }
  .sidebar { position: relative; height: auto; padding: 15px; }
  .brand { padding-bottom: 12px; }
  .sidebar nav { display: flex; overflow-x: auto; }
  .nav-item { flex: 0 0 auto; grid-template-columns: 10px auto auto; }
  .user-card { max-width: 250px; margin-top: 12px; }
  .topbar { align-items: flex-start; }
  .top-actions { flex-direction: column; align-items: flex-end; }
  .weather-strip { align-items: flex-start; flex-direction: column; gap: 6px; }
  .currency-rates { width: 100%; justify-content: flex-start; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .deal-row { grid-template-columns: 34px 1fr auto; }
  .deal-stage, .deal-owner { display: none; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .two-column { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .report-distributions { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .workspace { padding: 18px 12px; }
  .topbar h1 { font-size: 1.25rem; }
  .top-actions .secondary { display: none; }
  .currency-rates > small { display: none; }
  .metrics { gap: 7px; }
  .metrics article { min-height: 92px; padding: 13px; }
  .panel-head { align-items: flex-start; flex-direction: column; }
  .search-form { width: 100%; flex-wrap: wrap; }
  .search-form input:not([type="hidden"]) { min-width: 100%; }
  .search-form select { flex: 1; }
  .form-grid, .client-facts, .employee-list { grid-template-columns: 1fr; }
  .client-hero { grid-template-columns: 51px 1fr; }
  .hero-actions { grid-column: 1/-1; }
  .upload-form, .inline-form { grid-template-columns: 1fr; }
  .advance-box { text-align: left; }
  .backup-modal-actions { flex-direction: column; }
  .backup-modal-actions button { width: 100%; }
  .report-period-form { grid-template-columns: 1fr; }
  .report-period-form > div { grid-column: auto; }
  .report-period-form .primary, .report-period-form .secondary { width: 100%; }
  .report-kpis { grid-template-columns: 1fr; }
  .stage-card summary { grid-template-columns: 28px 1fr; }
  .stage-card summary > b { display: none; }
}
