/* List-first workspace. Screen-only rules preserve printed stock lists. */
@media screen {
  :root {
    --text: #23384a;
    --text-sub: #647585;
    --primary: #1d607a;
    --primary-strong: #194c65;
    --line: #dfe6eb;
    --surface: #ffffff;
    --radius: 14px;
    --shadow: 0 18px 55px #1b35461a;
    --shadow-soft: 0 2px 8px #1b354605;
  }
  body {
    background: linear-gradient(135deg, #f3f6f8, #f8f9fa 65%, #f0f5f5);
    color: var(--text);
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    line-height: 1.5;
  }
  button, input, select, textarea { font-family: inherit; }
  button, select { touch-action: manipulation; }
  .app-shell { max-width: 1240px; padding: 26px 30px 48px; }
  .top-bar { justify-content: flex-start; gap: 14px; padding: 0 0 12px; }
  .top-bar::before {
    content: "EP"; display: grid; place-items: center; flex: 0 0 44px;
    width: 44px; height: 44px; border-radius: 13px; background: #203e53;
    color: #fff; font-size: 1rem; font-weight: 700; letter-spacing: -.5px;
    box-shadow: inset 0 -3px 0 #577f89;
  }
  .top-bar h1 { font-size: 1rem; letter-spacing: .025em; margin: 0; line-height: 1.5; }
  .top-bar .subtitle { font-size: .76rem; margin: 2px 0 0; color: var(--text-sub); }
  .host-status { font-size: .71rem; color: #607982; margin: 0 0 23px 58px; }
  .alerts:empty { display: none; }
  .app-shell > main { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 26px; align-items: start; }
  .tab-bar {
    grid-column: 1; grid-row: 1; display: flex; flex-direction: column; gap: 6px;
    width: 100%; max-width: none; padding: 10px; background: #fff;
    border: 1px solid var(--line); border-radius: 15px; position: sticky; top: 24px;
  }
  .tab-item {
    display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
    padding: 12px; min-height: 48px; border: 0; border-radius: 9px;
    color: #627380; font-size: .84rem; background: transparent; box-shadow: none;
    transition: background-color .15s, color .15s;
  }
  .tab-item svg { width: 20px; height: 20px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
  .tab-item:hover { background: #f3f6f8; }
  .tab-item.active { background: #e9f2f5; color: #18566d; box-shadow: inset 3px 0 0 #29778a; }
  .tab-panels { grid-column: 2; grid-row: 1; min-width: 0; }
  #inventory.panel.active { display: flex; flex-direction: column; gap: 12px; }
  #inventory > * { min-width: 0; }
  .card { border-radius: 13px; border-color: var(--line); background: #fff; }
  #inventory .quick-actions {
    order: 0; display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: 14px; border: 0; padding: 0 0 5px; background: transparent;
  }
  .workspace-title h2 { margin: 0; font-size: 1.7rem; letter-spacing: -.045em; line-height: 1.2; }
  .workspace-title p { margin: 6px 0 0; font-size: .77rem; color: var(--text-sub); }
  .quick-actions .actions-grid { display: flex; gap: 9px; margin: 0; }
  .btn { border-radius: 9px; min-height: 44px; padding: 10px 16px; font-size: .82rem; font-weight: 700; box-shadow: none; }
  .btn:hover { background: #f4f7f9; }
  .btn-primary, .btn-primary:hover { background: #215d77; border: 1px solid #215d77; color: #fff; }
  .btn-primary:hover { background: #174a60; }
  input, select, textarea { border-radius: 9px; color: var(--text); border-color: #d7e1e8; min-height: 44px; }
  input:focus, select:focus, textarea:focus { outline: 3px solid #24758c22; border-color: #397b91; }
  :focus-visible { outline-offset: 3px; }
  #inventory .inventory-search { order: 1; margin: 0; padding: 15px 17px; gap: 7px; }
  .inventory-search > label { font-size: .74rem; color: #526b7d; font-weight: 700; }
  .inventory-search .search-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto 180px; align-items: center; gap: 12px; margin: 0; }
  .search-actions label { font-size: .73rem; color: var(--text-sub); }
  .inventory-search input { min-height: 44px; background: #f8fafb; font-size: .85rem; }
  .inventory-search select { width: 100%; font-size: .8rem; background: #fff; }
  .inventory-search p { font-size: .68rem; color: #72828d; }
  .stock-help-mobile { display: none; }
  #inventory .filter-details { order: 2; margin: 0; padding: 0 14px; border: 1px solid var(--line); background: #ffffffa6; }
  .filter-details > summary { padding: 10px 0; font-size: .75rem; color: #546d7d; }
  .filter-details .filters { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin: 4px 0 14px; }
  .filter-details .filters label { font-size: .72rem; }
  #inventory .product-detail-region, #inventory > #products-grid { order: 3; }
  .product-detail-region:empty, .product-detail-region:has(#products-grid:empty) { display: none; }
  #inventory .stock-list-card { order: 4; margin: 0; border: 1px solid #dbe4e9; box-shadow: 0 4px 18px #23394c05; }
  .stock-list th { background: #f5f8fa; font-size: .68rem; color: #72818e; font-weight: 700; padding: 13px 15px; }
  .stock-list .stock-unit-column { display: none !important; }
  .stock-list td { padding: 7px 15px; border-bottom: 1px solid #ecf0f3; }
  .stock-list tbody tr:nth-child(even) { background: #fff; }
  .stock-list tbody tr:hover td { background: #f7fafb; }
  .stock-list .stock-row-selected td { background: #edf5f7; }
  .stock-list-product { font-size: .77rem; font-weight: 600; min-height: 42px; line-height: 1.5; }
  .stock-list td.stock-list-quantity { font-size: 1.04rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
  .stock-unit-edit { background: #edf5f7; border-color: #d1e3e9; color: #275e71; font-size: .72rem; border-radius: 8px; min-height: 40px; }
  .stock-move { border: 1px solid #e2e8ec; border-radius: 7px; color: #647887; min-width: 30px; min-height: 40px; margin-right: 4px; }
  .stock-delete { color: #8a6265; font-size: .72rem; min-height: 40px; padding: 4px 8px; }
  .carton-equivalent { color: #7a8994; font-size: .65rem; margin-top: 2px; }
  #inventory .auto-orders { order: 6; margin: 0; padding: 11px 15px; background: #f9fbfc; }
  .auto-orders .quick-toggle > summary { font-size: .76rem; color: #5c7282; padding: 0; }
  .auto-orders .quick-toggle[open] > summary { padding-bottom: 12px; }
  #inventory > .mobile-group { order: 2; }
  .product-card { border: 1px solid #cfdee6; background: #fff; border-radius: 13px; padding: 18px; }
  .product-name { font-size: 1rem; }
  .product-subline { font-size: .75rem; }
  .product-stat { background: #f6f9fa; border-color: #e6edf1; border-radius: 9px; }
  .badge { font-size: .66rem; border-radius: 7px; color: #557177; background: #eff5f4; border-color: #dce8e6; }
  .badge.badge-danger { background: #faf2e7; border-color: #ead8bc; color: #876531; }
  #settings > .card { padding: 22px; }
  #settings h3, #movements h2, #reports h2 { margin-top: 0; letter-spacing: -.025em; }
  #settings .settings-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 20px; }
  .settings-actions .btn { text-align: left; background: #f9fbfc; padding: 16px; min-height: 58px; }
  .settings-actions .btn:hover { background: #edf4f7; }
  #open-host-logout { color: #916364; }
  .modal-card, .host-card { border-radius: 17px; padding: 24px; box-shadow: 0 20px 65px #16324b20; }
  .modal h3 { letter-spacing: -.025em; margin-top: 0; }
  .modal form { display: grid; gap: 13px; }
  .modal label { font-size: .77rem; gap: 7px; }
  .modal input, .modal select, .modal textarea { width: 100%; min-width: 0; box-sizing: border-box; }
  .modal .row-toggle input { width: auto; }
  .modal-actions { padding-top: 14px; border-top: 1px solid #e7edf1; }
  .product-unit-picker { border-color: #cddfe7; background: #f1f7f9; }
  .unit-choice-buttons { margin: 0; }
  .unit-choice-buttons [aria-pressed="true"] { background: #215d77; }
  .host-screen { background: radial-gradient(ellipse at 25% 0, #dceaf0, transparent 65%), #f3f6f8; }
  .host-dialog { max-height: 85dvh; }
  .delete-product-dialog { max-height: 85dvh; overflow-y: auto; }
  .stock-list-card button:not([class]) { border: 1px solid #dce5eb; border-radius: 8px; background: #fff; padding: 9px 13px; color: #526f81; font-family: inherit; min-height: 40px; cursor: pointer; }
  @media (prefers-reduced-motion: no-preference) { .panel.active { animation: workspace-enter .18s ease-out; } }
  @keyframes workspace-enter { from { opacity: .65; transform: translateY(4px); } to { opacity: 1; transform: none; } }
  @media (max-width: 900px) and (min-width: 701px) {
    .app-shell { padding: 22px 20px; }
    .app-shell > main { grid-template-columns: 132px minmax(0, 1fr); gap: 16px; }
    .tab-item { font-size: .75rem; padding: 10px 7px; gap: 8px; }
    .quick-actions .actions-grid { width: 100%; }
    .quick-actions .actions-grid .btn { flex: 1; }
    .inventory-search .search-actions { grid-template-columns: minmax(0, 1fr) 155px; }
    .search-actions label[for="list-sort"] { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  }
  @media (max-width: 700px) {
    .stock-help-desktop, #movement-type-row { display: none; }
    .stock-help-mobile { display: inline; }
    .stock-list tbody tr:has(.stock-list-product) { cursor: pointer; }
    .app-shell { padding: 18px 13px calc(94px + env(safe-area-inset-bottom)); }
    .top-bar { gap: 11px; padding-bottom: 6px; }
    .top-bar::before { flex-basis: 38px; width: 38px; height: 38px; border-radius: 11px; font-size: .86rem; }
    .top-bar h1 { font-size: .79rem; max-width: none; line-height: 1.45; letter-spacing: 0; }
    .top-bar .subtitle { font-size: .64rem; line-height: 1.5; margin-top: 3px !important; }
    .host-status { font-size: .64rem; margin: 0 0 18px 49px; }
    .app-shell > main { display: block; }
    .tab-bar {
      position: fixed; top: auto; bottom: 0; left: 0; right: 0; z-index: 30;
      display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px;
      width: 100%; margin: 0; padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
      border-radius: 16px 16px 0 0; border: 1px solid #dce5eb; box-sizing: border-box;
      background: #fff; box-shadow: 0 -5px 24px #213f5210;
    }
    .tab-item { display: flex; flex-direction: column; gap: 4px; padding: 7px 3px; min-height: 54px; justify-content: center; text-align: center; font-size: .68rem; }
    .tab-item.active { box-shadow: inset 0 2px 0 #29778a; border-radius: 8px; }
    .tab-item svg { width: 21px; height: 21px; }
    #inventory.panel.active { gap: 9px; }
    .workspace-title h2 { font-size: 1.45rem; }
    .workspace-title p { font-size: .71rem; margin-top: 4px; }
    #inventory .quick-actions { gap: 12px; padding-bottom: 3px; }
    .quick-actions .actions-grid { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
    .quick-actions .btn { min-height: 46px; font-size: .8rem; }
    #inventory .inventory-search { padding: 12px 13px; gap: 6px; margin: 0; }
    .inventory-search .search-actions { display: block; }
    .inventory-search input { min-height: 46px; font-size: 16px; }
    .inventory-search p { font-size: .65rem; line-height: 1.5; }
    .mobile-group { margin: 0; border-radius: 10px; background: #ffffffb3; }
    .mobile-group > summary { padding: 9px 13px; min-height: 42px; font-size: .73rem; box-sizing: border-box; }
    .mobile-group-body { padding: 0 12px 12px; }
    .mobile-group-body select { min-height: 44px; font-size: 16px; }
    #inventory .filter-details { border-radius: 10px; }
    .filter-details > summary { min-height: 42px; box-sizing: border-box; }
    .filter-details .filters { grid-template-columns: 1fr; }
    #inventory .stock-list-card { border-radius: 13px; overflow: visible; }
    .stock-list tr { grid-template-columns: minmax(0, 1fr) 112px 38px; gap: 0 8px; padding: 11px 12px; min-height: 72px; }
    .stock-list td { border: 0; padding: 0 !important; }
    .stock-list-product { font-size: .76rem; line-height: 1.55; min-height: 44px; font-weight: 600; }
    .stock-list td.stock-list-quantity { font-size: 1rem; grid-row: 1 / 3; align-self: center; }
    .stock-list td:nth-child(3) { margin-top: 3px; }
    .stock-unit-edit { min-height: 36px; font-size: .69rem; min-width: 64px; padding: 2px 8px; }
    .mobile-row-menu summary { width: 38px; min-height: 44px; border-radius: 8px; background: #f1f5f7; color: #6b7e8b; }
    .mobile-row-buttons { top: 46px; z-index: 32; border-radius: 11px; padding: 9px; }
    #products-grid:not(:empty) { margin: 2px 0; }
    #products-grid .product-card { padding: 15px; }
    #settings > .card { padding: 17px; }
    #settings .settings-actions { grid-template-columns: 1fr; gap: 9px; margin-top: 15px; }
    .settings-actions .btn { min-height: 52px; padding: 14px; }
    .modal { padding: 0; }
    .modal-card { padding: 21px 16px max(22px, env(safe-area-inset-bottom)); border-radius: 18px 18px 0 0; width: 100%; max-height: 92dvh; }
    .modal input, .modal select, .modal textarea { font-size: 16px; min-height: 48px; }
    .modal .row-toggle input { min-height: 22px; }
    .host-card { padding: 21px; }
    .unit-choice-buttons { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }
}
