:root {
  --sidebar-w: 230px;
  --sidebar-bg: #1e293b;
  --sidebar-text: #94a3b8;
  --sidebar-active: #38bdf8;
  --top-h: 52px;
}

body { background: #f1f5f9; font-size: 14px; }

/* ── Sidebar ──────────────────────────── */
#sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  z-index: 1000; overflow-y: auto;
  transition: transform .25s;
}
#sidebar .sidebar-header {
  display: flex; align-items: center;
  padding: 16px; color: #fff; font-size: 15px;
  border-bottom: 1px solid #334155;
}
#sidebar .nav-link {
  color: var(--sidebar-text); padding: 8px 16px;
  display: flex; align-items: center; gap: 8px;
  border-radius: 6px; margin: 1px 8px;
  transition: background .15s, color .15s;
  font-size: 13.5px; font-weight: 600;
}
#sidebar .nav-link:hover, #sidebar .nav-link.active {
  background: #334155; color: #fff;
}
#sidebar .nav-link.active { color: var(--sidebar-active); }
#sidebar .nav-section {
  padding: 14px 16px 4px; font-size: 10px; text-transform: uppercase;
  letter-spacing: 1px; color: #475569;
}

/* 案場管理獨立工作區 */
#sidebar .nav-section-projects {
  margin: 6px 10px 2px;
  padding: 6px 10px 5px;
  font-size: 10px; letter-spacing: 1.5px;
  color: #7dd3fc;
  background: rgba(56,189,248,.08);
  border-left: 3px solid #38bdf8;
  border-radius: 4px;
  text-transform: uppercase;
}
#sidebar .nav-item-projects .nav-link-projects {
  font-size: 13.5px;
  font-weight: normal;
  color: var(--sidebar-text);
  padding: 8px 16px;
  border-left: none;
  margin-bottom: 0;
}
#sidebar .nav-item-projects .nav-link-projects:hover,
#sidebar .nav-item-projects .nav-link-projects.active {
  color: var(--sidebar-active);
  background: #334155;
  border-left: none;
}
#sidebar .sidebar-footer {
  margin-top: auto; padding: 12px 16px;
  border-top: 1px solid #334155; color: #94a3b8;
  font-size: 12px; display: flex; align-items: center;
}

/* ── Main ─────────────────────────────── */
#main-wrap {
  margin-left: var(--sidebar-w);
  min-height: 100vh; display: flex; flex-direction: column;
}
.top-bar {
  height: var(--top-h); background: #fff;
  border-bottom: 1px solid #e2e8f0;
  position: sticky; top: 0; z-index: 100;
}
#content { flex: 1; }

/* ── Cards & Tables ───────────────────── */
.card { border: none; box-shadow: 0 1px 3px rgba(0,0,0,.07); border-radius: 10px; }
.card-header { background: #fff; border-bottom: 1px solid #f1f5f9; font-weight: 600; }
.table th { background: #f8fafc; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: #64748b; }
.table td { vertical-align: middle; }

/* ── Stat cards ───────────────────────── */
.stat-card { border-radius: 12px; padding: 20px; color: #fff; }
.stat-card .stat-val { font-size: 28px; font-weight: 700; }
.stat-card .stat-lbl { font-size: 12px; opacity: .85; }
.stat-card .stat-note { font-size: 11px; opacity: .68; margin-top: 3px; line-height: 1.25; }

/* ── Badge status ─────────────────────── */
.badge-draft     { background: #e2e8f0; color: #475569; }
.badge-sent      { background: #dbeafe; color: #1d4ed8; }
.badge-won       { background: #d1fae5; color: #065f46; }
.badge-lost      { background: #fee2e2; color: #991b1b; }
.badge-confirmed { background: #ede9fe; color: #5b21b6; }
.badge-in_progress{ background: #fef3c7; color: #92400e; }
.badge-completed { background: #d1fae5; color: #065f46; }
.badge-cancelled { background: #f1f5f9; color: #64748b; }
.badge-unpaid    { background: #fee2e2; color: #991b1b; }
.badge-partial   { background: #fef3c7; color: #92400e; }
.badge-paid      { background: #d1fae5; color: #065f46; }

/* ── Profit bar ───────────────────────── */
.profit-bar { height: 6px; border-radius: 3px; background: #e2e8f0; }
.profit-fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg,#10b981,#34d399); }

/* ── Responsive ───────────────────────── */
#sidebar-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 999; opacity: 0; visibility: hidden; transition: opacity .25s; }
#sidebar-backdrop.show { opacity: 1; visibility: visible; }
@media (max-width: 991px) {
  #sidebar { transform: translateX(-100%); width: 80%; max-width: 300px; box-shadow: 2px 0 18px rgba(0,0,0,.4); }
  #sidebar.open { transform: translateX(0); }
  #main-wrap { margin-left: 0; }
}

/* ── Misc ─────────────────────────────── */
.search-bar { max-width: 280px; }
.cursor-pointer { cursor: pointer; }
.item-row td { font-size: 13px; }
.text-money { font-family: 'Courier New', monospace; }

/* ── Worker Picker ────────────────────── */
.worker-picker { cursor: text; position: relative; }
.worker-picker:focus-within { border-color: #86b7fe !important; box-shadow: 0 0 0 .2rem rgba(13,110,253,.15); }
.worker-dropdown { position: absolute; top: 100%; left: 0; width: 100%; margin-top: 2px; }
.worker-option:first-child { border-radius: 4px 4px 0 0; }
.worker-option:last-child  { border-radius: 0 0 4px 4px; }

/* ── Bootstrap xs button ──────────────── */
.btn-xs { font-size: .75rem; padding: .15rem .4rem; line-height: 1.3; border-radius: .2rem; }

/* ════════════════════════════════════════
   品牌主色統一（天藍 / 青）
   ════════════════════════════════════════ */
:root {
  --brand:        #0ea5e9;
  --brand-dark:   #0284c7;
  --brand-darker: #0369a1;
  --brand-soft:   #f0f9ff;
  --bs-primary:        #0ea5e9;
  --bs-primary-rgb:    14,165,233;
  --bs-link-color-rgb: 2,132,199;
  --bs-link-hover-color-rgb: 3,105,161;
}

/* 主要 / 外框按鈕 */
.btn-primary {
  --bs-btn-bg:#0ea5e9; --bs-btn-border-color:#0ea5e9;
  --bs-btn-hover-bg:#0284c7; --bs-btn-hover-border-color:#0284c7;
  --bs-btn-active-bg:#0369a1; --bs-btn-active-border-color:#0369a1;
  --bs-btn-disabled-bg:#0ea5e9; --bs-btn-disabled-border-color:#0ea5e9;
}
.btn-outline-primary {
  --bs-btn-color:#0284c7; --bs-btn-border-color:#0ea5e9;
  --bs-btn-hover-bg:#0ea5e9; --bs-btn-hover-border-color:#0ea5e9;
  --bs-btn-active-bg:#0284c7; --bs-btn-active-border-color:#0284c7;
}
.btn-link { --bs-btn-color:#0284c7; --bs-btn-hover-color:#0369a1; }

/* 文字 / 連結 / 底色 */
.text-primary { color:#0284c7 !important; }
.bg-primary   { background-color:#0ea5e9 !important; }
.link-primary { color:#0284c7 !important; }
.spinner-border.text-primary { color:#0ea5e9 !important; }

/* 表單 focus 統一品牌色 */
.form-control:focus, .form-select:focus {
  border-color:#7dd3fc; box-shadow:0 0 0 .2rem rgba(14,165,233,.2);
}
.form-check-input:checked { background-color:#0ea5e9; border-color:#0ea5e9; }
.form-check-input:focus { border-color:#7dd3fc; box-shadow:0 0 0 .2rem rgba(14,165,233,.2); }

/* 分頁標籤 active 統一 */
.nav-tabs .nav-link { color:#64748b; }
.nav-tabs .nav-link.active { color:#0284c7; }

/* 側邊欄 active：左側品牌細條 + 淡底 + 亮圖示 */
#sidebar .nav-link.active {
  background: rgba(56,189,248,.14); color:#fff;
  box-shadow: inset 3px 0 0 var(--sidebar-active);
}
#sidebar .nav-link.active i { color: var(--sidebar-active); }
#sidebar .nav-section { color:#64748b; }

/* 表格 hover 改品牌淡色、卡片陰影微調 */
.table-hover > tbody > tr:hover > * { background-color: var(--brand-soft); }
.card { box-shadow: 0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04); }
