/* Screen-only shared surfaces. Drawing geometry and printed documents stay independent. */
@media screen {
  .production-theme :is(.topbar, .view, dialog) :is(button, input, select, textarea, label, summary, h2, h3, h4, th) {
    letter-spacing: 0;
  }

  .production-theme :is(#dashboard, #estimates, #inventory, #settings, #expenses, #calendar, #legal, #legal2, #reports) {
    --line: #dce2e1;
    --muted: #61706c;
    font-size: 14px;
    line-height: 1.45;
  }

  .production-theme :is(.panel-head, .section-head, .reference-head) {
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
  }

  .production-theme :is(.panel-head, .section-head, .reference-head) > div:first-child {
    min-width: 0;
  }

  .production-theme :is(.panel-head, .section-head) :is(h3, h4) {
    font-size: 17px;
    line-height: 1.35;
    margin: 0;
    overflow-wrap: anywhere;
  }

  .production-theme :is(.panel-head, .section-head) p {
    margin: 4px 0 0;
    font-size: 13px;
    line-height: 1.45;
  }

  .production-theme :is(.section-actions, .stacked-actions, .form-actions, .expense-form-actions, .reference-actions) {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }

  .production-theme :is(.panel-head, .section-head, .reference-head, .stacked-actions) > button,
  .production-theme :is(.section-actions, .form-actions, .expense-form-actions, .reference-actions) button {
    font-size: 13px;
    line-height: 1.3;
    min-height: 36px;
    white-space: normal;
    word-break: normal;
    overflow-wrap: normal;
  }

  .production-theme :is(#dashboard, #estimates, #inventory, #expenses, #calendar, #legal, #legal2, #reports) .panel {
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    box-shadow: none;
  }

  .production-theme :is(#inventory, #estimates) .feature-panel {
    border: 0;
    border-top: 1px solid var(--line);
    border-radius: 0;
    box-shadow: none;
  }

  .production-theme :is(.form-grid, .reference-fields, .crew-form-grid, .expense-form) label {
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
  }

  .production-theme :is(.form-grid, .reference-fields, .crew-form-grid, .expense-form) :is(input, select, textarea) {
    max-width: 100%;
    min-height: 38px;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.4;
  }

  .production-theme :is(.form-grid, .reference-fields, .crew-form-grid, .expense-form) input:is([type=checkbox], [type=radio]) {
    min-height: 0;
  }

  .production-theme .form-grid { align-items: end; }
  .production-theme :is(.metrics, .operation-metrics, .inventory-stats) { font-variant-numeric: tabular-nums; }
  .production-theme .metric strong { font-size: 22px; line-height: 1.25; overflow-wrap: anywhere; }

  .production-theme .profitability-card > div:first-child {
    display: grid;
    gap: 6px;
    min-width: 0;
  }

  .production-theme .profitability-card > div:first-child strong { font-size: 14px; line-height: 1.4; }
  .production-theme .profitability-card > div:first-child span { font-size: 12px; line-height: 1.45; }
  .production-theme .profitability-recommendation { font-size: 13px; font-weight: 500; line-height: 1.45; }
  .production-theme .inventory-stats { grid-template-columns: repeat(auto-fit, minmax(125px, 1fr)); }
  .production-theme #inventoryProfitabilityRows { grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr)); }

  .production-theme #expenseForm > .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .production-theme #expenseSourceFields {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    padding-block: 12px;
    border-block: 1px solid var(--line);
  }
  .production-theme #expenseForm label:has(#expenseEstimateId) { grid-column: 1 / -1; }

  .production-theme .reference-head { justify-content: flex-start; }
  .production-theme .reference-head > div:first-child { flex: 1 1 180px; }
  .production-theme .reference-head h2 { font-size: 22px; }
  .production-theme .reference-toolbar { gap: 12px; }
  .production-theme .reference-record { padding-block: 14px; }
  .production-theme .reference-record > div { min-width: 0; }
  .production-theme .reference-record strong { line-height: 1.45; overflow-wrap: anywhere; }
  .production-theme .reference-record:hover { background: #f7faf9; }

  .production-theme :is(#referenceEditor, #itemDialog, #splitLineEditor) .dialog-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
  }

  .production-theme :is(#referenceEditor, #itemDialog, #splitLineEditor) .dialog-actions button {
    min-height: 38px;
    font-size: 13px;
    word-break: normal;
    white-space: normal;
  }

  .production-theme #itemDialog .item-kind-switch {
    display: grid;
    grid-template-columns: 1.3fr 1fr 1fr;
    gap: 4px;
    border-radius: 6px;
    padding: 4px;
  }
  .production-theme #itemDialog .item-kind-switch > button {
    width: auto;
    min-width: 0;
    min-height: 40px;
    padding: 8px 4px;
    font-size: 12px;
    line-height: 1.3;
  }

  .production-theme :is(#estimateSplit .split-line, .reference-record) :is(button, input):focus-visible {
    outline: 2px solid #2d65a8;
    outline-offset: 2px;
  }

  .production-theme #estimateSplit .split-product { background: #fff; }
  .production-theme #estimateSplit .split-line-name { line-height: 1.45; }
  .production-theme #estimateSplit .section-fold { font-size: 12px; }
  .production-theme #estimateForm > .form-head .form-actions { display: flex; width: auto; justify-content: flex-end; }
  .production-theme #estimateForm > .form-head .form-actions button { width: auto; }

  @media (min-width: 1181px) {
    .production-theme .topbar-navigation .tabs { justify-content: flex-start; padding-top: 8px; }
    .production-theme .topbar-navigation .tabs > * { flex-shrink: 0; }
  }

  @media (min-width: 681px) and (max-width: 1600px) {
    .production-theme .topbar-workspace { grid-template-columns: minmax(150px, 200px) minmax(140px, 1fr) auto; gap: 12px; }
    .production-theme .topbar-actions { grid-column: auto; overflow: visible; }
    .production-theme .topbar-actions .notification-button > span:not(.notification-count),
    .production-theme .topbar-actions .data-actions-menu > summary span,
    .production-theme .topbar-actions .data-actions-menu > summary .lucide:last-child { display: none; }
    .production-theme .topbar-actions .notification-button,
    .production-theme .topbar-actions .data-actions-menu > summary { width: 38px; min-width: 38px; padding: 0; justify-content: center; }
  }

  @media (min-width: 681px) and (max-width: 1100px) {
    .production-theme .topbar-actions > .action-with-icon span { display: none; }
    .production-theme .topbar-actions > .action-with-icon { width: 38px; min-width: 38px; padding: 0; justify-content: center; }
  }

  @media (max-width: 680px) {
    .production-theme .topbar-workspace { grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 12px 10px; }
    .production-theme .workspace-heading { grid-column: 1 / -1; grid-row: 1; }
    .production-theme .workspace-heading h2 { font-size: 19px; }
    .production-theme .topbar-workspace .eyebrow { display: none; }
    .production-theme .global-search-shell { grid-column: 1; grid-row: 2; max-width: none; }
    .production-theme .topbar-actions { display: flex; grid-column: 2; grid-row: 2; gap: 6px; overflow: visible; width: auto; }
    .production-theme .topbar-actions > * { width: auto; min-width: 0; flex: 0 0 auto; }
    .production-theme .topbar-actions > .action-with-icon,
    .production-theme .topbar-actions .notification-button { width: 36px; min-width: 36px; height: 36px; padding: 0; justify-content: center; }
    .production-theme .topbar-actions > .action-with-icon span { display: none; }
    .production-theme .topbar-actions .data-actions-menu > summary { width: 36px; min-width: 36px; height: 36px; padding: 0; justify-content: center; }
    .production-theme .topbar-actions .data-actions-menu > summary .lucide:last-child { display: none; }
    .production-theme .topbar-actions #undoAction { margin: 0; }
    .production-theme .notification-shell { margin: 0; }
    .production-theme .notification-panel { position: fixed; top: 118px; right: 10px; width: calc(100vw - 20px); max-width: none; }
    .production-theme .panel-head { align-items: stretch; }
    .production-theme :is(#dashboard, #calendar) .panel-head { align-items: flex-start; text-align: left; }
    .production-theme .data-actions-popover { position: fixed; top: 176px; right: 10px; width: min(290px, calc(100vw - 20px)); }

    .production-theme :is(.metrics, .operation-metrics, .inventory-stats) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .production-theme .metric { min-height: 76px; padding: 12px; border-top: 0; border-right: 1px solid var(--line); }
    .production-theme .metric:nth-child(2n) { border-right: 0; }
    .production-theme .metric:nth-child(n+3) { border-top: 1px solid var(--line); }
    .production-theme .metric strong { font-size: 18px; }
    .production-theme #dashboard .dashboard-grid > .panel:first-child :is(th, td):nth-child(3) { display: none; }
    .production-theme #dashboard .dashboard-grid > .panel:first-child th:first-child { width: 60%; }
    .production-theme #dashboard .dashboard-grid > .panel:first-child th:last-child { width: 40%; }
    .production-theme #dashboard .dashboard-grid > .panel:first-child td:last-child { font-size: 12px; text-overflow: clip; }
    .production-theme #dashboard .dashboard-grid > .panel:first-child td:first-child .muted { white-space: normal; font-size: 12px; }

    .production-theme .reference-head > div:first-child { flex-basis: 100%; }
    .production-theme .reference-head > button { flex: 1 1 140px; min-width: 0; width: auto; }
    .production-theme .reference-record { gap: 10px; }
    .production-theme .reference-actions button { min-width: 36px; min-height: 36px; }
    .production-theme #expenseForm > .form-grid,
    .production-theme #expenseSourceFields { grid-template-columns: minmax(0, 1fr); }
    .production-theme #calendarGrid { min-width: 0; grid-template-columns: repeat(7, minmax(0, 1fr)); }
    .production-theme #calendarGrid :is(.calendar-weekday, .calendar-day) { min-width: 0; padding: 5px; }
    .production-theme #calendarGrid .calendar-day { min-height: 82px; }
    .production-theme #calendarGrid .calendar-pill { max-width: 100%; padding: 4px 2px; font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .production-theme #calendarGrid .calendar-weekday { font-size: 11px; }
  }
}
