/* ============================================================
   LT-ERP 簡易銷貨單 — 共用樣式
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Microsoft JhengHei', 'PingFang TC', 'Heiti TC', sans-serif;
  background: #f5f7fa;
  color: #2c3e50;
  font-size: 14px;
  line-height: 1.5;
}

.view { min-height: 100vh; }

/* ============================================================
   載入中
   ============================================================ */
#boot-view {
  display: flex;
  align-items: center;
  justify-content: center;
}
.boot {
  font-size: 16px;
  color: #1976d2;
}


/* ============================================================
   登入畫面
   ============================================================ */
#login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #1565c0 0%, #1976d2 50%, #42a5f5 100%);
}

.login-card {
  background: white;
  width: 100%;
  max-width: 400px;
  padding: 32px;
  border-radius: 10px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.12);
}

.login-card h1 {
  font-size: 22px;
  margin-bottom: 4px;
  color: #1565c0;
}

.login-card .subtitle {
  font-size: 13px;
  color: #777;
  margin-bottom: 24px;
}

.login-card label {
  display: block;
  margin-top: 14px;
  margin-bottom: 4px;
  font-size: 13px;
  font-weight: bold;
  color: #555;
}

.login-card input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}
.login-card input:focus {
  outline: none;
  border-color: #1976d2;
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.15);
}

.login-card button[type=submit] {
  width: 100%;
  margin-top: 22px;
  padding: 12px;
  background: #1565c0;
  color: white;
  border: 0;
  border-radius: 6px;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
}
.login-card button:hover { background: #0d47a1; }
.login-card button:disabled { background: #aaa; cursor: not-allowed; }

.login-card .footer-note {
  margin-top: 18px;
  font-size: 12px;
  color: #999;
  text-align: center;
}

.error {
  margin-top: 14px;
  padding: 10px 12px;
  background: #ffebee;
  color: #c62828;
  border-radius: 4px;
  font-size: 13px;
}


/* ============================================================
   主畫面 topbar
   ============================================================ */
.topbar {
  background: white;
  padding: 12px 20px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.topbar h1 {
  font-size: 18px;
  color: #1565c0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}

.topbar-right #current-user {
  color: #555;
  font-family: monospace;
}

.btn-secondary {
  padding: 6px 14px;
  background: #eceff1;
  color: #455a64;
  border: 0;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.btn-secondary:hover { background: #cfd8dc; }


/* ============================================================
   主內容
   ============================================================ */
#main-content {
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

.placeholder {
  background: white;
  padding: 24px 28px;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
}

.placeholder h2 {
  color: #2e7d32;
  margin-bottom: 12px;
  font-size: 18px;
}

.placeholder p { margin-bottom: 8px; }

.placeholder ul {
  margin: 12px 0 12px 24px;
}

.placeholder li {
  margin-bottom: 4px;
}

.placeholder .hint {
  margin-top: 16px;
  padding: 10px 14px;
  background: #e3f2fd;
  color: #1565c0;
  border-radius: 4px;
  font-size: 13px;
}


/* ============================================================
   篩選 bar
   ============================================================ */
.filter-bar {
  background: white;
  padding: 14px 18px;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.quick-buttons {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.quick-buttons button {
  padding: 6px 14px;
  background: #eceff1;
  color: #455a64;
  border: 0;
  border-radius: 18px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  font-weight: bold;
}
.quick-buttons button:hover { background: #cfd8dc; }
.quick-buttons button.active { background: #1565c0; color: white; }

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: flex-end;
}
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.filter-group label {
  font-size: 12px;
  font-weight: bold;
  color: #555;
}
.filter-group input,
.filter-group select {
  padding: 6px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  height: 32px;
}
.filter-group input[type=date] { min-width: 130px; }
.filter-group input[type=text] { min-width: 160px; }
.filter-group select { min-width: 110px; }
.filter-group input:focus,
.filter-group select:focus {
  outline: none;
  border-color: #1976d2;
}
.filter-group .dash {
  display: inline-block;
  margin: 0 4px;
  color: #999;
}

/* 日期區間的兩個 input + dash 排同列 */
.date-range {
  display: flex;
  align-items: center;
  gap: 4px;
}

.filter-actions {
  display: flex;
  gap: 8px;
  align-self: flex-end;
}
.filter-actions button {
  height: 32px;
  padding: 0 14px;
  font-size: 13px;
}
.btn-primary {
  background: #1565c0;
  color: white;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  font-weight: bold;
}
.btn-primary:hover { background: #0d47a1; }
.btn-primary:disabled { background: #aaa; cursor: not-allowed; }


/* ============================================================
   狀態列 + 批次列印
   ============================================================ */
.status-row {
  display: flex;
  gap: 12px;
  align-items: stretch;
  margin-bottom: 12px;
}
.status-row .status-bar { flex: 1; margin-bottom: 0; }
.status-row #btn-batch-print,
.status-row #btn-export-excel {
  height: auto;
  padding: 0 18px;
  font-size: 13px;
  white-space: nowrap;
}

.status-bar {
  padding: 10px 14px;
  border-radius: 4px;
  margin-bottom: 12px;
  font-size: 13px;
}
.status-info    { background: #e3f2fd; color: #1565c0; }
.status-success { background: #e8f5e9; color: #2e7d32; }
.status-warning { background: #fff3e0; color: #e65100; }
.status-error   { background: #ffebee; color: #c62828; }


/* ============================================================
   訂單列表
   ============================================================ */
.orders-card {
  background: white;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.orders-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.orders-table th {
  background: #f5f7fa;
  padding: 10px 12px;
  text-align: left;
  font-weight: bold;
  color: #555;
  border-bottom: 2px solid #e0e0e0;
  position: sticky;
  top: 0;
  z-index: 1;
}
.orders-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #eee;
  vertical-align: middle;
}
.orders-table tbody tr:hover { background: #fafbfc; }
.orders-table .r { text-align: right; }
.orders-table .c { text-align: center; }
.orders-table a {
  color: #1565c0;
  font-family: monospace;
  font-weight: bold;
  text-decoration: none;
  cursor: pointer;
}
.orders-table a:hover { text-decoration: underline; }
.orders-table .empty {
  text-align: center;
  padding: 40px 20px;
  color: #999;
  font-style: italic;
}

.btn-mini {
  padding: 4px 8px;
  background: #eceff1;
  color: #455a64;
  border: 0;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.btn-mini:hover { background: #cfd8dc; }
.btn-mini:disabled {
  background: #f0f0f0;
  color: #aaa;
  cursor: not-allowed;
}

/* 狀態徽章 */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: bold;
}
.b-pending  { background: #fff3e0; color: #e65100; }
.b-issued   { background: #e3f2fd; color: #1565c0; }
.b-received { background: #e8f5e9; color: #2e7d32; }
.b-issue    { background: #ffebee; color: #c62828; }
.b-draft    { background: #fff8e1; color: #e65100; border: 1px solid #ffb300; }

/* 任務 4.1 D 段：暫存單列底色淡黃 */
.orders-table tr.draft-row {
  background: #fffbeb;
}
.orders-table tr.draft-row:hover {
  background: #fff5d6;
}


/* ============================================================
   明細 modal
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
}
.modal-content {
  position: relative;
  background: white;
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  border-radius: 8px;
  padding: 24px 28px;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  background: #eceff1;
  color: #455a64;
  border: 0;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  font-family: inherit;
}
.modal-close:hover { background: #cfd8dc; }

.modal-title {
  font-family: monospace;
  font-size: 18px;
  color: #1565c0;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.modal-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  font-size: 13px;
}
.modal-meta > span {
  background: #eceff1;
  padding: 4px 10px;
  border-radius: 4px;
}
.modal-meta .return-badge {
  background: #ffcdd2;
  color: #c62828;
}

.modal-items {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 16px;
}
.modal-items th,
.modal-items td {
  border: 1px solid #ddd;
  padding: 6px 10px;
}
.modal-items th {
  background: #f5f5f5;
  text-align: left;
  font-weight: bold;
  color: #555;
}
.modal-items td.r { text-align: right; }
.modal-items .mono { font-family: monospace; font-size: 12px; }
.modal-items tr.return-row { background: #fff3e0; }
.modal-items .return-info {
  display: inline-block;
  margin-top: 4px;
  color: #c62828;
  font-size: 12px;
}
.modal-items .admin-note {
  display: inline-block;
  margin-top: 2px;
  color: #555;
  font-size: 12px;
  font-style: italic;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid #eee;
}
.modal-actions button {
  padding: 8px 16px;
  font-size: 13px;
  font-family: inherit;
  border-radius: 4px;
  border: 0;
  cursor: pointer;
}
.btn-disabled {
  background: #f0f0f0;
  color: #999;
  cursor: not-allowed;
}

.loading {
  text-align: center;
  padding: 40px;
  color: #1976d2;
}

/* 任務 4.1 D 段：暫存單 modal 警示框 */
.draft-warn {
  background: #fff8e1;
  border: 2px solid #ffa000;
  color: #bf360c;
  padding: 12px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 13px;
  line-height: 1.7;
}
.draft-warn b { color: #d84315; }
.draft-warn small { color: #6d4c41; }


/* ============================================================
   2026-04-29：舊系統 (legacy) 整合樣式
   ============================================================ */

/* 列表 — 類型徽章 */
.b-simple        { background: #e3f2fd; color: #1565c0; }                                /* 📦 一般 — 藍 */
.b-legacy        { background: #fff3e0; color: #e65100; border: 1px solid #ffb74d; }     /* 📜 歷史 — 琥珀 */
.b-legacy-return { background: #ffebee; color: #c62828; border: 1px solid #ef9a9a; }     /* 📜 歷史退貨 — 紅 */
.b-return-order  { background: #ffcdd2; color: #b71c1c; }                                /* 退貨單（狀態欄）*/
.b-ref-order     { background: #fff3e0; color: #e65100; border: 1px solid #ffb74d; font-family: monospace; }

/* 舊單列底色（淡灰，跟暫存淡黃區隔）*/
.orders-table tr.legacy-row {
  background: #fafafa;
}
.orders-table tr.legacy-row:hover {
  background: #f0f0f0;
}

/* 負金額紅字（列表 + modal）*/
.orders-table td.negative,
.modal-meta .negative,
.modal-items .negative {
  color: #c62828;
  font-weight: bold;
}

/* modal — 舊單唯讀警示框 */
.legacy-warn {
  background: #fff3e0;
  border: 2px solid #fb8c00;
  color: #bf360c;
  padding: 12px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 13px;
  line-height: 1.7;
}
.legacy-warn b { color: #e65100; }
.legacy-warn small { color: #6d4c41; }

/* modal — 備註列 */
.modal-note {
  background: #f5f5f5;
  padding: 8px 12px;
  border-radius: 4px;
  margin-bottom: 12px;
  font-size: 13px;
  color: #555;
}


/* ============================================================
   2026-04-30：月結報表
   ============================================================ */

/* topbar 切換按鈕（月結 / 列表）*/
#btn-toggle-report {
  background: #1565c0;
  color: white;
  font-weight: bold;
}
#btn-toggle-report:hover {
  background: #0d47a1;
}

/* 月結表格 */
.report-table th,
.report-table td {
  padding: 12px 14px;
  font-size: 14px;
}
.report-table tbody tr:hover {
  background: #f5f7fa;
}

/* 合計列 */
.report-table tfoot .total-row {
  background: #fff3e0;
  border-top: 2px solid #fb8c00;
  font-size: 15px;
}
.report-table tfoot .total-row th {
  padding: 14px;
  background: #fff3e0;
  color: #bf360c;
  border-bottom: 0;
  position: static;
}
.report-table tfoot .total-row .negative {
  color: #c62828;
}

/* 月份下拉樣式微調 */
#report-month {
  min-width: 120px;
  font-size: 14px;
  font-weight: bold;
}

/* 店名連結（彙總表）*/
.store-link {
  color: #1565c0;
  font-weight: bold;
  cursor: pointer;
  text-decoration: none;
}
.store-link:hover {
  text-decoration: underline;
}

/* 月費 input + 儲存鈕 */
.fee-input {
  width: 80px;
  padding: 3px 6px;
  font-size: 13px;
  text-align: right;
  border: 1px solid #ccc;
  border-radius: 4px;
}
.fee-input:focus {
  outline: none;
  border-color: #1976d2;
  box-shadow: 0 0 0 2px rgba(25,118,210,0.15);
}
.btn-fee-save {
  background: transparent;
  border: 0;
  padding: 0 6px;
  font-size: 14px;
  cursor: pointer;
}
.btn-fee-save:hover { background: #e3f2fd; border-radius: 4px; }

/* 店轉店淨額 placeholder（v1 灰字 — v3 後改成手動輸入，仍保留以防舊資料）*/
.placeholder-cell {
  color: #999;
  font-style: italic;
  font-size: 12px;
}

/* 店轉店 / 調整金額 input + 備註 input */
.amount-input {
  width: 80px;
  padding: 3px 6px;
  font-size: 13px;
  text-align: right;
  border: 1px solid #ccc;
  border-radius: 4px;
}
.amount-input:focus {
  outline: none;
  border-color: #1976d2;
  box-shadow: 0 0 0 2px rgba(25,118,210,0.15);
}
.note-input {
  width: 140px;
  padding: 3px 6px;
  font-size: 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
}
.note-input:focus {
  outline: none;
  border-color: #1976d2;
  box-shadow: 0 0 0 2px rgba(25,118,210,0.15);
}
.btn-section-save {
  background: transparent;
  border: 0;
  padding: 0 4px;
  font-size: 14px;
  cursor: pointer;
}
.btn-section-save:hover { background: #e3f2fd; border-radius: 4px; }

/* 店家明細 footer 的小備註灰字 */
.detail-side-note {
  color: #999;
  font-size: 11px;
  font-weight: normal;
  margin-left: 8px;
}

/* 報表頁底部提示 */
.report-hint {
  margin-top: 12px;
  padding: 10px 14px;
  background: #e3f2fd;
  color: #1565c0;
  border-radius: 4px;
  font-size: 13px;
}
.report-hint kbd {
  display: inline-block;
  padding: 1px 5px;
  background: white;
  border: 1px solid #ccc;
  border-radius: 3px;
  font-family: monospace;
  font-size: 12px;
}

/* 店家明細表 — footer 區塊 */
.detail-table tfoot th {
  padding: 10px 14px;
  text-align: right;
  position: static;
  background: #fafafa;
  border-top: 1px solid #e0e0e0;
}
.detail-table tfoot .subtotal-row th {
  background: #e3f2fd;
  color: #0d47a1;
  border-top: 2px solid #1976d2;
}
.detail-table tfoot .addon-row th {
  background: #fafafa;
  color: #555;
  font-weight: normal;
}
.detail-table tfoot .total-row th {
  background: #fff3e0;
  color: #bf360c;
  font-size: 15px;
  border-top: 2px solid #fb8c00;
}
.detail-table tfoot th:first-child {
  text-align: left;
}
.detail-table tfoot .negative {
  color: #c62828;
}
