/* 淨淨百貨門市儀表板 — 共用樣式 (v2: sidebar + 篩選) */
:root {
  --brand: #61D0DF;
  --brand-dark: #3FB7C8;
  --brand-light: #E8F8FB;
  --bg: #FAFBFC;
  --card: #FFFFFF;
  --text: #1F2937;
  --text-sub: #6B7280;
  --text-mute: #9CA3AF;
  --border: #E5E7EB;
  --shadow: 0 1px 3px rgba(0,0,0,0.04), 0 2px 8px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.06);
  --ok: #10B981;
  --warn: #F59E0B;
  --err: #EF4444;
  --info: #6366F1;
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 240px;
}

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

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

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

/* ========= Layout (Sidebar) ========= */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: row;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 0;
}

.sidebar-brand {
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--border);
  display: block;
  text-decoration: none;
}
.sidebar-brand:hover { text-decoration: none; }
.sidebar-brand .logo-img { width: 100%; max-width: 160px; height: auto; display: block; }
.sidebar-brand .brand-sub { font-size: 13px; color: var(--text-sub); margin-top: 4px; letter-spacing: 1px; font-weight: 600; }

.sidebar-nav {
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-bottom: 1px solid var(--border);
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-sub);
  font-weight: 500;
  font-size: 14px;
  transition: all 0.15s;
}
.sidebar-nav a:hover { background: var(--brand-light); color: var(--brand-dark); text-decoration: none; }
.sidebar-nav a.active { background: var(--brand-light); color: var(--brand-dark); font-weight: 600; }
.sidebar-nav a i { font-size: 18px; }

.sidebar-filter {
  padding: 16px 16px 8px;
  border-bottom: 1px solid var(--border);
  flex: 1;
  overflow-y: auto;
}
.sidebar-filter h4 {
  font-size: 11px;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}
.sidebar-filter h4 i { font-size: 14px; }
.sidebar-filter .filter-group { margin-bottom: 16px; }

/* 月份按鈕 */
.month-btns { display: flex; flex-wrap: wrap; gap: 4px; }
.month-btns button {
  padding: 5px 10px;
  border: 1px solid var(--border);
  background: white;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-sub);
  font-weight: 500;
  transition: all 0.15s;
}
.month-btns button:hover { border-color: var(--brand); color: var(--brand-dark); }
.month-btns button.active { background: var(--brand); color: white; border-color: var(--brand); }

/* 店面 checkbox */
.store-checks { display: flex; flex-direction: column; gap: 4px; }
.store-checks label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.1s;
}
.store-checks label:hover { background: var(--brand-light); }
.store-checks input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--brand);
  cursor: pointer;
}
.store-checks .status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block;
  margin-left: auto;
}
.store-checks .status-dot.active { background: var(--ok); }
.store-checks .status-dot.closed { background: var(--text-mute); }
.store-checks .status-dot.new { background: var(--warn); }

.filter-actions {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}
.filter-actions button {
  flex: 1;
  padding: 5px;
  border: 1px solid var(--border);
  background: white;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  color: var(--text-sub);
}
.filter-actions button:hover { background: var(--brand-light); color: var(--brand-dark); }

.sidebar-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-mute);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-foot a { color: var(--text-mute); }

.content {
  flex: 1;
  padding: 24px 28px;
  max-width: calc(100vw - var(--sidebar-w));
  min-width: 0;
}

/* ========= Card ========= */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 20px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.card.hover:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-sub);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title i { color: var(--brand-dark); font-size: 18px; }

/* ========= KPI ========= */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.kpi-label { font-size: 13px; color: var(--text-sub); display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.kpi-label i { color: var(--brand-dark); }
.kpi-value { font-size: 28px; font-weight: 700; color: var(--text); letter-spacing: -0.5px; }
.kpi-sub { font-size: 12px; color: var(--text-mute); margin-top: 4px; }

/* ========= Badge ========= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
}
.badge.active { background: #DEFCE9; color: #0F7A4F; }
.badge.new { background: #FEF3C7; color: #92400E; }
.badge.closed { background: #F3F4F6; color: #6B7280; }
.badge.warn { background: #FEF3C7; color: #92400E; }
.badge.err { background: #FEE2E2; color: #991B1B; }
.badge.ok { background: #DEFCE9; color: #0F7A4F; }

/* ========= Table ========= */
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.data th {
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  color: var(--text-sub);
  background: #F9FAFB;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  position: sticky; top: 0;
}
table.data td {
  padding: 10px 12px;
  border-bottom: 1px solid #F3F4F6;
  vertical-align: top;
}
table.data tr:hover td { background: #F9FAFB; }
table.data tr.total-row td {
  background: var(--brand-light);
  font-weight: 700;
  border-top: 2px solid var(--brand);
  border-bottom: 1px solid var(--brand);
  color: var(--brand-dark);
}
table.data tr.grand-total td {
  background: var(--brand);
  color: white;
  font-weight: 800;
  font-size: 15px;
}
.num { font-variant-numeric: tabular-nums; text-align: right; }

/* ========= Bar ========= */
.bar-wrap { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.bar-label { width: 110px; font-size: 13px; color: var(--text); flex-shrink: 0; }
.bar-track {
  flex: 1; height: 24px;
  background: #F3F4F6;
  border-radius: 6px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--brand-dark));
  border-radius: 6px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  color: white;
  font-size: 12px;
  font-weight: 600;
  min-width: 4px;
}
.bar-value {
  width: 90px;
  text-align: right;
  font-size: 13px;
  color: var(--text-sub);
  font-variant-numeric: tabular-nums;
}

/* ========= Store card grid ========= */
.store-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.store-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
  display: block;
  color: inherit;
  text-decoration: none;
}
.store-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--brand);
  text-decoration: none;
}
.store-card.dim { opacity: 0.4; }
.store-card-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.store-card-name { font-size: 17px; font-weight: 700; }
.store-card-period { font-size: 12px; color: var(--text-mute); margin-bottom: 14px; }
.store-card-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; font-size: 13px; }
.store-card-stat-label { color: var(--text-mute); font-size: 11px; }
.store-card-stat-val { font-weight: 600; font-size: 16px; }

/* ========= Section ========= */
.section { margin-bottom: 28px; }
.section-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title i { color: var(--brand-dark); }
.section-title small { font-size: 13px; color: var(--text-mute); font-weight: 400; }

/* ========= Filter pill (top of content) ========= */
.filter-pill-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--brand-light);
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 13px;
  color: var(--text-sub);
}
.filter-pill-bar strong { color: var(--brand-dark); }
.filter-pill-bar .pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: white;
  border: 1px solid var(--brand);
  border-radius: 999px;
  color: var(--brand-dark);
  font-weight: 600;
}

/* ========= Warning banner ========= */
.warn-banner {
  background: #FFFBEB;
  border-left: 4px solid var(--warn);
  padding: 10px 14px;
  border-radius: 4px;
  margin-bottom: 12px;
  font-size: 13px;
  color: #78350F;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.warn-banner.err { background: #FEF2F2; border-left-color: var(--err); color: #7F1D1D; }
.warn-banner i { color: var(--warn); flex-shrink: 0; margin-top: 2px; }
.warn-banner.err i { color: var(--err); }

/* ========= Empty ========= */
.empty { text-align: center; padding: 40px 20px; color: var(--text-mute); }
.empty i { font-size: 48px; color: var(--text-mute); margin-bottom: 10px; }

/* ========= Mobile ========= */
@media (max-width: 900px) {
  :root { --sidebar-w: 100%; }
  .app { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-brand { padding: 12px 16px; }
  .sidebar-brand .logo-img { max-width: 120px; }
  .sidebar-nav { flex-direction: row; padding: 8px 12px; overflow-x: auto; }
  .sidebar-nav a { white-space: nowrap; padding: 8px 12px; font-size: 13px; }
  .sidebar-filter { padding: 12px 16px; }
  .sidebar-foot { padding: 8px 16px; }
  .content { padding: 14px; max-width: 100vw; }
  .kpi-grid { gap: 12px; }
  .kpi-value { font-size: 22px; }
  .store-grid { gap: 12px; grid-template-columns: 1fr; }
  .bar-label { width: 90px; font-size: 12px; }
  .bar-value { width: 70px; font-size: 12px; }
}

/* ========= Login overlay ========= */
.login-overlay {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #E8F8FB 0%, #FFFFFF 100%);
  z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-box {
  background: white; padding: 36px 32px; border-radius: 16px;
  box-shadow: 0 8px 40px rgba(97, 208, 223, 0.2);
  max-width: 360px; width: 100%; text-align: center;
}
.login-box .brand-logo { height: 64px; width: auto; display: block; margin: 0 auto 16px; }
.login-box h1 { font-size: 20px; margin-bottom: 8px; }
.login-box p { font-size: 13px; color: var(--text-mute); margin-bottom: 20px; }
.login-box input {
  width: 100%; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 15px; margin-bottom: 12px;
}
.login-box input:focus { outline: none; border-color: var(--brand); }
.login-box button {
  width: 100%; padding: 12px;
  background: var(--brand); color: white;
  border: none; border-radius: 8px;
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: background 0.15s;
}
.login-box button:hover { background: var(--brand-dark); }
.login-error { color: var(--err); font-size: 13px; margin-top: 8px; min-height: 18px; }
