:root { --app-primary: #15803d; --app-ink: #14261c; --app-muted: #66746c; --app-line: #dfe7e1; --app-bg: #f5f8f6; --app-sidebar: 256px; --app-header: 72px; }
@font-face { font-family: "Material Symbols Outlined"; src: url("material-symbols-outlined.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: block; }
.material-symbols-outlined { font-family: "Material Symbols Outlined"; font-weight: 400; font-style: normal; font-size: 24px; line-height: 1; letter-spacing: normal; text-transform: none; display: inline-block; white-space: nowrap; word-wrap: normal; direction: ltr; font-feature-settings: "liga"; -webkit-font-smoothing: antialiased; }
[class*="font-body"], [class*="font-label"], [class*="font-headline"] { font-family: Inter, "Segoe UI", Arial, sans-serif; }
[class*="font-data-mono"] { font-family: "JetBrains Mono", Consolas, monospace; }
html { scrollbar-gutter: stable; }
body.app-body, body.app-login { margin: 0; color: var(--app-ink); background: var(--app-bg); font-family: Inter, "Segoe UI", Arial, sans-serif; font-size: 14px; line-height: 1.5; }
body.app-body { overflow-x: hidden; }
.app-frame { margin-left: var(--app-sidebar); }
.app-sidebar { position: fixed; inset: 0 auto 0 0; width: var(--app-sidebar); background: #fff; border-right: 1px solid var(--app-line); z-index: 50; display: flex; flex-direction: column; }
.app-brand { height: var(--app-header); padding: 0 22px; display: flex; align-items: center; gap: 11px; border-bottom: 1px solid var(--app-line); text-decoration: none; color: var(--app-ink); }
.app-brand img { width: 38px; height: 38px; object-fit: contain; }
.app-brand strong { display: block; font-size: 18px; font-weight: 750; letter-spacing: -.5px; }
.app-brand small { display: block; color: var(--app-muted); font-size: 9px; font-weight: 650; letter-spacing: 1.4px; margin-top: 2px; }
.app-nav-label { margin: 27px 24px 12px; color: #86948a; font-size: 10px; font-weight: 700; letter-spacing: 1.5px; }
.app-sidebar nav { padding: 0 12px; display: flex; flex-direction: column; gap: 6px; }
.app-nav-link { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 8px; color: #56665c; font-size: 12px; font-weight: 600; text-decoration: none; min-height: 44px; }
.app-nav-link svg, .app-header button svg { flex-shrink: 0; width: 20px; height: 20px; }
.app-nav-link:hover { color: var(--app-primary); background: #edf6ef; }
.app-nav-link[aria-current="page"] { color: #fff; background: var(--app-primary); box-shadow: 0 3px 8px #15803d20; }
.app-sidebar-footer { margin-top: auto; padding: 22px 18px; border-top: 1px solid var(--app-line); display: flex; align-items: center; gap: 9px; }
.app-status-dot { height: 7px; width: 7px; border-radius: 50%; background: var(--app-primary); }
.app-sidebar-footer strong { display: block; font-size: 11px; font-weight: 600; }
.app-sidebar-footer small { display: block; color: var(--app-muted); font-size: 9px; margin-top: 3px; }
.app-header { position: fixed; top: 0; left: var(--app-sidebar); right: 0; height: var(--app-header); padding: 0 28px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--app-line); background: #fffffffa; z-index: 40; }
.app-header-left, .app-header-right { display: flex; align-items: center; gap: 18px; }
.app-breadcrumb { font-size: 12px; color: var(--app-muted); }
.app-breadcrumb span { color: #b2bdb5; padding: 0 10px; }
.app-breadcrumb strong { color: var(--app-ink); font-weight: 600; }
.app-reference-badge { border: 1px solid #d3e8d8; border-radius: 30px; padding: 4px 10px; color: #257741; background: #f0f8f2; font-size: 10px; font-weight: 600; }
.app-account { text-align: right; }
.app-account strong { display: block; font-size: 12px; font-weight: 600; }
.app-account small { display: block; color: var(--app-muted); font-size: 10px; }
.app-avatar { border-radius: 50%; background: #e7f1e9; color: #267844; width: 34px; height: 34px; display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.app-header button { padding: 8px; border-radius: 6px; color: #6d7b71; }
.app-header button:hover { background: #edf3ee; }
.app-menu, .app-nav-backdrop { display: none; }
main.app-main { padding: calc(var(--app-header) + 28px) 28px 40px !important; min-height: 100vh; width: 100%; display: flex; flex-direction: column; gap: 24px; background: var(--app-bg); }
.app-main > * { min-width: 0; }
.app-page-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.app-page-heading h1 { margin: 0; font-size: 26px; line-height: 1.3; font-weight: 700; letter-spacing: -.8px; color: var(--app-ink); }
.app-page-heading p { font-size: 12px; color: var(--app-muted); margin: 7px 0 0; }
.app-page-label { font-size: 10px; color: #8a978f; white-space: nowrap; }
.app-main [class*="rounded-xl"] { border-radius: 12px; }
.app-main [class*="bg-surface-container-lowest"] { background-color: #fff; border-color: var(--app-line); }
.app-main [class*="bg-surface-container-low"], .app-main [class*="bg-surface-container-high"] { border-color: var(--app-line); }
.app-main [class*="shadow"] { box-shadow: 0 2px 5px #18332205; }
.app-main h2, .app-main h3 { color: var(--app-ink); }
.app-main table { width: 100%; border-collapse: collapse; font-size: 12px; }
.app-main thead { background: #f6f9f7; }
.app-main th { color: #64736a; font-size: 10px; font-weight: 650; text-align: left; }
.app-main th, .app-main td { padding: 12px 14px; border-color: var(--app-line); }
.app-main tbody tr:hover { background: #f8fbf9; }
.app-main td a { color: var(--app-primary); font-weight: 600; }
.app-main input:not([type="checkbox"]), .app-main select { border: 1px solid #dce5de; border-radius: 7px; min-height: 36px; font-size: 12px; max-width: 100%; background-color: #fff; }
.app-main input:focus, .app-main select:focus { outline: 2px solid #15803d40; outline-offset: 1px; }
.app-main button { border-radius: 7px; }
.app-main button:disabled { opacity: .45; cursor: not-allowed; }
.app-main button[class*="bg-primary"], #btn-new-formula { background: var(--app-primary) !important; color: #fff !important; box-shadow: none !important; }
.app-main #formula-fields, .app-main #premix-reference { order: 0; }
.app-main .app-page-heading { order: -1; }
.app-main #formula-fields { background: #fff; padding: 20px; border: 1px solid var(--app-line); border-radius: 12px; gap: 16px; }
#formula-fields label { font-size: 11px; font-weight: 600; color: var(--app-muted); flex: 1 1 160px; }
#formula-fields input, #formula-fields select { width: 100%; margin-top: 6px; color: var(--app-ink); }
.app-login button[type="submit"] { background: var(--app-primary); border-radius: 8px; }
.app-nav-link:focus-visible, .app-header button:focus-visible { outline: 3px solid #89cda0; outline-offset: 3px; }
[hidden] { display: none !important; }
.app-panel { padding: 22px; background: #fff; border: 1px solid var(--app-line); border-radius: 12px; min-width: 0; }
.app-panel h2, .app-dialog h2 { margin: 0 0 16px; font-size: 18px; font-weight: 650; }
.app-panel h3, .app-dialog h3 { margin: 20px 0 12px; font-size: 14px; font-weight: 650; }
.app-toolbar, .app-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-bottom: 20px; }
.app-formulation-actions { position: sticky; top: calc(var(--app-header) + 8px); z-index: 30; box-shadow: 0 4px 16px #14261c14; padding: 12px 16px; }
.app-formulation-actions .app-toolbar { margin-bottom: 0; align-items: center; }
.app-button { display: inline-flex; justify-content: center; align-items: center; padding: 8px 12px; min-height: 36px; border: 1px solid var(--app-line); border-radius: 7px; font-size: 12px; font-weight: 600; color: #41614b; background: #fff; text-decoration: none; cursor: pointer; white-space: nowrap; }
.app-button:hover { background: #f0f6f1; border-color: #b6d2be; }
.app-button.primary { background: var(--app-primary); border-color: var(--app-primary); color: #fff; }
.app-button.primary:hover { background: #116b32; }
.app-button:disabled { opacity: .45; cursor: not-allowed; }
.app-button:focus-visible { outline: 3px solid #89cda0; outline-offset: 2px; }
.app-filters label, .app-toolbar label, .app-editor label, .app-form-grid label, .app-auth label { display: flex; flex-direction: column; gap: 6px; color: var(--app-muted); font-size: 11px; font-weight: 600; }
.app-filters label { flex: 1 1 155px; }
.app-filters input, .app-filters select, .app-toolbar input, .app-form-grid input, .app-editor input, .app-editor select, .app-auth input { width: 100%; border: 1px solid var(--app-line); border-radius: 7px; padding: 8px 10px; min-height: 38px; color: var(--app-ink); background: #fff; font-size: 12px; }
.app-table-scroll { width: 100%; overflow-x: auto; border: 1px solid var(--app-line); border-radius: 9px; }
.app-table-scroll table { width: 100%; border-collapse: collapse; font-size: 12px; }
.app-table-scroll th, .app-table-scroll td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--app-line); }
.app-table-scroll th { background: #f5f8f6; color: var(--app-muted); font-size: 10px; font-weight: 650; }
.app-table-scroll tr:last-child td { border-bottom: 0; }
.app-row-actions { display: flex; gap: 6px; flex-wrap: nowrap; }
.app-row-actions .app-button { padding: 5px 8px; min-height: 30px; font-size: 10px; }
.app-note { color: var(--app-muted); font-size: 12px; line-height: 1.7; margin: 14px 0; }
.app-empty { text-align: center !important; padding: 30px !important; color: var(--app-muted); }
.app-pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; font-size: 11px; color: var(--app-muted); margin-top: 18px; }
.app-pagination > div { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.app-pagination label { display: inline-flex; align-items: center; gap: 6px; }
.app-pagination select { padding: 6px; }
.app-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.app-metric small { text-transform: uppercase; letter-spacing: .8px; font-size: 10px; color: var(--app-muted); }
.app-metric strong { display: block; font-size: 26px; line-height: 1.4; font-weight: 700; margin-top: 7px; word-break: break-word; }
.app-metric p { font-size: 11px; color: var(--app-muted); }
.app-dashboard-charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.app-dashboard-charts h3 { margin: 0 0 12px; font-size: 15px; }
.app-chart-bars { list-style: none; padding: 0; margin: 0; display: grid; gap: 16px; max-height: 360px; overflow-y: auto; }
.app-chart-label { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 6px; font-size: 12px; }
.app-chart-label > :first-child { min-width: 0; overflow-wrap: anywhere; }
.app-chart-label strong { flex-shrink: 0; color: var(--app-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.app-chart-track { height: 12px; background: #eef3ef; border-radius: 4px; overflow: hidden; }
.app-chart-fill { height: 100%; background: var(--app-primary); border-radius: 4px; }
#dashboard-status-chart .app-chart-fill { background: #397a9c; }
#dashboard-cost-chart .app-chart-fill { background: #b77b24; }
.app-dashboard-charts a { color: var(--app-primary); text-underline-offset: 3px; }
.app-chart-select { display: grid; gap: 6px; font-size: 11px; color: var(--app-muted); }
.app-chart-select select { width: 100%; padding: 8px 10px; color: var(--app-ink); }
.app-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.app-main #formula-fields { padding: 0; border: 0; margin-top: 20px; }
#formula-ingredients input { width: 110px; padding: 6px 10px; }
.app-dialog { width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: auto; border: 1px solid var(--app-line); border-radius: 14px; padding: 26px; color: var(--app-ink); background: #fff; box-shadow: 0 20px 80px #14261c30; }
.app-dialog::backdrop { background: #14261c60; }
.app-editor-content { display: flex; flex-direction: column; gap: 16px; }
.app-dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.app-nutrient-row { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 8px; margin: 8px 0; }
.app-nutrient-row > * { min-width: 0; }
.app-nutrient-row.with-tolerance { grid-template-columns: 1.7fr 1fr .7fr 1fr auto; align-items: end; }
.app-nutrient-row .app-tolerance { display: flex; flex-direction: column; gap: 4px; font-size: 10px; color: var(--app-muted); }
.app-tolerance-controls { display: grid; grid-template-columns: minmax(0, 1fr) minmax(48px, .8fr); gap: 4px; }
.app-tolerance-controls > * { min-width: 0; }
.app-vitamin-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 16px; margin: 12px 0; border: 1px solid var(--app-line); border-radius: 8px; }
.app-form-error { color: #a33128; background: #fff1ee; padding: 12px; border-radius: 8px; font-size: 12px; }
.app-toast { position: fixed; bottom: 24px; right: 24px; z-index: 100; max-width: min(460px, calc(100vw - 32px)); background: #edf8ef; border: 1px solid #b9d9c2; color: #185d2d; padding: 12px 16px; border-radius: 9px; box-shadow: 0 5px 25px #14261c20; font-size: 12px; }
.app-toast.error { color: #9d332b; background: #fff0ed; border-color: #efc2ba; }
.app-auth { width: min(1000px, calc(100% - 40px)); min-height: 100vh; margin: auto; display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: 50px; padding: 60px 0; }
.app-auth-brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--app-ink); font-size: 16px; }
.app-auth-brand img { width: 44px; height: 44px; }
.app-auth-intro h1 { margin: 30px 0 18px; font-size: 34px; font-weight: 700; line-height: 1.3; letter-spacing: -1px; }
.app-auth-intro > p { color: var(--app-muted); }
.app-auth-card { padding: 30px; }
.app-auth form { display: flex; flex-direction: column; gap: 18px; }
.app-auth-card h2 { margin-top: 24px; }
.app-password { display: flex; gap: 8px; }
.app-password input { min-width: 0; }
@media (max-width: 1000px) { .app-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) {
  .app-dashboard-charts { grid-template-columns: 1fr; }
  .app-panel, .app-dialog { padding: 16px; }
  .app-form-grid { grid-template-columns: 1fr; }
  .app-nutrient-row { grid-template-columns: 1fr 1fr; }
  .app-nutrient-row.with-tolerance { grid-template-columns: 1fr 1fr; }
  .app-nutrient-row select { grid-column: 1 / -1; }
  .app-vitamin-row { grid-template-columns: 1fr; }
  .app-auth { grid-template-columns: 1fr; gap: 24px; padding: 26px 0; }
  .app-auth-intro h1 { font-size: 27px; }
  .app-metric strong { font-size: 23px; }
}
@media print {
  .app-sidebar, .app-header, .app-toolbar, .app-filters, .app-pagination, .app-toast, .app-nav-backdrop, .app-formulation-actions, noscript { display: none !important; }
  .app-frame { margin: 0; }
  main.app-main { padding: 0 !important; background: #fff; }
  .app-panel { border: 0; padding: 8px 0; }
  .app-table-scroll { overflow: visible; }
  .app-table-scroll table { min-width: 0 !important; }
  body[data-print="profile"] .app-main > .app-panel:first-of-type, body[data-print="report"] #report-index { display: none !important; }
}
@media (max-width: 1100px) { .app-reference-badge, .app-page-label { display: none; } .app-header { padding: 0 22px; } main.app-main { padding-left: 22px !important; padding-right: 22px !important; } }
@media (max-width: 800px) {
  .app-frame { margin-left: 0; }
  .app-sidebar { transform: translateX(-100%); transition: transform .18s ease; }
  .app-header { left: 0; padding: 0 16px; }
  .app-menu { display: block; }
  .app-header-left, .app-header-right { gap: 10px; }
  .app-account small, .app-breadcrumb { display: none; }
  .app-nav-open .app-sidebar { transform: translateX(0); }
  .app-nav-open .app-nav-backdrop { display: block; position: fixed; inset: 0; background: #14261c60; z-index: 45; }
  main.app-main { padding: calc(var(--app-header) + 20px) 16px 28px !important; gap: 20px; }
  .app-page-heading h1 { font-size: 23px; }
  .app-main table { min-width: 620px; }
  .app-main #formula-fields { padding: 16px; }
  .app-main div.flex:not(.flex-col) { flex-wrap: wrap; min-width: 0; }
  .app-main .grid > * { min-width: 0; }
  .app-main button { height: auto; min-height: 36px; }
  .app-main [class*="overflow-x-auto"] { max-width: 100%; }
}
/* Formulation target comparisons remain readable without relying on color. */
.app-target { display: inline-block; padding: 4px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; background: #eef1f3; color: #46515a; }
.app-target.on_target, .app-target.within_target { background: #e0f2e7; color: #185b36; }
.app-target.below_target { background: #fee2e2; color: #991b1b; }
.app-target.above_target { background: #fef3c7; color: #854d0e; }
.app-target.not_comparable { background: #fbe5e5; color: #8d2424; }
@media (max-width: 720px) {
  .app-formulation-actions { padding: 8px; }
  .app-formulation-actions .app-toolbar { flex-wrap: nowrap; overflow-x: auto; padding: 2px; gap: 8px; }
  .app-formulation-actions .app-button { flex: 0 0 auto; }
}
#formula-ingredients input { width: 110px; }
.app-dialog:has([aria-label="Formula to compare"]), .app-dialog[aria-label="Least-cost proposal"] { max-width: 1000px; width: calc(100% - 32px); }
