/* ── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand: #1a56db;
  --brand-dark: #1045b8;
  --brand-light: #e8f0fe;
  --accent: #f59e0b;
  --success: #10b981;
  --danger: #ef4444;
  --warn: #f59e0b;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.1);
  --font: 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
}

html, body { height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--gray-900);
  background: var(--gray-50);
  line-height: 1.6;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }

/* ── Login Page ────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a56db 0%, #0e3a9b 100%);
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 40px rgba(0,0,0,.25);
}

.login-logo {
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-logo .logo-text {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--brand);
  letter-spacing: .05em;
}

.login-logo .logo-sub {
  font-size: .8rem;
  color: var(--gray-500);
  margin-top: .2rem;
}

.login-card h2 {
  text-align: center;
  margin-bottom: 1.5rem;
  color: var(--gray-700);
}

/* ── Forms ─────────────────────────────────────────────── */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: .35rem;
  color: var(--gray-700);
  font-size: .875rem;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: .55rem .75rem;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: .9rem;
  color: var(--gray-900);
  transition: border-color .15s;
  background: #fff;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(26,86,219,.15);
}

.form-group textarea { resize: vertical; min-height: 70px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}

/* ── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1.1rem;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }

.btn-outline {
  background: #fff;
  color: var(--brand);
  border: 1.5px solid var(--brand);
}
.btn-outline:hover { background: var(--brand-light); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-warning { background: #f59e0b; color: #fff; }
.btn-warning:hover { background: #d97706; }

.btn-ghost {
  background: transparent;
  color: var(--gray-700);
  border: 1.5px solid var(--gray-300);
}
.btn-ghost:hover { background: var(--gray-100); }

.btn-sm { padding: .3rem .7rem; font-size: .8rem; }
.btn-lg { padding: .7rem 1.5rem; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }

.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── App Shell ─────────────────────────────────────────── */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Sidebar Layout ─────────────────────────────────────── */
.sidebar-shell {
  flex-direction: row;
  align-items: stretch;
}

.sidebar {
  width: 220px;
  min-width: 220px;
  background: #1e293b;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
  z-index: 50;
}

.sidebar-brand {
  padding: 1.25rem 1rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-brand .logo-text {
  font-size: 1.2rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: .05em;
}
.sidebar-brand .logo-sub {
  font-size: .72rem;
  color: rgba(255,255,255,.45);
  margin-top: .2rem;
}

.sidebar-nav {
  flex: 1;
  padding: .75rem 0;
  overflow-y: auto;
}

.nav-group-label {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: rgba(255,255,255,.3);
  padding: .9rem 1rem .3rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .55rem;
  width: 100%;
  padding: .55rem 1rem;
  font-size: .875rem;
  font-weight: 500;
  color: rgba(255,255,255,.6);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  text-decoration: none;
  transition: color .15s, background .15s;
  text-align: left;
  border-radius: 0;
  box-sizing: border-box;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,.07); }
.nav-item.active {
  color: #fff;
  background: rgba(26,86,219,.45);
  font-weight: 700;
}

.nav-sub { padding-left: 2rem; font-size: .85rem; }

.sidebar-footer {
  padding: .9rem 1rem;
  border-top: 1px solid rgba(255,255,255,.1);
}
.sidebar-user-name {
  font-size: .82rem;
  color: rgba(255,255,255,.65);
  font-weight: 600;
  margin-bottom: .5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.btn-sidebar-logout {
  width: 100%;
  padding: .4rem .8rem;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 6px;
  color: rgba(255,255,255,.6);
  font-family: var(--font);
  font-size: .8rem;
  cursor: pointer;
  text-align: center;
  transition: background .15s, color .15s;
}
.btn-sidebar-logout:hover { background: rgba(255,255,255,.16); color: #fff; }

/* 使用者選單（點名字展開） */
.sidebar-user-menu { position: relative; }
.sidebar-user-trigger {
  width: 100%;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 8px;
  color: rgba(255,255,255,.85);
  font-family: var(--font);
  font-size: .82rem;
  font-weight: 600;
  padding: .45rem .8rem;
  cursor: pointer;
  text-align: left;
  transition: background .15s;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .4rem;
}
.sidebar-user-trigger::after { content: '⌃'; font-size: .7rem; opacity: .6; transition: transform .2s; }
.sidebar-user-trigger.open::after { transform: rotate(180deg); }
.sidebar-user-trigger:hover { background: rgba(255,255,255,.15); }
.sidebar-user-dropdown {
  display: none;
  position: absolute;
  bottom: calc(100% + .4rem);
  left: 0; right: 0;
  background: #1e293b;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 -4px 16px rgba(0,0,0,.3);
}
.sidebar-user-dropdown.open { display: block; }
.sidebar-user-dropdown button {
  width: 100%;
  padding: .55rem .9rem;
  background: none;
  border: none;
  color: rgba(255,255,255,.75);
  font-family: var(--font);
  font-size: .82rem;
  cursor: pointer;
  text-align: left;
  transition: background .12s, color .12s;
  display: block;
}
.sidebar-user-dropdown button:hover { background: rgba(255,255,255,.1); color: #fff; }
.sidebar-user-dropdown button + button { border-top: 1px solid rgba(255,255,255,.08); }

.sidebar-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--gray-50);
}

/* Top Nav */
.topnav {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.topnav-brand {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--brand);
  letter-spacing: .05em;
}

.topnav-brand span {
  color: var(--gray-500);
  font-weight: 400;
  font-size: .85rem;
  margin-left: .5rem;
}

.topnav-user {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.topnav-user .user-name {
  font-size: .875rem;
  color: var(--gray-700);
}

/* Tabs */
.tab-nav {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 1.5rem;
  display: flex;
  gap: 0;
}

.tab-btn {
  padding: .85rem 1.2rem;
  border: none;
  border-bottom: 3px solid transparent;
  background: transparent;
  font-family: var(--font);
  font-size: .9rem;
  color: var(--gray-500);
  cursor: pointer;
  font-weight: 500;
  transition: all .15s;
}

.tab-btn:hover { color: var(--brand); }
.tab-btn.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
  font-weight: 700;
}

/* Main Content */
.main-content {
  flex: 1;
  padding: 1.5rem;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

/* Tab Panels */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Cards ─────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card-title {
  font-size: .95rem;
  font-weight: 700;
  margin-bottom: 1rem;
  padding-bottom: .6rem;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
  display: flex;
  align-items: center;
  gap: .5rem;
}

/* ── Service Grid ───────────────────────────────────────── */
.category-section { margin-bottom: 1.5rem; }

.category-title {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--gray-400);
  margin-bottom: .6rem;
}

.service-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: .6rem;
}

.service-card {
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  padding: .8rem .9rem;
  cursor: pointer;
  transition: all .15s;
  background: #fff;
  position: relative;
}

.service-card:hover {
  border-color: var(--brand);
  background: var(--brand-light);
}

.service-card.selected {
  border-color: var(--brand);
  background: var(--brand-light);
}

.service-card.selected::after {
  content: "✓";
  position: absolute;
  top: .4rem;
  right: .5rem;
  color: var(--brand);
  font-weight: 800;
  font-size: .9rem;
}

.service-card-name { font-weight: 700; font-size: .9rem; margin-bottom: .2rem; }
.service-card-desc { font-size: .78rem; color: var(--gray-500); margin-bottom: .4rem; }
.service-card-price {
  font-size: .85rem;
  font-weight: 700;
  color: var(--brand);
}
.service-card-unit {
  font-size: .75rem;
  color: var(--gray-400);
  font-weight: 400;
}

/* ── Line Items Table ───────────────────────────────────── */
.line-items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

.line-items-table th {
  text-align: left;
  padding: .5rem .6rem;
  background: var(--gray-50);
  color: var(--gray-500);
  font-weight: 600;
  font-size: .8rem;
  border-bottom: 1px solid var(--gray-200);
}

.line-items-table td {
  padding: .55rem .6rem;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}

.line-items-table tr:last-child td { border-bottom: none; }

.line-items-table input[type="number"] {
  width: 65px;
  padding: .3rem .4rem;
  border: 1.5px solid var(--gray-300);
  border-radius: 4px;
  font-size: .875rem;
  text-align: center;
}

.line-items-table input[type="number"]:focus {
  outline: none;
  border-color: var(--brand);
}

.subtotal-cell { font-weight: 600; color: var(--gray-700); }
.remove-btn {
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  font-size: 1rem;
  padding: .2rem .4rem;
  border-radius: 4px;
  transition: all .15s;
}
.remove-btn:hover { color: var(--danger); background: #fee2e2; }

/* ── Totals Box ─────────────────────────────────────────── */
.totals-box {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-top: .5rem;
}

.total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .3rem 0;
  font-size: .9rem;
}

.total-row.divider { border-top: 1px solid var(--gray-300); margin-top: .3rem; padding-top: .6rem; }
.total-row.grand { font-size: 1.1rem; font-weight: 800; color: var(--brand); }
.total-row label { color: var(--gray-600); }

/* Discount inputs inline */
.discount-row {
  display: flex;
  align-items: center;
  gap: .4rem;
  justify-content: flex-end;
}
.discount-row select, .discount-row input {
  padding: .25rem .4rem;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  font-size: .85rem;
  font-family: var(--font);
}
.discount-row input { width: 70px; text-align: right; }

/* ── Step Indicator ────────────────────────────────────── */
.step-indicator {
  display: flex;
  align-items: center;
  margin-bottom: 1.5rem;
  max-width: 480px;
}

.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .3rem;
}

.step-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gray-200);
  color: var(--gray-400);
  font-size: .85rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s, color .2s;
}

.step-label {
  font-size: .72rem;
  color: var(--gray-400);
  font-weight: 600;
  white-space: nowrap;
  transition: color .2s;
}

.step-item.active .step-circle {
  background: var(--brand);
  color: #fff;
}
.step-item.active .step-label { color: var(--brand); }

.step-item.done .step-circle {
  background: var(--success);
  color: #fff;
}
.step-item.done .step-circle::before { content: '✓'; }
.step-item.done .step-circle { font-size: 0; }
.step-item.done .step-circle::before { font-size: .85rem; }
.step-item.done .step-label { color: var(--success); }

.step-line {
  flex: 1;
  height: 2px;
  background: var(--gray-200);
  margin: 0 .5rem;
  margin-bottom: 1.3rem;
}

/* ── Quotation History ──────────────────────────────────── */
.search-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .75rem;
  align-items: end;
}

.history-toolbar {
  display: flex;
  gap: .75rem;
  margin-bottom: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.history-toolbar input[type="search"] {
  flex: 1;
  min-width: 200px;
  padding: .5rem .75rem;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: .875rem;
}

.history-table-wrap { overflow-x: auto; }

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

.history-table th {
  text-align: left;
  padding: .6rem .8rem;
  background: var(--gray-50);
  color: var(--gray-500);
  font-weight: 600;
  font-size: .8rem;
  border-bottom: 1.5px solid var(--gray-200);
}

.history-table td {
  padding: .65rem .8rem;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}

.history-table tr:hover td { background: var(--gray-50); }

.status-badge {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 700;
}

.status-draft { background: var(--gray-100); color: var(--gray-500); }
.status-sent { background: #dbeafe; color: #1d4ed8; }
.status-accepted { background: #d1fae5; color: #065f46; }
.status-rejected { background: #fee2e2; color: #991b1b; }

.action-btns { display: flex; gap: .4rem; align-items: center; }

/* ── Action Dropdown ────────────────────────────────────── */
.action-more { position: relative; }
.action-more-btn { font-size: 1rem; letter-spacing: .05em; padding: .3rem .6rem; }
.action-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,.1);
  min-width: 120px;
  z-index: 200;
  overflow: hidden;
}
.action-menu.open { display: block; }
.action-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: .55rem 1rem;
  font-size: .82rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-700);
  font-family: inherit;
  white-space: nowrap;
}
.action-menu-item:hover { background: var(--gray-50); }
.action-menu-item.danger { color: var(--danger); }
.action-menu-item.danger:hover { background: #fef2f2; }
.action-menu-divider { height: 1px; background: var(--gray-100); margin: .25rem 0; }

/* ── Empty State ────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--gray-400);
}
.empty-state p { margin-top: .5rem; font-size: .875rem; }

/* ── Editor Layout ──────────────────────────────────────── */
.editor-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 1rem;
  align-items: start;
}

@media (max-width: 900px) {
  .editor-layout { grid-template-columns: 1fr; }
}

.editor-left { display: flex; flex-direction: column; gap: 1rem; }
.editor-right { display: flex; flex-direction: column; gap: 1rem; }

/* Package presets */
.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .6rem;
  margin-bottom: .5rem;
}

.preset-card {
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  padding: .7rem .8rem;
  cursor: pointer;
  transition: all .15s;
  text-align: center;
}

.preset-card:hover { border-color: var(--brand); background: var(--brand-light); }
.preset-card-name { font-weight: 700; font-size: .85rem; margin-bottom: .2rem; }
.preset-card-desc { font-size: .75rem; color: var(--gray-400); }

/* ── Toggle Switch ──────────────────────────────────────── */
.toggle-switch {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  position: relative;
}

.toggle-switch input { display: none; }

.toggle-track {
  width: 36px;
  height: 20px;
  background: var(--gray-300);
  border-radius: 99px;
  position: relative;
  transition: background .2s;
}

.toggle-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
}

.toggle-switch input:checked + .toggle-track {
  background: var(--success);
}

.toggle-switch input:checked + .toggle-track::after {
  transform: translateX(16px);
}

/* ── Alerts ─────────────────────────────────────────────── */
.alert {
  padding: .7rem 1rem;
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: .75rem;
}
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }

/* ── Print Preview Modal ────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
  overflow-y: auto;
}
.modal-overlay.open { display: flex; }

.modal {
  background: #fff;
  border-radius: 12px;
  max-width: 860px;
  width: 100%;
  box-shadow: 0 25px 50px rgba(0,0,0,.3);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--gray-200);
}
.modal-header h2 { font-size: 1rem; }
.modal-actions { display: flex; gap: .6rem; }

.modal-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--gray-400);
  padding: .2rem .4rem;
  border-radius: 4px;
}
.modal-close:hover { background: var(--gray-100); color: var(--gray-700); }

.modal-body { padding: 1.5rem; }

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .6rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--gray-200);
}

/* ── Tooltip ─────────────────────────────────────────────── */
.tooltip-wrap { position: relative; display: inline-block; }

/* ════════════════════════════════════════════════════════════
   RWD — Mobile Header & Sidebar Drawer
   ════════════════════════════════════════════════════════════ */

/* 手機頂部 Header（桌機隱藏） */
.mobile-header {
  display: none;
  align-items: center;
  gap: .75rem;
  padding: .7rem 1rem;
  background: #1e293b;
  position: sticky;
  top: 0;
  z-index: 200;
}

.mobile-header .mobile-brand {
  flex: 1;
  font-size: 1rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: .05em;
}

.hamburger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  padding: 6px;
  background: rgba(255,255,255,.1);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
}
.hamburger span {
  display: block;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: all .2s;
}

/* Sidebar 遮罩（手機專用） */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 149;
}
.sidebar-overlay.open { display: block; }

/* ── 手機 Sidebar 抽屜 ── */
@media (max-width: 768px) {
  /* 隱藏原始側邊欄（改為抽屜） */
  .sidebar-shell .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 150;
  }
  .sidebar-shell .sidebar.open {
    transform: translateX(0);
  }

  /* 顯示手機 Header */
  .mobile-header {
    display: flex;
  }

  /* 主內容區不需要左 margin（sidebar 已移出流） */
  .sidebar-main {
    width: 100%;
  }

  /* 主內容 padding 縮小 */
  .main-content {
    padding: 1rem .75rem;
  }

  /* Form row：兩欄改一欄 */
  .form-row {
    grid-template-columns: 1fr;
  }

  /* 套餐預設：三欄改兩欄，手機改一欄 */
  .preset-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* 搜尋格 */
  .search-grid {
    grid-template-columns: 1fr 1fr;
  }

  /* 合約記錄操作按鈕允許換行 */
  .action-btns {
    flex-wrap: wrap;
  }

  /* Modal 全寬 */
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }
  .modal {
    border-radius: 16px 16px 0 0;
    max-height: 92vh;
    overflow-y: auto;
  }

  /* Step 指示器縮小 */
  .step-label { font-size: .65rem; }
  .step-circle { width: 28px; height: 28px; font-size: .78rem; }

  /* Editor layout 確保單欄 */
  .editor-layout { grid-template-columns: 1fr; }

  /* 登入卡片 */
  .login-card { border-radius: 0; min-height: 100vh; display: flex; flex-direction: column; justify-content: center; }
}

@media (max-width: 480px) {
  /* 更小螢幕：搜尋格全部單欄 */
  .search-grid {
    grid-template-columns: 1fr;
  }

  /* 套餐預設：單欄 */
  .preset-grid {
    grid-template-columns: 1fr;
  }

  /* Modal header 按鈕縮排 */
  .modal-header {
    flex-wrap: wrap;
    gap: .5rem;
    padding: .75rem 1rem;
  }
  .modal-actions {
    flex-wrap: wrap;
    gap: .4rem;
  }
  .modal-body {
    padding: 1rem;
  }

  /* 合約記錄表格：部分欄位在極小螢幕隱藏 */
  .history-table .col-hide-xs { display: none; }
}
