/* ============================================
   SaaS E-commerce Admin — Professional Theme
   ============================================ */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --success: #16a34a;
  --success-light: #f0fdf4;
  --warning: #d97706;
  --warning-light: #fffbeb;
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-active: rgba(37,99,235,.15);
  --sidebar-active-border: var(--primary);
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #f1f5f9;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,.06), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.08), 0 4px 6px rgba(0,0,0,.04);
  --sidebar-w: 260px;
  --topbar-h: 60px;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --info: #2563eb;
  --info-light: #dbeafe;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---- Layout ---- */
.app { display: flex; min-height: 100vh; }

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w);
  background: #ffffff;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform .25s cubic-bezier(.4,0,.2,1);
  display: flex;
  flex-direction: column;
  border-right: 1px solid #e5e7eb;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }

.sidebar-header {
  padding: 20px 20px 18px;
  border-bottom: 1px solid #f3f4f6;
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-header .brand-logo {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(79,70,229,.25);
}
.sidebar-header .brand-logo svg { width: 22px; height: 22px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-header .brand-text { min-width: 0; }
.sidebar-header .brand {
  font-size: 16px;
  font-weight: 700;
  color: #111827;
  letter-spacing: -.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}
.sidebar-header .brand-sub {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 2px;
  font-weight: 500;
}

.sidebar-nav { padding: 16px 0; flex: 1; }
.nav-section {
  padding: 24px 20px 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #9ca3af;
}
.nav-section:first-child { padding-top: 4px; }
.nav-item {
  display: flex;
  align-items: center;
  padding: 0 14px;
  height: 42px;
  margin: 2px 10px;
  color: #6b7280;
  text-decoration: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all .2s cubic-bezier(.4,0,.2,1);
  border-left: none;
  border-radius: 10px;
  gap: 12px;
}
.nav-item:hover {
  background: #f3f4f6;
  color: #111827;
}
.nav-item.active {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: #fff;
  box-shadow: 0 4px 12px rgba(79,70,229,.25);
  font-weight: 600;
}
.nav-item .icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.nav-item .icon svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-item:hover .icon svg { stroke: #111827; }
.nav-item.active .icon svg { stroke: #fff; }

/* ---- Main ---- */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- Topbar ---- */
.topbar {
  height: var(--topbar-h);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title { font-size: 16px; font-weight: 600; color: var(--text); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }

/* ---- Content ---- */
.content { padding: 28px; flex: 1; }

/* ---- Cards ---- */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}
.card-body { padding: 20px; }
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h3 { font-size: 14px; font-weight: 600; color: var(--text); }

/* ---- Stats ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.stat-card .label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 8px;
}
.stat-card .value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.02em;
  line-height: 1.1;
}
.stat-card .sub { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-outline { background: var(--card-bg); border-color: var(--border); color: var(--text-secondary); }
.btn-outline:hover { background: var(--bg); border-color: #cbd5e1; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 10px 20px; font-size: 14px; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
  color: var(--text-secondary);
  vertical-align: middle;
}
tr:hover td { background: #f8fafc; }
tr:last-child td { border-bottom: none; }

/* ---- Forms ---- */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  padding: 9px 12px;
  font-size: 13px;
  font-family: var(--font);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.form-control::placeholder { color: var(--text-muted); }
textarea.form-control { min-height: 80px; resize: vertical; }
select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 36px;
}

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  line-height: 1.6;
}
.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef3c7; color: #a16207; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-info { background: #dbeafe; color: #1d4ed8; }
.badge-gray { background: #f1f5f9; color: #475569; }

/* ---- Modal ---- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.4);
  backdrop-filter: blur(4px);
  z-index: 200;
  justify-content: center;
  align-items: flex-start;
  padding-top: 60px;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0,0,0,.04);
  animation: modalIn .2s ease-out;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(-12px) scale(.98); } }
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: var(--bg);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.modal-close {
  background: none;
  border: none;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  font-size: 18px;
  transition: all .15s;
}
.modal-close:hover { background: var(--bg); color: var(--text); }

/* ---- Toolbar ---- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.toolbar .search-input { max-width: 280px; }
.toolbar .spacer { flex: 1; }

/* ---- Pagination ---- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px;
}
.pagination button {
  padding: 6px 12px;
  font-size: 13px;
  font-family: var(--font);
  border: 1px solid var(--border);
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  transition: all .15s;
}
.pagination button:hover:not(:disabled) { background: var(--bg); }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }

/* ---- Toast ---- */
.toast-container { position: fixed; top: 16px; right: 16px; z-index: 300; }
.toast {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  box-shadow: var(--shadow-md);
  animation: toastIn .3s ease-out;
}
.toast-success { background: #059669; }
.toast-error { background: var(--danger); }
@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } }

/* ---- Loading ---- */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 13px;
}
.loading::before {
  content: '';
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  margin-right: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ Login Page (split-screen) ============ */
.login-page {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(420px, 45%) 1fr;
  background: var(--card-bg);
  z-index: 10000;
  overflow: hidden;
}

/* ---- Left: form panel ---- */
.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 60px;
  overflow-y: auto;
}
.login-panel-inner {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 96px);
}

/* Brand wordmark */
.login-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  margin-bottom: 64px;
}
.login-brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #4f46e5 0%, #2563eb 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(79, 70, 229, .25);
}
.login-brand-mark svg {
  width: 20px; height: 20px;
  stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.login-brand-text {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.005em;
}
.login-brand-text em {
  font-style: normal;
  font-weight: 400;
  color: var(--text-muted);
  font-size: 14px;
  margin-left: 6px;
}

/* Form */
.login-form { display: flex; flex-direction: column; gap: 22px; }
.login-title {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  line-height: 1.15;
  letter-spacing: -.02em;
}
.login-title-dot { color: #f97316; }
.login-subtitle {
  font-size: 14.5px;
  color: var(--text-secondary);
  margin: -8px 0 8px;
  line-height: 1.6;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.login-field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: .04em;
}
.login-field-input {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.login-field-input:focus-within {
  border-color: #4f46e5;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, .08);
}
.login-field-input svg {
  width: 18px; height: 18px;
  stroke: var(--text-muted); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0;
}
.login-field-input input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  padding: 14px 0;
  font-family: inherit;
  font-size: 14.5px;
  color: var(--text);
  min-width: 0;
}
.login-field-input input::placeholder { color: #94a3b8; }
.login-field-toggle {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  color: var(--text-muted);
  transition: color .2s;
}
.login-field-toggle:hover { color: var(--text); }
.login-field-toggle svg { width: 16px; height: 16px; stroke: currentColor; }
.login-field-hint {
  font-size: 12px;
  color: var(--text-muted);
  padding-left: 4px;
}

/* Submit */
.login-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 15px 24px;
  background: linear-gradient(135deg, #4f46e5 0%, #2563eb 100%);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .04em;
  cursor: pointer;
  margin-top: 4px;
  box-shadow: 0 8px 20px rgba(79, 70, 229, .3);
  transition: transform .2s, box-shadow .2s, gap .2s;
}
.login-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(79, 70, 229, .35);
  gap: 14px;
}
.login-submit:active { transform: translateY(0); }
.login-submit svg {
  width: 16px; height: 16px;
  stroke: #fff; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round;
}

.login-aux {
  font-size: 13.5px;
  color: var(--text-secondary);
  text-align: center;
  margin: 6px 0 0;
}
.login-aux a {
  color: #4f46e5;
  font-weight: 600;
  text-decoration: none;
}
.login-aux a:hover { text-decoration: underline; }

/* Error banner */
.login-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger);
  padding: 11px 14px;
  border-radius: 8px;
  font-size: 13px;
  display: none;
  margin-top: -6px;
}

/* Footer */
.login-footer {
  margin-top: auto;
  padding-top: 56px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.8;
}
.login-footer p { margin: 0; }
.login-footer strong { color: var(--text-secondary); font-weight: 600; }
.login-footer a {
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.login-footer a:hover { border-bottom-color: var(--text-muted); }
.login-footer-meta {
  margin-top: 16px !important;
  font-size: 10.5px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: #cbd5e1;
}

/* ---- Right: hero photo panel ---- */
.login-hero {
  position: relative;
  overflow: hidden;
  background: #0f172a;
}
.login-hero-image {
  position: absolute;
  inset: 0;
  background-image: url('https://images.pexels.com/photos/3965545/pexels-photo-3965545.jpeg?auto=compress&cs=tinysrgb&w=1600');
  background-size: cover;
  background-position: center;
  filter: saturate(1.05);
}
.login-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(79, 70, 229, .35) 0%, rgba(15, 23, 42, .55) 100%);
  z-index: 1;
}
.login-hero-overlay {
  position: relative;
  z-index: 2;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 64px;
  color: #fff;
}
.login-hero-tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .32em;
  color: rgba(255, 255, 255, .85);
  margin: 0 0 18px;
  text-transform: uppercase;
}
.login-hero-quote {
  font-family: 'Noto Serif TC', Georgia, serif;
  font-size: clamp(28px, 3.4vw, 44px);
  font-weight: 500;
  line-height: 1.25;
  margin: 0 0 28px;
  letter-spacing: .005em;
  text-shadow: 0 2px 20px rgba(0, 0, 0, .25);
}
.login-hero-quote em {
  font-style: normal;
  color: #f97316;
  font-weight: 700;
}
.login-hero-credit {
  font-size: 12.5px;
  color: rgba(255, 255, 255, .75);
  letter-spacing: .12em;
  text-transform: uppercase;
  margin: 0;
  font-weight: 500;
}

/* Responsive */
@media (max-width: 900px) {
  .login-page { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .login-panel { padding: 36px 28px; }
  .login-brand { margin-bottom: 40px; }
  .login-panel-inner { min-height: auto; }
  .login-footer { padding-top: 40px; }
}
@media (max-width: 480px) {
  .login-title { font-size: 26px; }
  .login-panel { padding: 28px 20px; }
}
.login-link a { color: var(--primary); text-decoration: none; font-weight: 500; }
.login-link a:hover { text-decoration: underline; }

/* ---- Image ---- */
.img-preview { width: 44px; height: 44px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border-light); }
.img-upload {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  transition: border-color .15s, background .15s;
}
.img-upload:hover { border-color: var(--primary); background: var(--primary-light); }
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; margin-top: 8px; }
.img-grid img { width: 100%; height: 72px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border-light); }

/* ---- Editor ---- */
.editor-frame { width: 100%; height: calc(100vh - 180px); border: 1px solid var(--border); border-radius: var(--radius); }

/* ---- Responsive ---- */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 20px;
  align-items: center;
  justify-content: center;
}
.menu-toggle:hover { background: var(--bg); }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); z-index: 200; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: flex; }
  .content { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar { padding: 0 16px; }
}

/* ---- KPI Dashboard ---- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: box-shadow .2s, transform .2s;
}
.kpi-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.kpi-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
}
.kpi-card.kpi-blue::after { background: linear-gradient(90deg, #2563eb, #3b82f6); }
.kpi-card.kpi-purple::after { background: linear-gradient(90deg, #7c3aed, #8b5cf6); }
.kpi-card.kpi-cyan::after { background: linear-gradient(90deg, #0891b2, #06b6d4); }
.kpi-card.kpi-green::after { background: linear-gradient(90deg, #059669, #10b981); }
.kpi-card.kpi-orange::after { background: linear-gradient(90deg, #d97706, #f59e0b); }
.kpi-card.kpi-indigo::after { background: linear-gradient(90deg, #4f46e5, #6366f1); }

.kpi-top {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.kpi-icon svg { width: 22px; height: 22px; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.kpi-icon.blue { background: #eff6ff; color: #2563eb; }
.kpi-icon.blue svg { stroke: #2563eb; }
.kpi-icon.purple { background: #f5f3ff; color: #7c3aed; }
.kpi-icon.purple svg { stroke: #7c3aed; }
.kpi-icon.cyan { background: #ecfeff; color: #0891b2; }
.kpi-icon.cyan svg { stroke: #0891b2; }
.kpi-icon.green { background: #f0fdf4; color: #059669; }
.kpi-icon.green svg { stroke: #059669; }
.kpi-icon.orange { background: #fffbeb; color: #d97706; }
.kpi-icon.orange svg { stroke: #d97706; }
.kpi-icon.indigo { background: #eef2ff; color: #4f46e5; }
.kpi-icon.indigo svg { stroke: #4f46e5; }

.kpi-content { flex: 1; min-width: 0; }
.kpi-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 6px;
}
.kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.02em;
  line-height: 1.1;
}
.kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.kpi-sub svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; }
.kpi-clickable { cursor: pointer; }
.kpi-clickable:hover { border-color: var(--primary); }

/* Chart card */
.chart-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  overflow: hidden;
}
.chart-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chart-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.chart-header .chart-badge {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--primary-light);
  color: var(--primary);
}
.chart-body { padding: 16px 20px 20px; }

@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-grid-3 { grid-template-columns: 1fr; }
  .kpi-value { font-size: 22px; }
  .kpi-icon { width: 40px; height: 40px; border-radius: 10px; }
  .kpi-icon svg { width: 18px; height: 18px; }
}

/* ---- Utility ---- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-gray { color: var(--text-muted); }
.text-muted { color: var(--text-muted); }
.font-semibold { font-weight: 600; }
.font-mono { font-family: var(--mono); font-size: 12px; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Featured star toggle (商品列表) */
.featured-star{display:inline-flex;align-items:center;justify-content:center;width:30px;height:30px;background:transparent;border:none;border-radius:6px;cursor:pointer;font-size:18px;line-height:1;color:#cbd5e1;transition:color .2s,background .2s,transform .15s}
.featured-star:hover{background:#fef3c7;color:#f59e0b;transform:scale(1.1)}
.featured-star.is-on{color:#f59e0b}
.featured-star.is-on:hover{color:#d97706}

/* ============================================
   Settings Page (商店設定)
   ============================================ */
.settings-wrap{max-width:920px;margin:0 auto;padding:8px 0}
.settings-wrap .card{margin-bottom:24px;padding:0;border:1px solid var(--border);border-radius:var(--radius-lg);overflow:hidden;transition:border-color .2s,box-shadow .2s;background:#fff}
.settings-wrap .card:hover{border-color:#cbd5e1}

/* Header — generous padding so titles never feel cramped */
.settings-wrap .card-header{padding:22px 28px;background:#fafbfc;border-bottom:1px solid var(--border-light);display:flex;align-items:center;justify-content:space-between;gap:16px;margin:0}
.settings-wrap .card-header h3{font-size:14.5px;font-weight:600;color:var(--text);letter-spacing:-.005em;margin:0;display:flex;align-items:center;gap:10px;line-height:1.4}
.settings-wrap .card-header h3::before{content:'';display:inline-block;width:3px;height:14px;background:var(--primary);border-radius:2px;flex-shrink:0}
.settings-wrap .card-section-desc{font-size:12.5px;color:var(--text-muted);margin:0;line-height:1.5}

/* Card body children get uniform horizontal padding (header has its own).
   Buttons are excluded — they need MARGIN not padding so they sit inset from the card edge instead of stretching. */
.settings-wrap .card > *:not(.card-header):not(.btn){padding-left:28px;padding-right:28px}

/* The very FIRST element after the header gets generous top breathing space */
.settings-wrap .card-header + *{margin-top:24px !important}

/* The LAST element gets bottom breathing space (when not a button — buttons have their own margin below) */
.settings-wrap .card > *:last-child:not(.card-header):not(.btn){margin-bottom:24px}

/* Button: margin from card edges instead of padding */
.settings-wrap .card > .btn{margin:14px 28px 26px;display:inline-block}

/* Section subheadings (e.g. LINE NOTIFY / EMAIL inside 通知設定) */
.settings-wrap .card > h4{font-size:11px;font-weight:700;color:var(--text-muted);text-transform:uppercase;letter-spacing:.14em;margin-top:24px;margin-bottom:10px}

/* Description paragraphs sit close to the content they describe */
.settings-wrap .card > p{font-size:13px;color:var(--text-muted);line-height:1.65;margin-top:0;margin-bottom:14px}

/* Tables (staff list etc.) */
.settings-wrap .card > table{width:auto;min-width:calc(100% - 56px);margin:0 0 14px}
.settings-wrap .card > #staffList{padding-top:0;padding-bottom:0}

/* Form polish */
.settings-wrap .form-group{margin-bottom:18px}
.settings-wrap .form-group label{font-size:12.5px;font-weight:500;color:var(--text-secondary);margin-bottom:7px;letter-spacing:.005em;display:flex;align-items:center;gap:8px}
.settings-wrap .form-group label .badge{font-size:10px;padding:2px 7px}
.settings-wrap .form-control{padding:10px 13px;font-size:13.5px;border-radius:8px;background:#fff}
.settings-wrap .form-control:hover:not(:focus){border-color:#cbd5e1}
.settings-wrap .form-control:disabled{background:#f8fafc;color:var(--text-muted);cursor:not-allowed}
.settings-wrap textarea.form-control{min-height:72px;line-height:1.6}

/* Settings save button — make it primary action */
.settings-wrap .card > .btn-primary{padding:9px 18px;font-size:13px;border-radius:8px;font-weight:500}

/* ===== 網站類型 toggle card (special primary card) ===== */
.settings-toggle-card{margin-bottom:20px;padding:0;border-radius:var(--radius-lg);overflow:hidden;background:linear-gradient(135deg,#eff6ff 0%,#dbeafe 100%);border:1px solid #bfdbfe;transition:all .25s}
.settings-toggle-card.is-on{background:linear-gradient(135deg,#f0fdf4 0%,#dcfce7 100%);border-color:#bbf7d0}
.settings-toggle-row{display:flex;align-items:center;justify-content:space-between;gap:24px;padding:24px 28px;flex-wrap:wrap}
.settings-toggle-info{flex:1;min-width:240px}
.settings-toggle-info .heading{display:flex;align-items:center;gap:10px;margin-bottom:6px}
.settings-toggle-info .heading h3{font-size:15px;font-weight:600;color:var(--text);margin:0;letter-spacing:-.005em}
.settings-toggle-info .status-pill{display:inline-flex;align-items:center;gap:5px;padding:3px 9px;font-size:10.5px;font-weight:600;letter-spacing:.04em;text-transform:uppercase;border-radius:100px;background:#fff;color:var(--text-muted)}
.settings-toggle-card.is-on .status-pill{background:#16a34a;color:#fff}
.settings-toggle-info .desc{font-size:13px;color:var(--text-secondary);line-height:1.55;margin:0}
.settings-toggle-actions{display:flex;align-items:center;gap:14px;flex-shrink:0}

/* iOS-style switch */
.toggle-switch{position:relative;display:inline-block;width:48px;height:28px;flex-shrink:0;cursor:pointer}
.toggle-switch input{opacity:0;width:0;height:0}
.toggle-switch .slider{position:absolute;inset:0;background:#cbd5e1;border-radius:28px;transition:background .3s var(--ease,ease);box-shadow:inset 0 1px 2px rgba(0,0,0,.06)}
.toggle-switch .slider::before{content:'';position:absolute;left:3px;top:3px;width:22px;height:22px;background:#fff;border-radius:50%;transition:transform .3s cubic-bezier(.4,0,.2,1);box-shadow:0 1px 3px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.08)}
.toggle-switch input:checked + .slider{background:#16a34a}
.toggle-switch input:checked + .slider::before{transform:translateX(20px)}
.toggle-switch:hover .slider{box-shadow:inset 0 1px 2px rgba(0,0,0,.1),0 0 0 4px rgba(15,23,42,.04)}

/* Footer info card (last small gray card) */
.settings-wrap .card[style*="gray-50"]{background:var(--bg);border:1px dashed var(--border)}

/* Compact responsive */
@media (max-width:768px){
  .settings-wrap{max-width:100%}
  .settings-wrap .card-header{padding:14px 18px}
  .settings-wrap .card > .form-group,
  .settings-wrap .card > div[style*="grid"]{padding-left:18px;padding-right:18px}
  .settings-wrap .card > .btn{margin:8px 18px 18px}
  .settings-toggle-row{padding:20px;gap:16px}
  .settings-toggle-actions{width:100%;justify-content:space-between}
}
