/* AVP V5.54 — Final UI polish
   Readability, tables, actions, compact states, form feedback and accessibility. */
:root{
  --v554-ink:#173529;
  --v554-muted:#64756b;
  --v554-line:#dce5df;
  --v554-line-soft:#e9efeb;
  --v554-focus:#4f8d55;
  --v554-danger:#a33a3a;
}

/* Typography: compact, but no longer tiny. */
body.app-shell{font-size:13px;line-height:1.45;color:var(--v554-ink)}
body.app-shell .page-heading p:not(.overline){font-size:12.5px!important;color:var(--v554-muted)!important}
body.app-shell .panel-heading h2{font-size:16px!important;line-height:1.25!important}
body.app-shell .panel-heading p{font-size:11.5px!important;line-height:1.45!important;color:var(--v554-muted)!important;max-width:820px}
body.app-shell .field>span,
body.app-shell label.field>span,
body.app-shell .form-label{font-size:11px!important;line-height:1.25!important;letter-spacing:.015em!important;color:#52675b!important;font-weight:750!important;text-transform:none!important}
body.app-shell :is(input,select,textarea){font-size:13px!important;color:#233c2e}
body.app-shell :is(.helper-note,.td-sub,.ledger-entry small,.metric small){font-size:10.75px!important;line-height:1.45!important}
body.app-shell .metric-top{font-size:11px!important}

/* Primary actions always read as primary; destructive actions stay visually separate. */
body.app-shell :is(.heading-actions,.panel-actions,.order-invoice-actions,.inline-actions){align-items:center!important;gap:8px!important}
body.app-shell .panel-actions{display:flex!important;justify-content:flex-end!important;flex-wrap:wrap!important;margin-top:14px!important}
body.app-shell :is(.panel-actions,.heading-actions) :is(.btn-danger,.text-danger){margin-left:auto!important}
body.app-shell .btn-danger{background:#a43d3d!important;border-color:#a43d3d!important;color:#fff!important}
body.app-shell .text-danger{color:#9d3939!important;border-color:#e6caca!important;background:#fffafa!important}
body.app-shell .btn-small,body.app-shell .mini-btn{min-height:34px!important;padding:7px 10px!important;font-size:11px!important}

/* Status chips: never stretch across grid/table cells. */
body.app-shell .status{
  width:max-content!important;max-width:100%!important;justify-self:start!important;align-self:center!important;
  flex:0 0 auto!important;padding:4px 8px!important;border-radius:999px!important;
  font-size:10.5px!important;line-height:1.2!important;letter-spacing:0!important;
}
body.app-shell .status::before{width:5px!important;height:5px!important;flex:0 0 5px!important}
body.app-shell .invoice-link>.status,
body.app-shell .ledger-entry>.status{justify-self:end!important}

/* Tables: stronger hierarchy, sticky headers, predictable numeric/action columns. */
body.app-shell .table-scroll{border:1px solid var(--v554-line-soft)!important;background:#fff!important;max-height:min(68vh,760px)}
body.app-shell .data-table{font-size:12.5px!important;font-variant-numeric:tabular-nums}
body.app-shell .data-table thead{position:sticky;top:0;z-index:3;background:#f5f8f5!important;box-shadow:0 1px 0 var(--v554-line)!important}
body.app-shell .data-table th{
  font-size:10.5px!important;letter-spacing:.045em!important;color:#67786e!important;
  padding:11px 12px!important;background:#f5f8f5!important;
}
body.app-shell .data-table td{padding:12px!important;border-bottom:1px solid #edf1ee!important;line-height:1.4!important}
body.app-shell .data-table tbody tr{transition:background .12s ease}
body.app-shell .data-table tbody tr:hover{background:#f8fbf8!important}
body.app-shell .data-table tr:last-child td{border-bottom:0!important}
body.app-shell .data-table :is(.is-num-col){text-align:right!important;font-variant-numeric:tabular-nums;white-space:nowrap}
body.app-shell .data-table :is(.is-status-col){width:1%;white-space:nowrap}
body.app-shell .data-table :is(.is-action-col){width:1%;white-space:nowrap;text-align:right!important}
body.app-shell .data-table :is(.is-id-col){white-space:nowrap;font-variant-numeric:tabular-nums}
body.app-shell .data-table td.is-id-col :is(strong,a),
body.app-shell .data-table td.is-id-col{font-weight:750;color:#244936}
body.app-shell .data-table td.is-action-col .inline-actions{justify-content:flex-end!important;flex-wrap:nowrap!important}

/* Quiet empty states: absence of data should not dominate a page. */
body.app-shell .empty-state{
  display:grid!important;grid-template-columns:auto minmax(0,1fr) auto;grid-template-rows:auto auto;
  column-gap:11px!important;row-gap:2px!important;align-items:center!important;text-align:left!important;
  min-height:0!important;padding:12px 13px!important;border:1px dashed #dbe4dd!important;border-radius:8px!important;background:#fafcfa!important;
}
body.app-shell .empty-state>svg{grid-row:1/3;width:20px!important;height:20px!important;color:#7c9c7b!important}
body.app-shell .empty-state>h3{grid-column:2;margin:0!important;font-size:12px!important;color:#385142!important}
body.app-shell .empty-state>p{grid-column:2;margin:0!important;font-size:10.75px!important;color:#78877e!important}
body.app-shell .empty-state>.btn,body.app-shell .empty-state>a{grid-column:3;grid-row:1/3}
body.app-shell .order-empty-state{
  display:grid!important;grid-template-columns:auto minmax(0,1fr);grid-template-rows:auto auto;
  column-gap:10px!important;row-gap:1px!important;justify-items:start!important;text-align:left!important;
  padding:12px 13px!important;min-height:0!important;
}
body.app-shell .order-empty-state>svg{grid-row:1/3;width:20px!important;height:20px!important;margin-top:1px}
body.app-shell .order-empty-state>strong{font-size:11.5px!important}
body.app-shell .order-empty-state>span{font-size:10.5px!important;max-width:none!important}

/* Task-specific canvas widths: registers wide, settings/forms readable. */
body.app-shell:is(.page-settings,.page-profile,.page-payment_terms,.page-sharing,.page-system_health) .content{max-width:1180px!important}
body.app-shell:is(.page-settings,.page-profile,.page-payment_terms,.page-sharing) .form-stack{max-width:920px}
body.app-shell:is(.page-orders,.page-invoices,.page-product_management,.page-customer_cash,.page-commission_center,.page-import_center) .content{max-width:1580px!important}

/* Advanced/optional controls are quiet until opened. */
body.app-shell details{
  border-color:var(--v554-line-soft)!important;box-shadow:none!important;
}
body.app-shell details>summary{min-height:38px;display:flex;align-items:center;cursor:pointer;font-size:11.5px!important;color:#496353!important}
body.app-shell details[open]>summary{color:#245c35!important}

/* Unsaved edit feedback. JS adds .has-unsaved-changes to meaningful POST forms. */
body.app-shell form.has-unsaved-changes :is(button[type="submit"],input[type="submit"]):not(.btn-danger):not(.text-danger){
  box-shadow:0 0 0 3px rgba(79,141,85,.12)!important;border-color:#6c9f70!important;
}
body.app-shell form.has-unsaved-changes .form-dirty-indicator{display:inline-flex!important}
body.app-shell .form-dirty-indicator{
  display:none;align-items:center;gap:6px;width:max-content;margin:8px 0 0;padding:5px 8px;
  border-radius:999px;background:#fff7e7;color:#805d1e;font-size:10.5px;font-weight:750;
}
body.app-shell .form-dirty-indicator::before{content:"";width:6px;height:6px;border-radius:50%;background:#c58b28}

/* Clear keyboard focus and comfortable click targets. */
body.app-shell :is(a,button,input,select,textarea,summary):focus-visible{
  outline:3px solid rgba(79,141,85,.26)!important;outline-offset:2px!important;
}
body.app-shell :is(input,select,textarea):focus{border-color:#76a37a!important;box-shadow:0 0 0 3px rgba(79,141,85,.08)!important}
body.app-shell :is(.btn,.mini-btn,.nav-link,summary){touch-action:manipulation}
body.app-shell .search-clear{min-width:32px!important;min-height:32px!important}

/* Identifiers should be easy to scan without looking like ordinary prose. */
body.app-shell :is(.order-id,.customer-id,.record-id,.ops-card-sku,.pricing-product-sku){font-variant-numeric:tabular-nums;letter-spacing:.025em}

/* High-frequency order document screen: keep help copy minimal and rows dense. */
.order-workspace .order-document-panel .panel-heading{margin-bottom:10px!important}
.order-workspace .order-document-panel .panel-heading p:empty{display:none!important}
.order-workspace .order-invoice-list .invoice-link{padding:11px 12px!important;border-radius:8px!important}
.order-workspace .order-documents-secondary{gap:18px!important}

@media(max-width:760px){
  body.app-shell .empty-state{grid-template-columns:auto 1fr!important}
  body.app-shell .empty-state>.btn,body.app-shell .empty-state>a{grid-column:1/-1;grid-row:auto;width:100%;margin-top:7px}
  body.app-shell .data-table td.is-action-col .inline-actions{flex-wrap:wrap!important}
  body.app-shell .status{font-size:10px!important}
}
