/* ASFOS uniform design layer: one look for controls, cards, tables and tabs.
   Loaded after the page styles; selectors are prefixed for specificity. */
:root{
  --u-line:#e5e7eb;
  --u-line-strong:#d1d5db;
  --u-text:#111827;
  --u-muted:#6b7280;
  --u-soft:#f9fafb;
  --u-accent:#111827;
  --u-radius:10px;
  --u-control-h:40px;
  --u-focus:0 0 0 3px rgba(17,24,39,.08);
}
html body{
  -webkit-font-smoothing:antialiased;
  text-rendering:optimizeLegibility;
}

/* Controls: one consistent field style everywhere */
html body input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=color]),
html body select,
html body textarea{
  background:#fff!important;
  border:1px solid var(--u-line-strong)!important;
  border-radius:var(--u-radius)!important;
  color:var(--u-text);
  font:inherit;
  font-size:14px;
  box-shadow:none!important;
  max-width:100%;
}
html body input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=color]),
html body select{min-height:var(--u-control-h)}
html body textarea{min-height:84px;padding:10px 12px}
html body input:focus,
html body select:focus,
html body textarea:focus{
  outline:0!important;
  border-color:var(--u-accent)!important;
  box-shadow:var(--u-focus)!important;
}
html body input::placeholder,
html body textarea::placeholder{color:#9ca3af}
html body input:disabled,
html body select:disabled,
html body textarea:disabled{background:var(--u-soft)!important;color:var(--u-muted)}

/* Buttons */
html body .btn,
html body button.btn{
  min-height:var(--u-control-h);
  border-radius:var(--u-radius);
  font-weight:600;
  font-size:14px;
  white-space:nowrap;
  transition:background .15s,border-color .15s,opacity .15s;
}
html body .btn:focus-visible,
html body button:focus-visible,
html body a:focus-visible{outline:2px solid var(--u-accent);outline-offset:2px}

/* Cards and panels */
html body .panel,
html body .kpi,
html body .financial-record-card{
  border:1px solid var(--u-line);
  border-radius:12px;
  box-shadow:none;
}

/* Tables: no awkward wrapping of dates/amounts, scroll instead of squash */
html body table{border-collapse:collapse;width:100%}
html body table th{
  font-size:12px;
  font-weight:600;
  color:var(--u-muted);
  text-transform:none;
  letter-spacing:0;
  white-space:nowrap;
  text-align:left;
}
html body table td{font-size:13px;vertical-align:middle}
html body table td:first-child,
html body table th:first-child{white-space:nowrap}
html body .table-wrap,
html body .asfos-budget-table-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch}

/* Budget: tabs, header and filters */
html body .asfos-budget-page,
html body .asfos-budget-table-card,
html body .asfos-budget-table-wrap,
html body .asfos-budget-head,
html body .asfos-budget-summary,
html body .asfos-budget-filterbar{min-width:0;max-width:100%;box-sizing:border-box}
html body #internalPageHost:has(.asfos-budget-page){overflow-x:hidden!important}
html body .asfos-budget-table{min-width:760px}
html body .asfos-budget-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px 16px;
  flex-wrap:wrap;
}
html body .asfos-budget-head h1{margin:0}
html body .asfos-budget-head p{margin:4px 0 0;color:var(--u-muted);font-size:13px}
html body .asfos-budget-actions{
  display:flex;
  align-items:center;
  gap:8px;
  flex:0 0 auto;
  min-width:0;
}
html body .asfos-budget-actions{flex-wrap:nowrap!important}
html body .asfos-budget-add-button{
  display:inline-flex!important;
  visibility:visible!important;
  opacity:1!important;
  flex:0 0 40px!important;
  width:40px!important;
  height:40px!important;
  min-width:40px!important;
  padding:0!important;
  align-items:center;
  justify-content:center;
  border:0!important;
  border-radius:10px!important;
  background:#111827!important;
  color:#fff!important;
}
html body .asfos-budget-add-button svg{width:18px!important;height:18px!important;stroke:#fff!important;fill:none!important;stroke-width:2!important}
html body .asfos-budget-switcher{
  display:inline-flex;
  flex-wrap:nowrap;
  gap:2px;
  padding:3px;
  background:#f3f4f6;
  border-radius:var(--u-radius);
  flex:0 0 auto;
}
html body .asfos-budget-switch{
  flex:0 0 auto;
  width:auto;
  min-width:0;
  white-space:nowrap;
  padding:7px 12px;
  font-size:13px!important;
  border:0;
  border-radius:8px;
  font-size:13px;
  font-weight:600;
  background:transparent;
  color:var(--u-muted);
  cursor:pointer;
}
html body .asfos-budget-switch.active{background:#fff;color:var(--u-text);box-shadow:0 1px 2px rgba(0,0,0,.08)}
html body .asfos-budget-filters,
html body .asfos-budget-filterbar,
html body .asfos-budget-toolbar{
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  gap:8px;
}
html body .asfos-budget-search{flex:1 1 220px;min-width:0}
html body .asfos-budget-filters{align-items:flex-end}
html body .asfos-budget-filters label{flex:0 1 auto;min-width:0}
html body .asfos-budget-filters input,
html body .asfos-budget-filters select{flex:none;height:var(--u-control-h);min-height:var(--u-control-h);padding:0 10px;font-size:13px;width:auto;min-width:130px}
html body .asfos-budget-filters select{min-width:150px}
html body .asfos-budget-search input{height:var(--u-control-h);min-height:var(--u-control-h);width:100%}
html body .asfos-budget-pagesize{white-space:nowrap}
html body .asfos-budget-pagesize select{min-width:70px;padding-right:28px}
html body .asfos-budget-table td,
html body .asfos-budget-table th{padding:8px 10px;line-height:1.35}
html body .asfos-budget-table td{overflow-wrap:anywhere}
html body .asfos-budget-table td:first-child,
html body .asfos-budget-table td:nth-last-child(-n+4){white-space:nowrap;overflow-wrap:normal}
html body .asfos-budget-table thead th{position:sticky;top:0;background:#fff;z-index:1}

/* Budget form fields keep the same style as every other field */
html body .asfos-budget-form-grid input,
html body .asfos-budget-form-grid select,
html body .asfos-budget-form-grid textarea,
html body .asfos-plan-card input,
html body .asfos-plan-card select,
html body .asfos-plan-card textarea{
  background:#fff!important;
  border:1px solid var(--u-line-strong)!important;
}

/* Responsive */
@media (max-width:900px){
  html body .asfos-plan-columns{grid-template-columns:1fr!important}
}
@media (max-width:760px){
  html body .asfos-budget-head{align-items:stretch}
  html body .asfos-budget-actions{width:100%;justify-content:space-between}
  html body .asfos-budget-switcher{flex:1 1 auto}
  html body .asfos-budget-switch{flex:1 1 auto;padding:6px 10px}
  html body .asfos-budget-filters input,
  html body .asfos-budget-filters select{width:100%;min-width:0}
  html body .asfos-budget-search{flex:1 1 100%}
  html body input,html body select,html body textarea{font-size:16px}
}
@media (prefers-reduced-motion:reduce){
  html body *{transition:none!important;animation:none!important}
}

/* Budget header: never let the action group be pushed outside the page */
html body .asfos-budget-page{box-sizing:border-box;padding-right:4px}
html body .asfos-budget-head{width:100%;padding-right:2px}
html body .asfos-budget-head > div:first-child{flex:1 1 auto;min-width:0}
html body .asfos-budget-actions{margin-left:auto;padding-right:2px}
html body .asfos-financial-planning{overflow-x:hidden}
html body .asfos-plan-columns > *{min-width:0}

@media (max-width:900px){
  html body.asfos-chatgpt-ui .asfos-budget-head{flex-wrap:wrap!important;row-gap:8px!important}
  html body.asfos-chatgpt-ui .asfos-budget-head > div:first-child{flex:1 1 100%!important}
  html body.asfos-chatgpt-ui .asfos-budget-head > .asfos-budget-actions{flex:1 1 100%!important;width:100%!important;margin-left:0!important}
  html body .asfos-budget-switcher{flex:1 1 auto}
  html body .asfos-budget-switch{flex:1 1 auto;padding:7px 8px}
  html body.asfos-chatgpt-ui .asfos-budget-head > .asfos-budget-actions{margin:0!important;box-sizing:border-box}
}

/* Reserve room for the add button so it can never be pushed out of view */
html body .asfos-budget-head > .asfos-budget-actions{position:relative;padding-right:48px!important;min-height:40px}
html body .asfos-budget-head .asfos-budget-add-button{position:absolute!important;right:0;top:50%;transform:translateY(-50%)}

html body .asfos-budget-switch{transition:none!important}
html body .asfos-budget-switcher{width:max-content;min-width:max-content}
@media (max-width:900px){html body .asfos-budget-switcher{width:auto;min-width:0}}

html body.asfos-chatgpt-ui .asfos-budget-switcher .asfos-budget-switch{
  flex:0 0 auto!important;
  width:auto!important;
  min-width:max-content!important;
  padding:7px 14px!important;
  white-space:nowrap!important;
}
@media (max-width:900px){
  html body.asfos-chatgpt-ui .asfos-budget-switcher .asfos-budget-switch{flex:1 1 auto!important;padding:7px 10px!important}
}
