/* ============================================================
   行動裝置版面 (<= 768px)
   側邊欄收合為上方列，選單以下拉抽屜方式呈現
   ============================================================ */

@media (max-width: 768px) {
  body {
    background: var(--bg);
    font-size: 15px;
  }

  /* ---------- TodaySell / InStock mobile tuning ---------- */
  .todaysell-filter {
    margin-bottom: 12px;
  }

  .todaysell-filter .field-group,
  .instock-editing-hint,
  .todaysell-table-actions,
  .instock-table-actions {
    width: 100%;
  }

  .todaysell-filter .field-group {
    max-width: none;
  }

  .todaysell-filter .input-field,
  .excel-table .todaysell-row .input-field,
  .excel-table .instock-row .input-field {
    width: auto;
    min-width: 0;
    max-width: none;
    box-sizing: border-box;
  }

  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .excel-table {
    width: max-content;
    min-width: 100%;
    table-layout: auto;
  }

  .instock-editing-hint {
    flex-wrap: wrap;
    gap: 6px 8px;
    align-items: flex-start;
    padding: 10px 12px;
  }

  .instock-editing-hint strong {
    min-width: 0;
    word-break: break-word;
  }

  .excel-table .todaysell-col-select,
  .excel-table .instock-col-select {
    width: 38px;
    min-width: 38px;
  }

  .excel-table .todaysell-col-goods {
    min-width: 220px;
  }

  .excel-table .todaysell-col-qty {
    min-width: 100px;
  }

  .excel-table .todaysell-col-remain {
    min-width: 88px;
  }

  .excel-table .todaysell-row .todaysell-sid-select {
    min-width: 220px;
  }

  .excel-table .todaysell-row .todaysell-qty-input {
    min-width: 96px;
  }

  .excel-table .todaysell-row .todaysell-remain {
    min-width: 72px;
  }

  .excel-table .instock-col-vender {
    min-width: 180px;
  }

  .excel-table .instock-col-goods {
    min-width: 220px;
  }

  .excel-table .instock-col-money {
    min-width: 92px;
  }

  .excel-table .instock-col-margin {
    min-width: 86px;
  }

  .excel-table .instock-col-qty {
    min-width: 84px;
  }

  .excel-table .instock-col-date {
    min-width: 130px;
  }

  .excel-table .todaysell-row .btn-action-row,
  .excel-table .instock-row .btn-action-row {
    display: inline-flex;
    width: auto;
    min-width: 0;
    padding: 5px 8px;
    font-size: 0.72rem;
    line-height: 1.2;
    border-radius: 999px;
  }

  .excel-table .todaysell-row .btn-save-row,
  .excel-table .todaysell-row .btn-add-row {
    box-shadow: 0 6px 14px rgba(227, 64, 45, 0.16);
  }

  .excel-table .todaysell-row .btn-save-row:hover,
  .excel-table .todaysell-row .btn-add-row:hover {
    box-shadow: 0 8px 18px rgba(227, 64, 45, 0.22);
  }

  .todaysell-bulk-delete-btn,
  .instock-bulk-delete-btn {
    width: 100%;
  }

  .todaysell-table-actions,
  .instock-table-actions {
    margin-bottom: 12px;
  }

  .excel-table .todaysell-row-select,
  .excel-table .instock-row-select {
    width: 16px;
    height: 16px;
  }

  .excel-table .col-actions {
    width: 64px;
  }

  .excel-table .todaysell-row .btn-save-row,
  .excel-table .todaysell-row .btn-add-row {
    min-width: 0;
  }

  /* ---------- 上方列 ---------- */
  .top-nav {
    position: sticky;
    top: 0;
    z-index: 30;
    box-shadow: var(--shadow-sm);
  }

  .top-nav-inner {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 60px;
  }

  .brand-block {
    font-size: 0.95rem;
    min-width: 0;
    max-width: calc(100% - 56px);
  }

  .brand-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }

  .menu-mobile-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.12);
    color: var(--sidebar-text-active);
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    font-size: 1.15rem;
  }

  .menu-list {
    display: none;
    width: 100%;
    position: absolute;
    left: 0;
    top: 100%;
    background: var(--sidebar-bg);
    border-top: 1px solid var(--sidebar-border);
    box-shadow: var(--shadow);
    max-height: calc(100vh - 60px);
    overflow-y: auto;
  }

  .top-nav.menu-open .menu-list {
    display: block;
  }

  .menu-groups {
    padding: 10px;
  }

  .menu-group {
    border-bottom: 1px solid var(--sidebar-border);
  }

  .menu-group:last-child {
    border-bottom: none;
  }

  .menu-group-toggle {
    padding: 14px 10px;
    font-size: 0.98rem;
  }

  .menu-group-toggle::after {
    content: "\25B8";
    font-size: 0.85rem;
    opacity: 0.9;
    transform: none;
  }

  .menu-group.open > .menu-group-toggle::after {
    content: "\25BE";
    transform: none;
  }

  .menu-group-items {
    padding: 0 6px 8px 12px;
  }

  .menu-item {
    padding: 10px 10px;
  }

  /* ---------- 內容區 ---------- */
  .page-shell {
    margin-left: 0;
    max-width: none;
    padding: 18px 14px 46px;
  }

  .card {
    padding: 18px;
    border-radius: var(--radius);
  }

  .card.wide {
    padding: 20px;
  }

  .brand h1 {
    font-size: 1.4rem;
  }

  .page-header {
    align-items: flex-start;
  }

  .page-header h1,
  .page-header h2 {
    font-size: 1.3rem;
  }

  .field-group label {
    font-size: 0.92rem;
  }

  .button {
    width: 100%;
  }

  .filter-actions {
    flex-wrap: wrap;
  }

  .filter-actions .button {
    width: auto;
    flex: 1;
  }

  .filter-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

