:root{font:15px/1.55 system-ui;color:#18313d;background:#f1f5f7}*{box-sizing:border-box}body{margin:0}header,main{max-width:1200px;margin:auto;padding:24px}header{display:flex;align-items:center;justify-content:space-between;gap:20px;flex-wrap:wrap}h1{font-size:27px;margin:0}h2{font-size:20px}h1,h2,strong{font-weight:600}p{color:#536572}header p{margin:4px 0}label{display:grid;gap:6px}button,select,input{font:inherit;min-height:44px;padding:10px 14px;border:1px solid #cbd7df;border-radius:8px;background:white;color:#18313d}button{cursor:pointer}button:hover{border-color:#24715e}button:disabled{opacity:.5;cursor:default}nav{display:flex;gap:10px;flex-wrap:wrap;margin-bottom:24px}nav button[aria-current=true],#commit{background:#17594c;color:white}section{background:white;border:1px solid #dbe4e9;border-radius:14px;padding:22px}.grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px}.metric{padding:18px;background:#f3f7f8;border-radius:10px}.metric strong{display:block;font-size:25px}.scroll{overflow:auto}table{width:100%;border-collapse:collapse}td,th{padding:12px 10px;border-bottom:1px solid #e1e7eb;text-align:left;white-space:nowrap}th{font-weight:500;color:#536572}.batch{padding:14px 0;border-bottom:1px solid #dbe4e9;display:flex;justify-content:space-between;gap:18px;align-items:center}.ok{color:#17594c}.error{color:#a32d2d}#message:empty{display:none}[hidden]{display:none!important}small{display:block;color:#536572}button:focus-visible,input:focus-visible,select:focus-visible{outline:3px solid #83baa9;outline-offset:2px}@media(max-width:650px){header,main{padding:14px}.grid{grid-template-columns:1fr}section{padding:15px}.batch{flex-wrap:wrap}select{max-width:100%}}

.allocation{display:grid;grid-template-columns:repeat(auto-fit,minmax(165px,1fr));gap:12px;margin:20px 0}.allocation-card{padding:15px;border:1px solid #dbe4e9;border-radius:10px}.allocation-card strong{display:block;font-size:24px;margin:4px 0}.group-heading{background:#edf4f1}.group-heading th,.group-heading td{color:#183c31;font-weight:600}#allocation-info{font-size:13px}td:last-child,th:last-child{text-align:right}

dialog{width:min(640px,calc(100% - 28px));max-height:90vh;overflow:auto;border:1px solid #cbd7df;border-radius:14px;padding:24px;color:#18313d}dialog::backdrop{background:rgb(15 30 40 / .4)}dialog label{margin:12px 0}textarea{font:inherit;padding:10px;border:1px solid #cbd7df;border-radius:8px;resize:vertical}.actions{display:flex;gap:10px;flex-wrap:wrap;margin:16px 0}#group-save{background:#17594c;color:white}.group-button{padding:6px 10px;min-height:40px;font-size:13px}#group-error{color:#a32d2d}#instruments label{display:flex;align-items:center;gap:10px}#unclassified-only{min-height:20px;width:20px;height:20px}

.target-fields{display:grid;grid-template-columns:repeat(auto-fit,minmax(160px,1fr));gap:14px;margin:18px 0}#target-editor{margin:24px 0}#target-form>label{margin:16px 0}#target-error{color:#a32d2d}summary{cursor:pointer;padding:10px 0}#target-save{background:#17594c;color:white}

#cash-error{color:#a32d2d}#cash-save{background:#17594c;color:white}#cash-entry-rows button{margin:3px}

.settings-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:18px}.settings-grid form{display:grid;gap:12px;padding:16px;border:1px solid #dbe4e9;border-radius:10px}.settings-grid button{justify-self:start}#backup-list small{overflow-wrap:anywhere}#backup-create{background:#17594c;color:white}#settings h3{margin-top:24px}

#excel td:nth-child(2){white-space:normal;min-width:210px;max-width:260px}#excel td:last-child{white-space:normal;min-width:190px;max-width:230px;text-align:left}#excel th:last-child{text-align:left}#excel-save{margin-top:14px}#excel-month{max-width:300px}#excel-summary{margin:18px 0}

.closing-card{border:1px solid #dbe4e9;border-radius:12px;padding:18px;margin:20px 0}.closing-card>label{margin:12px 0}.closing-confirm{display:flex;align-items:center;gap:12px}.closing-confirm input{min-height:20px;width:20px;height:20px}#closing-month{max-width:230px}#closing-refresh{margin-top:12px}

#goal-form>label{margin:15px 0}#goal-summary{margin:20px 0}#goal-save{background:#17594c;color:white}#goal-error{color:#a32d2d}#goal-history p{white-space:pre-wrap}

.coverage-account{border-top:1px solid #dbe4e9;padding:12px 0;min-width:280px;max-width:560px;white-space:normal;text-align:left}.coverage-account h4{margin:8px 0}.coverage-account button{margin:5px 6px 5px 0}#import-request:empty{display:none}#import-request{padding:12px;border-left:3px solid #17594c;background:#f3f7f8}

.auth-panel{max-width:540px;margin:30px auto}.auth-panel form{display:grid;gap:15px}#auth-code{letter-spacing:2px}#auth-error,#access-error{color:#a32d2d}#access-code-result{font-weight:600;overflow-wrap:anywhere}#access-actions button{margin:6px 0}@media(max-width:650px){.auth-panel{margin:20px 14px}}

.mobile-nav{display:none}
#mobile-menu{width:min(580px,calc(100% - 24px))}
.mobile-menu-heading{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:16px}
.mobile-menu-heading h2{margin:0}
#mobile-menu nav{display:grid;grid-template-columns:1fr;gap:8px;margin:0}
#mobile-menu nav button{text-align:left;white-space:normal}

.portfolio-allocation{margin:20px 0}
.allocation-summary{display:grid;grid-template-columns:minmax(0,1fr);align-items:center;gap:12px}
.allocation-plot{width:100%;max-width:390px;justify-self:center}
.allocation-plot>svg{display:block;width:100%;height:auto}
.chart-total{font:600 12px system-ui;fill:#18313d}
.chart-caption{font:6px system-ui;fill:#536572}
.chart-share{font:600 5.5px system-ui;fill:#18313d}
.chart-share-light{fill:white}
.chart-share-outside{font-size:5px}
.allocation-legend{display:grid;gap:12px}
.allocation-legend-row{display:grid;grid-template-columns:14px minmax(0,1fr);align-items:center;gap:10px}
.allocation-legend-row small{font-size:13px}
.legend-swatch{width:12px;height:12px}
.portfolio-table{table-layout:fixed;width:100%}
.portfolio-table th,.portfolio-table td{white-space:normal;overflow-wrap:anywhere}
.portfolio-table th:first-child{width:36%}
.portfolio-table th:nth-child(2){width:12%}
.portfolio-table th:nth-child(3){width:17%}
.portfolio-table th:nth-child(4){width:19%}
.portfolio-table th:nth-child(5){width:16%}
.portfolio-table td:not(:first-child),.portfolio-table thead th:not(:first-child){text-align:right}
.portfolio-table .sector-heading th{text-align:center;background:#edf4f1;padding:14px 12px;border-radius:8px;color:#183c31;font-weight:600}
.portfolio-table .sector-heading small{margin-top:3px;color:#183c31;font-weight:400}
.portfolio-table .category-heading th{text-align:left;font-size:13px;background:#f7f9fa;color:#536572;padding-top:14px;padding-bottom:8px}
.portfolio-classification{margin-top:16px}

@media(max-width:650px){
  .allocation-summary{grid-template-columns:minmax(0,1fr);gap:16px}
  .allocation-plot{max-width:360px}
  .allocation-legend{gap:10px}
  .allocation-legend-row{font-size:14px}
  .allocation-legend-row strong{font-size:15px}
  .portfolio-scroll{overflow:visible}
  .portfolio-table{font-size:12px}
  .portfolio-table td,.portfolio-table thead th{padding:10px 4px;line-height:1.4}
  .portfolio-table thead th{font-size:11px}
  .portfolio-table th:first-child{width:32%}
  .portfolio-table th:nth-child(2){width:10%}
  .portfolio-table th:nth-child(3){width:18%}
  .portfolio-table th:nth-child(4){width:23%}
  .portfolio-table th:nth-child(5){width:17%}
  .portfolio-table .sector-heading th{font-size:14px;padding:12px 8px}
  .portfolio-table .category-heading th{font-size:12px;padding-left:4px}
  .portfolio-classification{width:100%}
}

@media(max-width:650px){
  :root{font-size:16px}
  header,main{width:100%;min-width:0;padding:12px}
  header{gap:14px;padding-top:max(16px,env(safe-area-inset-top))}
  header>div,header>label{width:100%;min-width:0}
  header p{font-size:13px;overflow-wrap:anywhere}
  h1{font-size:25px}
  h2{font-size:20px;overflow-wrap:anywhere}
  main{padding-bottom:calc(94px + env(safe-area-inset-bottom))}
  section{min-width:0;padding:16px;border-radius:14px}
  #section-nav{display:none}
  input,select,textarea{min-width:0;width:100%;max-width:100%;font-size:16px}
  input[type=checkbox]{width:22px;height:22px;min-height:22px;flex-shrink:0}
  input[type=file]{padding:10px 6px;font-size:14px}
  button{white-space:normal;overflow-wrap:anywhere;touch-action:manipulation;min-height:46px}
  p,small,label{overflow-wrap:anywhere}
  .grid,.settings-grid,.target-fields{grid-template-columns:minmax(0,1fr)}
  .metric{min-width:0;padding:15px}
  .metric strong{font-size:24px;overflow-wrap:anywhere}
  #summary .metric:last-child{order:-1;background:#17594c;color:#fff}
  .allocation{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
  .allocation-card{min-width:0;padding:12px}
  .allocation-card span{font-size:13px;overflow-wrap:anywhere}
  .allocation-card strong{font-size:22px}
  .batch{flex-direction:column;align-items:stretch;gap:10px}
  .batch>div,.batch>span{min-width:0;overflow-wrap:anywhere}
  .actions{flex-direction:column;align-items:stretch;gap:8px}
  .actions button,.settings-grid button{width:100%}
  .group-button{min-height:44px}
  dialog{width:calc(100% - 16px);max-height:calc(100dvh - 24px);padding:18px}
  dialog .target-fields{gap:12px}
  .closing-card{padding:14px}
  .coverage-account{min-width:0;max-width:100%}
  .coverage-account button{width:100%;margin:4px 0}
  #excel td:nth-child(2),#excel td:last-child{min-width:0;max-width:none}
  .mobile-cards{display:block;max-width:100%;width:100%}
  .mobile-cards>thead{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
  .mobile-cards>tbody{display:grid;gap:12px;width:100%;min-width:0}
  .mobile-cards tr{display:grid;min-width:0;border:1px solid #dbe4e9;border-radius:12px;overflow:hidden;background:#fff}
  .mobile-cards td{display:grid;grid-template-columns:minmax(92px,.85fr) minmax(0,1.15fr);gap:12px;min-width:0;max-width:100%;padding:9px 12px;white-space:normal;overflow-wrap:anywhere;text-align:right;border-bottom:1px solid #f0f3f5;font-size:14px}
  .mobile-cards td::before{content:attr(data-label);text-align:left;color:#536572;font-size:13px;font-weight:400}
  .mobile-cards td:first-child{display:block;background:#f3f7f8;text-align:left;font-weight:600;padding:12px}
  .mobile-cards td:first-child::before{display:block;margin-bottom:3px}
  .mobile-cards td:last-child{border-bottom:0;text-align:right}
  .mobile-cards td>button{grid-column:2;max-width:100%;padding:8px;font-size:14px}
  .mobile-cards td.cell-details{display:block;text-align:left}
  .mobile-cards td.cell-details::before{display:block}
  .mobile-cards td.cell-details summary{white-space:normal}
  .mobile-cards td.cell-details button{width:100%;margin:4px 0}
  .mobile-cards .group-heading{display:flex;flex-wrap:wrap;gap:4px 14px;padding:12px;background:#edf4f1;border:0;border-radius:10px}
  .mobile-cards .group-heading th{flex:1 1 100%;padding:0;border:0;white-space:normal}
  .mobile-cards .group-heading td{display:block;padding:0;background:none;border:0;white-space:normal;text-align:left}
  .mobile-cards .group-heading td::before{display:none}
  .mobile-cards .group-heading td:empty{display:none}
  .mobile-nav{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));position:fixed;left:0;right:0;bottom:0;z-index:20;margin:0;padding:8px 8px calc(8px + env(safe-area-inset-bottom));gap:4px;background:#fff;border-top:1px solid #dbe4e9;box-shadow:0 -4px 18px rgb(24 49 61 / .06)}
  .mobile-nav button{min-width:0;min-height:50px;padding:8px 3px;border-color:transparent;border-radius:10px;font-size:13px;line-height:1.25}
  .mobile-nav button[aria-current=true]{background:#17594c;color:#fff}
  #mobile-menu{max-height:calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom))}
}

.payment-month{margin:20px 0 26px}
.payment-summary-table{table-layout:fixed;margin-bottom:22px}
.payment-summary-table td,.payment-summary-table th{white-space:normal;overflow-wrap:anywhere}
.payment-summary-table th:first-child{width:24%}
.payment-summary-table th:last-child{width:30%}
.payment-total{font-weight:600;background:#f3f7f8}
.payment-net{padding:18px;background:#edf4f1;border-radius:10px;display:flex;justify-content:space-between;align-items:center;gap:16px;flex-wrap:wrap}
.payment-net strong{font-size:24px}
.payment-note{font-size:13px}
.payment-warning{padding:12px;background:#fff6df;border-radius:8px}
#cash-details{border-top:1px solid #dbe4e9;margin-top:22px}
@media(max-width:650px){.payment-summary-table{font-size:13px}.payment-summary-table th,.payment-summary-table td{padding:10px 5px}.payment-net{display:grid;gap:6px}}

.annual-chart{margin:26px 0;padding:16px;border:1px solid #dbe4e9;border-radius:12px}.annual-chart svg{display:block;width:100%;max-width:850px;margin:auto}.annual-axis{font:9px system-ui;fill:#536572}.annual-chart label{max-width:260px}.annual-chart p{margin-bottom:0}.annual-summary-note{grid-column:1/-1}#report-detail{margin-top:24px;border-top:1px solid #dbe4e9}@media(max-width:650px){.annual-chart{padding:10px 4px}.annual-chart label,.annual-chart p,.annual-chart h3{margin-left:8px;margin-right:8px}}

.growth-card{background:#f3f7f8;padding:14px;border-radius:10px;margin:14px 0}.growth-card h3{margin-top:0}.growth-legend{display:flex;flex-wrap:wrap;gap:12px;font-size:13px;margin:16px 0}.growth-legend>span{display:flex;align-items:center;gap:7px}.growth-legend svg{width:12px;height:12px;margin:0;flex-shrink:0}
