/* ============================================================
   後台管理系統 — 共享樣式
   設計系統：深藍主色 + 中性灰 + 強調色
   ============================================================ */

:root {
  /* 主色 */
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-soft: #eff6ff;

  /* 中性色 */
  --bg: #f6f7fb;
  --surface: #ffffff;
  --border: #e7e9f0;
  --text: #1a1d29;
  --text-muted: #6b7280;
  --text-soft: #9aa1af;

  /* 強調 / 狀態 */
  --success: #16a34a;
  --success-soft: #dcfce7;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;

  /* 側欄 */
  --sidebar: #111827;
  --sidebar-text: #c7cdd9;
  --sidebar-active: #2563eb;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(17, 24, 39, 0.06), 0 1px 2px rgba(17, 24, 39, 0.04);
  --shadow-lg: 0 10px 30px rgba(17, 24, 39, 0.08);
}

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

html {
  background: var(--bg);
}

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

a {
  color: inherit;
  text-decoration: none;
}

/* ============================================================
   登入頁
   ============================================================ */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
}

@media (min-width: 900px) {
  .auth-wrap {
    grid-template-columns: 1.1fr 1fr;
  }
}

.auth-brand {
  display: none;
  background: linear-gradient(160deg, #1d4ed8 0%, #111827 100%);
  color: #fff;
  padding: 56px;
  flex-direction: column;
  justify-content: space-between;
}

@media (min-width: 900px) {
  .auth-brand {
    display: flex;
  }
}

.auth-brand .logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 18px;
}

.auth-brand .logo .mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.15);
  display: grid;
  place-items: center;
}

.auth-brand h1 {
  font-size: 34px;
  line-height: 1.25;
  font-weight: 700;
  max-width: 16ch;
}

.auth-brand p {
  color: rgba(255, 255, 255, 0.7);
  margin-top: 16px;
  max-width: 38ch;
}

.auth-brand .stats {
  display: flex;
  gap: 40px;
}

.auth-brand .stats .num {
  font-size: 26px;
  font-weight: 700;
}

.auth-brand .stats .label {
  color: rgba(255, 255, 255, 0.6);
  font-size: 13px;
}

.auth-form-side {
  display: grid;
  place-items: center;
  padding: 32px 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
}

.auth-card .mobile-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  margin-bottom: 32px;
  color: var(--brand);
}

.auth-card h2 {
  font-size: 24px;
  font-weight: 700;
}

.auth-card .sub {
  color: var(--text-muted);
  margin: 6px 0 28px;
  font-size: 14px;
}

/* ============================================================
   表單元件
   ============================================================ */
.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 7px;
  color: var(--text);
}

.input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
}

.input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

textarea.input {
  height: auto;
  padding: 12px 14px;
  resize: vertical;
  min-height: 100px;
}

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 22px;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  cursor: pointer;
}

.checkbox input {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
}

.link {
  color: var(--brand);
  font-weight: 600;
}

/* ============================================================
   按鈕
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
  white-space: nowrap;
}

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

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

.btn-primary2 {
    background: var(--brand);
    color: #fff;
}

.btn-primary2:hover {
background: var(--brand-dark);
}

.btn-block {
  width: 100%;
  height: 44px;
}

.btn-ghost {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:hover {
  background: var(--bg);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-danger:hover {
  background: #fbcaca;
}

.btn-sm {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
}

/* ============================================================
   後台佈局
   ============================================================ */
.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 248px;
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  transition: transform 0.25s;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 20px 22px;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand .mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--brand);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.nav {
  padding: 14px 12px;
  flex: 1;
  overflow-y: auto;
}

.nav-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-soft);
  padding: 14px 12px 6px;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--sidebar-text);
  margin-bottom: 2px;
  transition: background 0.15s, color 0.15s;
}

.nav a:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.nav a.active {
  background: var(--sidebar-active);
  color: #fff;
}

.nav a svg {
  flex-shrink: 0;
}

.nav a .badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
}

.sidebar-foot {
  padding: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 11px;
}

.sidebar-foot .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}

.sidebar-foot .meta {
  line-height: 1.3;
  overflow: hidden;
}

.sidebar-foot .meta .name {
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}

.sidebar-foot .meta .role {
  color: var(--text-soft);
  font-size: 12px;
}

/* 主內容區 */
.main {
  flex: 1;
  margin-left: 248px;
  min-width: 0;
}

.topbar {
  height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar .menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
}

.topbar h1 {
  font-size: 18px;
  font-weight: 700;
}

.topbar .search {
  margin-left: auto;
  position: relative;
  max-width: 280px;
  width: 100%;
}

.topbar .search input {
  height: 38px;
  padding-left: 38px;
}

.topbar .search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-soft);
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--text-muted);
  position: relative;
}

.icon-btn:hover {
  background: var(--bg);
}

.icon-btn .dot {
  position: absolute;
  top: 8px;
  right: 9px;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--surface);
}

.content {
  padding: 24px;
  max-width: 1280px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.page-head .title {
  font-size: 22px;
  font-weight: 700;
}

.page-head .desc {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 2px;
}

.page-head .actions {
  display: flex;
  gap: 10px;
}

/* ============================================================
   卡片 / 統計
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-pad {
  padding: 20px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.card-head h3 {
  font-size: 15px;
  font-weight: 700;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.stat .stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat .stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand);
}

.stat .label {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
}

.stat .value {
  font-size: 28px;
  font-weight: 700;
  margin-top: 10px;
  letter-spacing: -0.02em;
}

.trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  margin-top: 6px;
}

.trend.up {
  color: var(--success);
}

.trend.down {
  color: var(--danger);
}

.trend .since {
  color: var(--text-soft);
  font-weight: 500;
}

/* ============================================================
   表格
   ============================================================ */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead th {
  text-align: left;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--bg);
}

.cell-user {
  display: flex;
  align-items: center;
  gap: 11px;
}

.cell-user .avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
}

.cell-user .name {
  font-weight: 600;
}

.cell-user .email {
  color: var(--text-soft);
  font-size: 12px;
}

.muted {
  color: var(--text-muted);
}

/* 狀態標籤 */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.tag::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.tag.success {
  background: var(--success-soft);
  color: var(--success);
}

.tag.warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.tag.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.tag.neutral {
  background: #f1f3f7;
  color: var(--text-muted);
}

.tag.brand {
  background: var(--brand-soft);
  color: var(--brand);
}

/* 行內操作 */
.row-actions {
  display: flex;
  gap: 6px;
}

.row-actions button {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--text-muted);
}

.row-actions button:hover {
  background: var(--bg);
  color: var(--text);
}

.row-actions button.del:hover {
  color: var(--danger);
  border-color: var(--danger-soft);
}

/* 工具列 / 篩選 */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.toolbar .search {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.toolbar .search input {
  padding-left: 38px;
  height: 38px;
}

.toolbar .search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-soft);
}

.toolbar select {
  height: 38px;
  width: auto;
  min-width: 130px;
}

/* 分頁 */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 10px;
}

.pagination .pages {
  display: flex;
  gap: 4px;
}

.pagination .pages button {
  min-width: 34px;
  height: 34px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  font-family: inherit;
}

.pagination .pages button.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.pagination .pages button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ============================================================
   圖表（純 CSS 長條圖）
   ============================================================ */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

@media (min-width: 1000px) {
  .grid-2 {
    grid-template-columns: 1.6fr 1fr;
  }
}

.bars {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  height: 220px;
  padding: 20px;
}

.bars .bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  height: 100%;
  justify-content: flex-end;
}

.bars .bar {
  width: 100%;
  max-width: 38px;
  background: var(--brand);
  border-radius: 6px 6px 0 0;
  transition: height 0.3s;
}

.bars .bar.soft {
  background: var(--brand-soft);
}

.bars .bar-label {
  font-size: 12px;
  color: var(--text-muted);
}

/* 進度 / 來源列表 */
.bar-list {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.bar-list .item .row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 6px;
}

.bar-list .item .row .pct {
  font-weight: 600;
}

.track {
  height: 8px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
}

.track .fill {
  height: 100%;
  background: var(--brand);
  border-radius: 999px;
}

/* 活動列表 */
.activity {
  padding: 8px 20px 20px;
}

.activity .item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.activity .item:last-child {
  border-bottom: none;
}

.activity .dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.activity .txt {
  font-size: 14px;
}

.activity .txt .time {
  color: var(--text-soft);
  font-size: 12px;
}

/* 設定頁 */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

@media (max-width: 640px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

.form-grid .full {
  grid-column: 1 / -1;
}

.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.switch:last-child {
  border-bottom: none;
}

.switch .info .t {
  font-weight: 600;
  font-size: 14px;
}

.switch .info .d {
  color: var(--text-muted);
  font-size: 13px;
}

.toggle {
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: #d1d5db;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  border: none;
  transition: background 0.2s;
}

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

.toggle.on {
  background: var(--brand);
}

.toggle.on::after {
  transform: translateX(20px);
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
}

.tabs button {
  padding: 12px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}

.tabs button.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

/* 遮罩 */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.5);
  z-index: 35;
}

/* ============================================================
   響應式
   ============================================================ */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main {
    margin-left: 0;
  }
  .topbar .menu-toggle {
    display: grid;
    place-items: center;
  }
  .overlay.open {
    display: block;
  }
  .topbar .search {
    display: none;
  }
}

.avatar-1 { background: #2563eb; }
.avatar-2 { background: #16a34a; }
.avatar-3 { background: #d97706; }
.avatar-4 { background: #dc2626; }
.avatar-5 { background: #7c3aed; }
.avatar-6 { background: #0891b2; }

/* ============================================================
   內容維護頁 (content-upt.html)
   ============================================================ */
.edit-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
}
.edit-main,
.edit-side {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}
@media (max-width: 960px) {
  .edit-grid {
    grid-template-columns: 1fr;
  }
}

.field .req {
  color: var(--danger);
}
.field .hint {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-soft);
}
textarea.input {
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
}

.uploader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  padding: 28px 16px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.uploader:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.uploader .up-text {
  font-size: 13px;
  color: var(--text-muted);
}
.uploader .up-text span {
  color: var(--brand);
  font-weight: 600;
}

.form-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
@media (max-width: 560px) {
  .form-foot {
    flex-direction: column-reverse;
  }
  .form-foot .btn {
    width: 100%;
  }
}



