/* unified-ui-v34.0 — single final visual contract. No accounting logic. */
:root{--u-font:var(--app-font,Vazirmatn,-apple-system,BlinkMacSystemFont,sans-serif);--u-text:var(--app-text,#f5f7fb);--u-muted:var(--app-muted,#a9b7cc);--u-surface:var(--app-surface,#17283f);--u-raised:var(--app-surface-raised,#203854);--u-border:var(--app-border,#36536f);--u-accent:var(--app-accent,#2387f5);--u-success:var(--app-success,#12b981);--u-danger:var(--app-danger,#ff5964);--u-radius:14px;--u-card:20px;--u-control:48px}
html{overflow-x:hidden}body{overflow-x:hidden}.app-shell,.page,.panel,.card,.stats-grid,.report-grid,.form-grid,.field{min-width:0;max-width:100%}.page{overflow-x:clip}
button,input,select,textarea,.file-label{box-sizing:border-box;max-width:100%;font-family:var(--u-font);-webkit-tap-highlight-color:transparent}button,.file-label{-webkit-appearance:none;appearance:none}
input,select,textarea{width:100%;min-width:0;border-radius:var(--u-radius);font-size:16px}
.primary,.secondary,button.danger,.settings-list button,.file-label,#addAccountBtn,#addAssetBtn,#addCommitmentBtn,.modal-actions button,.form-grid>button{min-height:var(--u-control);height:auto!important;padding:10px 15px!important;border-radius:var(--u-radius)!important;font-weight:800!important;line-height:1.35!important;box-shadow:none!important;text-shadow:none!important;transform:none!important}
.primary,#addAccountBtn,#addAssetBtn,#addCommitmentBtn{background:linear-gradient(180deg,#2f94ff,var(--u-accent))!important;border:1px solid #4ca2ff!important;color:#fff!important}.secondary,.section-title button,.settings-list button:not(.danger),.file-label{background:var(--app-button-bg)!important;border:1px solid var(--u-border)!important;color:var(--u-text)!important;box-shadow:none!important;text-shadow:none!important}.danger,button.danger,.danger-link{box-shadow:none!important;text-shadow:none!important;transform:none!important}
.section-title{gap:10px}.section-title>*{min-width:0}.section-title button,.mini-row button{min-height:38px!important;height:auto!important;padding:8px 12px!important;border-radius:12px!important;font-size:12.5px!important;white-space:normal}
.panel,.card,.stats-grid article,.report-grid article{box-sizing:border-box;max-width:100%}.mini-row,.history-item,.card-head{min-width:0;gap:10px}.mini-row>*,.history-item>*,.card-head>*{min-width:0}.mini-row b,.mini-row small,.history-item b,.history-item small,.card h3{overflow-wrap:anywhere}
dialog{box-sizing:border-box;width:min(430px,calc(100vw - 20px))!important;max-width:calc(100vw - 20px)!important;max-height:calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 20px);overflow:auto;margin:auto;border-radius:20px!important}#modalBody{box-sizing:border-box;min-width:0;padding:18px!important;overflow-x:hidden}.base-modal-close{position:static!important;float:none!important;width:auto!important;min-width:78px!important;min-height:40px!important;height:auto!important;margin:0 0 12px auto!important;padding:8px 13px!important;border-radius:12px!important;box-shadow:none!important}
#modalBody .person-history-head{display:flex!important;align-items:flex-start!important;justify-content:space-between!important;gap:12px!important;min-height:0!important;padding:0 0 14px!important;margin:0 0 14px!important}#modalBody .person-history-head h3{min-width:0!important;padding:0!important;margin:0!important;overflow-wrap:anywhere}#modalBody .person-history-head>div{min-width:0}
#modal.installment-ui-modal{width:min(430px,calc(100vw - 20px))!important;max-width:calc(100vw - 20px)!important}#modal.installment-ui-modal #modalBody>.base-modal-close{display:none!important}#modal.installment-ui-modal #modalBody .person-history-head{display:flex!important;align-items:flex-start!important;gap:10px!important;padding:0 0 14px!important;margin:0 0 14px!important}#modal.installment-ui-modal #modalBody .person-history-head>div:first-child,#modal.installment-ui-modal #modalBody .person-history-head>h3{flex:1 1 auto!important;min-width:0!important}#modal.installment-ui-modal #modalBody .person-history-head>div:last-child{display:flex!important;flex:0 0 auto!important;gap:7px!important;padding:0!important;margin:0!important;align-items:flex-start!important}#modal.installment-ui-modal [data-close-installment-modal],#modal.installment-ui-modal [data-back-to-commitment],#modal.installment-ui-modal .shared-modal-close,#modal.installment-ui-modal [data-recalc-commitment]{width:auto!important;min-width:72px!important;max-width:104px!important;height:40px!important;min-height:40px!important;padding:0 10px!important;border-radius:11px!important;font-size:12px!important;box-shadow:none!important}
#installmentDashboard .mini-row{display:grid!important;grid-template-columns:minmax(0,1fr) minmax(126px,150px)!important;gap:10px!important;align-items:center!important}#installmentDashboard .installment-row-actions{min-width:0!important}#installmentDashboard .installment-row-actions>div{display:grid!important;grid-template-columns:1fr 1fr!important;gap:6px!important}#installmentDashboard [data-edit-installment],#installmentDashboard [data-pay-installment]{width:100%!important;min-width:0!important;height:38px!important;min-height:38px!important;padding:0 6px!important;font-size:11px!important;border-radius:10px!important;box-shadow:none!important;white-space:nowrap!important}
#commitmentsList .commitment-card{min-width:0!important}#commitmentsList .commitment-card .installment-open{width:auto!important;min-width:0!important;max-width:100%!important;height:auto!important;min-height:42px!important;margin-top:14px!important;padding:9px 14px!important;box-shadow:none!important}
.installment-pay-picker{box-sizing:border-box;padding:calc(env(safe-area-inset-top) + 10px) 10px calc(env(safe-area-inset-bottom) + 10px)!important}.installment-pay-sheet{box-sizing:border-box;width:min(100%,520px)!important;max-width:100%!important;max-height:calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 20px)!important;overflow:auto!important}.installment-pay-head{min-height:0!important;padding:0 0 14px!important;align-items:flex-start!important}.installment-pay-head [data-close-pay-picker]{width:auto!important;min-width:72px!important;height:40px!important;min-height:40px!important;padding:0 10px!important;box-shadow:none!important}
.segmented{max-width:100%;overflow:hidden}.segmented button{min-width:0!important;white-space:normal!important}.quick{box-shadow:none!important;transform:none!important}.icon-btn{box-shadow:none!important;transform:none!important}.bottom-nav button{transform:none!important}
body:not(.dark) .primary,body:not(.dark) #addAccountBtn,body:not(.dark) #addAssetBtn,body:not(.dark) #addCommitmentBtn{color:#fff!important}body:not(.dark) .secondary,body:not(.dark) .section-title button,body:not(.dark) .settings-list button:not(.danger){box-shadow:none!important}
@media(max-width:390px){.page{padding-inline:12px!important}#modalBody{padding:14px!important}#installmentDashboard .mini-row{grid-template-columns:minmax(0,1fr) 124px!important;gap:7px!important;padding:11px!important}#installmentDashboard [data-edit-installment],#installmentDashboard [data-pay-installment]{font-size:10px!important;padding-inline:3px!important}#modal.installment-ui-modal [data-close-installment-modal],#modal.installment-ui-modal [data-back-to-commitment],#modal.installment-ui-modal .shared-modal-close,#modal.installment-ui-modal [data-recalc-commitment]{min-width:64px!important;max-width:92px!important;padding-inline:8px!important;font-size:11px!important}}

/* v34.0.1 — screenshot QA: one modal close, safe header spacing, stable task actions. */
#modalBody{padding:20px 18px!important}
#modalBody>.base-modal-close{margin:0 0 16px auto!important}
#modalBody>h3:first-of-type{margin-top:2px!important;margin-bottom:18px!important;padding-inline:0!important}
#modalBody>.base-modal-close+ h3{padding-top:0!important}
#modal.installment-ui-modal #modalBody{padding:20px 18px!important}
#modal.installment-ui-modal #modalBody>.base-modal-close{display:none!important}
#modal.installment-ui-modal #modalBody .person-history-head{padding:0 0 18px!important;margin:0 0 18px!important;align-items:flex-start!important}
#modal.installment-ui-modal #modalBody .person-history-head>div:last-child{padding-top:0!important;align-self:flex-start!important}
#modal.installment-ui-modal #modalBody .person-history-head h3{padding:0!important}
#modal.installment-ui-modal [data-close-installment-modal],#modal.installment-ui-modal [data-back-to-commitment],#modal.installment-ui-modal .shared-modal-close{margin:0!important}
#modalBody .tn-tabs,#homeTasksNotes .tn-tabs{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:10px!important;width:100%!important;margin:12px 0 18px!important}
#modalBody .tn-tabs button,#homeTasksNotes .tn-tabs button{box-sizing:border-box!important;width:100%!important;min-width:0!important;max-width:none!important;min-height:46px!important;height:46px!important;padding:0 14px!important;border-radius:13px!important;font-size:14px!important;line-height:1!important}
#modalBody .tn-row{margin-inline:0!important;max-width:100%!important}
#modalBody>.secondary#tnCancel{display:flex!important;width:100%!important;min-height:46px!important;margin:18px 0 0!important;align-items:center!important;justify-content:center!important}
@media(max-width:390px){#modalBody,#modal.installment-ui-modal #modalBody{padding:16px 14px!important}#modalBody .tn-tabs,#homeTasksNotes .tn-tabs{gap:8px!important}}

/* v35 UI reference contract: one modal surface, one close, consistent spacing/actions */
#modal{padding:0!important}
#modalBody{position:relative!important;padding:22px 18px 20px!important;overflow-x:hidden!important}
#modalBody>.base-modal-close{position:static!important;display:flex!important;align-items:center!important;justify-content:center!important;width:auto!important;min-width:86px!important;height:44px!important;min-height:44px!important;margin:0 0 18px auto!important;padding:0 16px!important;border-radius:13px!important}
#modalBody [data-modal-close],#modalBody [data-close-installment-modal],#modalBody [data-back-to-commitment]{min-width:86px!important;min-height:44px!important;height:44px!important;padding:0 16px!important;border-radius:13px!important}
#modalBody>.base-modal-close~button[id*="Close"],#modalBody>.base-modal-close~button[id*="close"],#modalBody>.base-modal-close~.modal-close,#modalBody>.base-modal-close~.close-btn{display:none!important}
#modalBody>h2:first-of-type,#modalBody>h3:first-of-type{margin:0 0 18px!important;padding:0!important}
#modalBody .person-history-head{padding:0 0 18px!important;margin:0 0 18px!important;gap:14px!important;border-bottom:1px solid var(--app-border,#36536f)!important}
#modalBody .person-history-head [data-close-installment-modal],#modalBody .person-history-head [data-back-to-commitment]{margin:0!important}
#modalBody .tn-tabs{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:10px!important;width:100%!important}
#modalBody .tn-tabs>button{width:100%!important;min-width:0!important;max-width:none!important;height:46px!important;min-height:46px!important;margin:0!important}
#modalBody .form-grid>button,#modalBody .tn-form-actions>button{max-width:100%!important}
#modalBody>button.secondary:last-child,#modalBody>.form-grid>button.secondary:last-child{margin-top:18px!important}
@media(max-width:390px){#modalBody{padding:18px 14px!important}}

/* v35.1 reference QA: preserve premium surfaces after legacy retirement */
#modal{border-radius:22px!important}
#modalBody{border-radius:22px!important}
#modalBody .history-item,#modalBody .mini-row,#modalBody .tr-row,#modalBody .nr-row,#modalBody .ledger-detail,#modalBody .field input,#modalBody .field select,#modalBody .field textarea{border-radius:16px!important}
#modalBody button:not(.base-modal-close),#modalBody .primary,#modalBody .secondary{border-radius:14px!important}
#modalBody .history-side [data-debt-edit]{background:#183d62!important;color:#eaf4ff!important;border:1px solid #2f6f9f!important}
#modalBody .history-side [data-debt-delete]{background:rgba(255,82,96,.12)!important;color:#ff6673!important;border:1px solid rgba(255,82,96,.55)!important}
#homeTasksNotes .tn-tabs button{position:relative!important;color:#f5f8ff!important;border:1px solid #365d80!important;background:#19324d!important}
#homeTasksNotes .tn-tabs button[data-tn-open="task"]::before{content:"✓";display:inline-block;margin-left:7px;color:#39d98a;font-weight:900}
#homeTasksNotes .tn-tabs button[data-tn-open="note"]::before{content:"✎";display:inline-block;margin-left:7px;color:#8ab4ff;font-weight:900}
#modalBody>.base-modal-close{position:static!important;margin:0 0 18px 0!important;justify-self:start!important}

/* v35.2 screenshot fixes: inset modal close + restore task/note accent identity */
#modalBody>.base-modal-close{position:static!important;margin:8px 8px 20px 0!important;min-width:86px!important;height:44px!important;border-radius:14px!important}
#modalBody{padding-top:18px!important}
#homeTasksNotes .tn-tabs{gap:12px!important}
#homeTasksNotes .tn-tabs button{border-radius:16px!important;min-height:50px!important;font-weight:800!important;box-shadow:none!important}
#homeTasksNotes .tn-tabs button[data-tn-open="task"]{background:rgba(30,184,126,.14)!important;border-color:rgba(45,212,145,.55)!important;color:#49dda0!important}
#homeTasksNotes .tn-tabs button[data-tn-open="note"]{background:rgba(99,102,241,.15)!important;border-color:rgba(129,140,248,.58)!important;color:#a9b2ff!important}
#homeTasksNotes .tn-tabs button[data-tn-open="task"]::before{content:"✓";color:#35d693!important}
#homeTasksNotes .tn-tabs button[data-tn-open="note"]::before{content:"✎";color:#9ea8ff!important}

/* v35.3 focused visual fix — inset close, dedupe generic close, restore reference task/note colors */
#modalBody{padding:24px 18px 20px!important}
#modalBody>.base-modal-close{position:relative!important;inset:auto!important;top:auto!important;left:auto!important;right:auto!important;float:none!important;margin:4px 0 22px 0!important;min-width:86px!important;height:44px!important;min-height:44px!important;border-radius:14px!important}
#modalBody>.base-modal-close~button[type="submit"]:last-child:not(.primary):not(.danger),#modalBody>.base-modal-close~button.secondary:last-child[data-modal-close]{display:none!important}
#homeTasksNotes .tn-tabs button[data-tn-open="task"]{background:linear-gradient(180deg,#31a9ff,#087cf0)!important;border:1px solid #4db5ff!important;color:#fff!important;box-shadow:0 4px 0 rgba(0,78,171,.72),inset 0 1px 0 rgba(255,255,255,.25)!important}
#homeTasksNotes .tn-tabs button[data-tn-open="note"]{background:linear-gradient(180deg,#8a5cff,#6534ed)!important;border:1px solid #9b78ff!important;color:#fff!important;box-shadow:0 4px 0 rgba(66,31,169,.72),inset 0 1px 0 rgba(255,255,255,.22)!important}
#homeTasksNotes .tn-tabs button[data-tn-open="task"]::before,#homeTasksNotes .tn-tabs button[data-tn-open="note"]::before{display:none!important;content:none!important}
