/* ============================================================
   style.css — HomeBase
   Mobile-first, responsive home improvement tracker UI
   ============================================================ */

/* ── Custom Properties ─────────────────────────────────────── */
:root {
  --primary:       #2563eb;
  --primary-dark:  #1d4ed8;
  --primary-light: #dbeafe;

  --bg:            #f1f5f9;
  --surface:       #ffffff;
  --surface-2:     #f8fafc;

  --text:          #0f172a;
  --text-2:        #475569;
  --text-3:        #94a3b8;

  --border:        #e2e8f0;
  --border-focus:  #93c5fd;

  --radius-sm:     6px;
  --radius:        10px;
  --radius-lg:     14px;

  --shadow-sm:     0 1px 2px rgba(0,0,0,0.06);
  --shadow:        0 1px 4px rgba(0,0,0,0.09), 0 0 0 1px rgba(0,0,0,0.04);
  --shadow-md:     0 4px 16px rgba(0,0,0,0.12);

  --header-h:      56px;
  --nav-h:         60px;
  --sidebar-w:     220px;

  /* Status colours */
  --open-bg:       #fee2e2; --open-fg:       #b91c1c;
  --prog-bg:       #dbeafe; --prog-fg:       #1d4ed8;
  --done-bg:       #d1fae5; --done-fg:       #065f46;

  /* Project status */
  --plan-bg:       #f3f4f6; --plan-fg:       #374151;
  --active-bg:     #dbeafe; --active-fg:     #1d4ed8;
  --comp-bg:       #d1fae5; --comp-fg:       #065f46;

  /* Issue type colours */
  --fix-bg:        #fee2e2; --fix-fg:        #b91c1c;
  --clean-bg:      #cffafe; --clean-fg:      #0e7490;
  --replace-bg:    #ede9fe; --replace-fg:    #6d28d9;
  --build-bg:      #fef3c7; --build-fg:      #b45309;
  --improve-bg:    #d1fae5; --improve-fg:    #065f46;
  --other-bg:      #f1f5f9; --other-fg:      #475569;
}

/* ── Dark Theme ─────────────────────────────────────────────── */
html[data-theme="dark"] {
  --bg:            #080f1f;
  --surface:       #0f1d36;
  --surface-2:     #080f1f;

  --text:          #f1f5f9;
  --text-2:        #8fa8c8;
  --text-3:        #4a6080;

  --border:        #1a2d4a;
  --border-focus:  #f97316;

  --primary:       #f97316;
  --primary-dark:  #ea6c0a;
  --primary-light: #431407;

  --shadow-sm:     0 1px 3px rgba(0,0,0,0.5);
  --shadow:        0 2px 6px rgba(0,0,0,0.5), 0 0 0 1px rgba(0,0,0,0.3);
  --shadow-md:     0 4px 20px rgba(0,0,0,0.6);

  /* Status */
  --open-bg:       #3b0d0d; --open-fg:       #fca5a5;
  --prog-bg:       #0c2045; --prog-fg:       #93c5fd;
  --done-bg:       #052e16; --done-fg:       #6ee7b7;

  /* Project status */
  --plan-bg:       #111d36; --plan-fg:       #94a3b8;
  --active-bg:     #0c2045; --active-fg:     #93c5fd;
  --comp-bg:       #052e16; --comp-fg:       #6ee7b7;

  /* Issue type */
  --fix-bg:        #3b0d0d; --fix-fg:        #fca5a5;
  --clean-bg:      #062030; --clean-fg:      #67e8f9;
  --replace-bg:    #1e0a45; --replace-fg:    #c4b5fd;
  --build-bg:      #2d1000; --build-fg:      #fcd34d;
  --improve-bg:    #052e16; --improve-fg:    #6ee7b7;
  --other-bg:      #111d36; --other-fg:      #8fa8c8;
}

/* Auth screen gradient */
html[data-theme="dark"] #auth-screen {
  background: linear-gradient(160deg, #080f1f 0%, #0f1d36 60%);
}

/* In-progress status toggle stays blue (consistent with its badge colour) */
html[data-theme="dark"] .status-toggle.s-inprogress { color: #93c5fd; background: #0c2045; }
html[data-theme="dark"] .status-toggle.s-open:hover { color: #f97316; background: #431407; }

/* Priority badges */
html[data-theme="dark"] .badge.p-low      { background: #052e16; color: #86efac; }
html[data-theme="dark"] .badge.p-medium   { background: #2d1000; color: #fcd34d; }
html[data-theme="dark"] .badge.p-high     { background: #2d1000; color: #fdba74; }
html[data-theme="dark"] .badge.p-critical { background: #3b0d0d; color: #fca5a5; }

/* Score chip dark */
html[data-theme="dark"] .issue-score-chip.score-high { background: #052e16; color: #86efac; border-color: #166534; }
html[data-theme="dark"] .issue-score-chip.score-mid  { background: #2d1000; color: #fcd34d; border-color: #92400e; }
html[data-theme="dark"] .issue-score-chip.score-low  { background: #0f1d36; color: var(--text-3); border-color: var(--border); }

/* Error message */
html[data-theme="dark"] .error-msg { background: #3b0d0d; color: #fca5a5; }

/* Button primary shadow */
html[data-theme="dark"] .btn-primary { box-shadow: 0 1px 3px rgba(249,115,22,0.3); }

/* Theme toggle icons */
.icon-sun  { display: none; }
.icon-moon { display: block; }
html[data-theme="dark"] .icon-sun  { display: block; }
html[data-theme="dark"] .icon-moon { display: none; }

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; font-size: 1rem; }
a { color: inherit; text-decoration: none; }
h1,h2,h3,h4 { font-weight: 600; line-height: 1.25; }

/* ── Utility ───────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Loading Overlay ───────────────────────────────────────── */
#loading-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Screens ───────────────────────────────────────────────── */
.screen { min-height: 100dvh; }

/* ── Auth ──────────────────────────────────────────────────── */
#auth-screen {
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
  background: linear-gradient(160deg, #eff6ff 0%, #f8fafc 60%);
}
.auth-wrap { width: 100%; max-width: 400px; }
.auth-header { text-align: center; margin-bottom: 28px; }
.auth-logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 68px; height: 68px; border-radius: 20px;
  background: var(--primary); color: white;
  margin-bottom: 14px;
}
.auth-logo svg { stroke: white; }
.auth-header h1 { font-family: 'Bungee Spice', sans-serif; font-weight: 400; font-size: 1.75rem; color: var(--primary); }
.auth-header p { color: var(--text-2); margin-top: 4px; }

.auth-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

/* Tab bar */
.tab-bar {
  display: flex;
  border-bottom: 1px solid var(--border);
}
.tab {
  flex: 1; padding: 14px;
  font-size: 0.9rem; font-weight: 500;
  color: var(--text-2);
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab:hover:not(.active) { color: var(--text); }

#auth-form { padding: 20px; }
.input-reveal { position: relative; }
.input-reveal input { padding-right: 40px; }
.reveal-btn {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); padding: 2px;
  transition: color 0.15s;
}
.reveal-btn:hover { color: var(--text-2); }

/* ── Forms ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-group label {
  display: block; font-size: 0.85rem; font-weight: 500;
  color: var(--text-2); margin-bottom: 5px;
}
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
  -webkit-appearance: none;
}
.form-group textarea { resize: vertical; min-height: 72px; }
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
.form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5'%3E%3Cpolyline points='6,9 12,15 18,9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}
.req { color: #dc2626; }
.opt { color: var(--text-3); font-weight: 400; }
.error-msg {
  font-size: 0.85rem; color: #dc2626;
  padding: 8px 12px;
  background: #fee2e2; border-radius: var(--radius-sm);
  margin-bottom: 12px;
}

/* Checkboxes */
.checkbox-group { display: flex; flex-direction: column; gap: 6px; }
.checkbox-label {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; font-size: 0.9rem;
  padding: 5px 0;
}
.checkbox-label input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  width: 18px; height: 18px; margin: 0; cursor: pointer; flex-shrink: 0;
  border: 2px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  transition: background 0.15s, border-color 0.15s;
  position: relative;
}
.checkbox-label input[type="checkbox"]:hover {
  border-color: var(--primary);
}
.checkbox-label input[type="checkbox"]:checked {
  background: var(--primary);
  border-color: var(--primary);
}
.checkbox-label input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 50%; top: 48%;
  width: 5px; height: 9px;
  border: 2px solid white;
  border-top: none; border-left: none;
  transform: translate(-50%, -50%) rotate(45deg);
}
.checkbox-label input[type="checkbox"]:focus {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent);
}

/* ── Modal multi-select dropdown ───────────────────────────── */
.modal-multiselect { position: relative; }
.modal-multiselect-btn {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-size: 0.9rem;
  cursor: pointer; text-align: left;
  transition: border-color 0.15s;
}
.modal-multiselect-btn:hover { border-color: var(--border-focus); }
.modal-multiselect-btn:focus { outline: none; border-color: var(--border-focus); }
.modal-multiselect-panel {
  position: absolute; z-index: 30; top: calc(100% + 3px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
  padding: 8px 10px; max-height: 180px; overflow-y: auto;
}
.modal-multiselect-panel .checkbox-group { gap: 8px; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem; font-weight: 500;
  transition: background 0.15s, opacity 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--primary); color: white;
  box-shadow: 0 1px 2px rgba(37,99,235,0.25);
}
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }

.btn-secondary {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg); }

.btn-danger {
  background: #dc2626; color: white;
}
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

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

.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  color: var(--text-2); transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }
.icon-btn.danger:hover { background: #fee2e2; color: #dc2626; }
.icon-btn.sm { width: 30px; height: 30px; }

/* ── Main App Layout ───────────────────────────────────────── */
#main-app {
  display: flex; flex-direction: column;
  min-height: 100dvh;
}

/* Header */
#app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px;
  box-shadow: var(--shadow-sm);
}
.app-brand {
  font-family: 'Bungee Spice', sans-serif;
  font-weight: 400;
  font-size: clamp(1.0rem, 2.5vw, 1.7rem);
  color: var(--primary);
}
#app-brand {
  flex-shrink: 0;
  padding-right: 12px;
  border-right: 1px solid var(--border);
  margin-right: 4px;
}
#page-title {
  flex: 1; font-size: 1.05rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Sidebar (desktop) */
#sidebar {
  display: none;
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  flex-direction: column;
  z-index: 40;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px; border-bottom: 1px solid var(--border);
}
.sidebar-logo svg { stroke: var(--primary); }
.sidebar-nav { flex: 1; padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav .nav-btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 10px; border-radius: var(--radius-sm);
  font-size: 0.9rem; font-weight: 500; color: var(--text-2);
  text-align: left;
  transition: background 0.15s, color 0.15s;
}
.sidebar-nav .nav-btn:hover { background: var(--bg); color: var(--text); }
.sidebar-nav .nav-btn.active { background: var(--primary-light); color: var(--primary); }
.sidebar-footer {
  padding: 12px 8px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.sidebar-github { color: var(--text-3); display: flex; align-items: center; padding: 4px; transition: color 0.15s; }
.sidebar-github:hover { color: var(--text); }

/* Main content area */
#main-content {
  flex: 1;
  margin-top: var(--header-h);
  margin-bottom: var(--nav-h);
  overflow-y: auto;
}

/* Bottom nav (mobile) */
#bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom, 0);
  box-shadow: 0 -1px 4px rgba(0,0,0,0.06);
  z-index: 50;
}
#bottom-nav .nav-btn {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  color: var(--text-3); font-size: 0.7rem; font-weight: 500;
  transition: color 0.15s;
  padding-bottom: 2px;
}
#bottom-nav .nav-btn.active { color: var(--primary); }
#bottom-nav .nav-btn svg { stroke: currentColor; }

/* Desktop override */
@media (min-width: 768px) {
  #sidebar { display: flex; }
  #app-header { left: var(--sidebar-w); }
  #main-content { margin-left: var(--sidebar-w); margin-bottom: 0; }
  #app-brand { display: none; }
  #bottom-nav { display: none; }
}

/* ── View Content ──────────────────────────────────────────── */
.view-content {
  padding: 16px;
  max-width: 760px;
  margin: 0 auto;
}

/* Section header */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.section-header h3 { font-size: 1rem; font-weight: 600; }
.count-pill {
  display: inline-block; font-size: 0.72rem; font-weight: 600;
  background: var(--primary-light); color: var(--primary);
  border-radius: 999px; padding: 1px 7px; margin-left: 6px;
  vertical-align: middle;
}
.dashboard-section-label {
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-3);
  margin: 0 0 8px;
}
.dash-tab-bar {
  margin: -16px -16px 0;
}
.dash-section-row {
  display: flex; align-items: center; justify-content: space-between;
  margin: 0 0 8px;
}
.dash-section-row .dashboard-section-label { margin-bottom: 0; }
.limit-selector { display: flex; gap: 2px; }
.limit-btn {
  padding: 2px 8px; font-size: 0.72rem; font-weight: 600;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: transparent; color: var(--text-2);
  cursor: pointer; transition: all 0.15s;
}
.limit-btn:hover { color: var(--text); border-color: var(--text-3); }
.limit-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Empty state */
.empty-state {
  text-align: center; padding: 40px 20px;
  color: var(--text-2);
}
.empty-state.empty-state-sm { padding: 16px 20px; }
.empty-state p { margin-bottom: 16px; }
.empty-icon { font-size: 2.5rem; margin-bottom: 12px; color: var(--text-3); }

/* ── Stats Bar ─────────────────────────────────────────────── */
.stats-bar {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  margin-bottom: 20px;
}
.stat-item {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 12px; text-align: center;
}
.stat-item.clickable { cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s; }
.stat-item.clickable:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); }
.stat-value { display: block; font-size: 1.6rem; font-weight: 700; line-height: 1; }
.stat-label { display: block; font-size: 0.72rem; color: var(--text-2); margin-top: 4px; }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 14px;
  box-shadow: var(--shadow-sm);
}

/* Project cards grid */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  margin-bottom: 8px;
}
.project-card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 14px 16px;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
  box-shadow: var(--shadow-sm);
}
.project-card:hover { box-shadow: var(--shadow); border-color: var(--primary); }
.project-card-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  margin-bottom: 6px;
}
.project-card-header h4 { font-size: 0.95rem; font-weight: 600; }
.project-card-desc { font-size: 0.83rem; color: var(--text-2); margin-bottom: 8px; }
.project-card-stats { font-size: 0.78rem; color: var(--text-3); display: flex; gap: 10px; }

/* ── List Items ─────────────────────────────────────────────── */
.list { display: flex; flex-direction: column; gap: 1px; }
.list-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.list-item:hover { box-shadow: var(--shadow-sm); }
.list-item.clickable { cursor: pointer; }
.list-item.clickable:hover { border-color: var(--primary); }
.list-item:has(.list-item-main.clickable):hover { border-color: var(--primary); box-shadow: var(--shadow-sm); }
.list-item-main { flex: 1; min-width: 0; }
.list-item-main.clickable { cursor: pointer; }
.list-item-title { font-size: 0.93rem; font-weight: 500; }
.list-item-subtitle { font-size: 0.82rem; color: var(--text-2); margin-top: 1px; }
.list-item-meta { font-size: 0.78rem; color: var(--text-3); margin-top: 3px; }
.list-item-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

/* ── Issue Cards ─────────────────────────────────────────────── */
.issue-list { display: flex; flex-direction: column; gap: 6px; }
.issue-card {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 12px 14px;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.issue-card:hover { box-shadow: var(--shadow-sm); }
.issue-card.sortable-ghost  { opacity: 0.35; }
.issue-card.sortable-chosen { box-shadow: var(--shadow-sm); }

.drag-handle {
  flex-shrink: 0; display: flex; align-items: center;
  cursor: grab; color: var(--text-muted); opacity: 0.35;
  padding: 2px 0; margin-top: 2px; touch-action: none;
}
.drag-handle:hover  { opacity: 0.65; }
.drag-handle:active { cursor: grabbing; }

/* Status toggle button */
.status-toggle {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid currentColor;
  display: flex; align-items: center; justify-content: center;
  margin-top: 2px;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}
.status-toggle.s-open { color: #9ca3af; }
.status-toggle.s-open:hover { color: var(--primary); background: var(--primary-light); }
.status-toggle.s-inprogress { color: var(--primary); background: var(--primary-light); }
.status-toggle.s-done { color: var(--done-fg); background: var(--done-bg); border-color: var(--done-fg); }

.issue-body { flex: 1; min-width: 0; cursor: pointer; }
.issue-name { font-size: 0.93rem; font-weight: 500; line-height: 1.3; }
.issue-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 5px;
  margin-top: 5px;
}
.issue-actions { flex-shrink: 0; display: flex; gap: 2px; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 7px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 600;
  white-space: nowrap; line-height: 1.5;
}

/* Status badges */
.badge.s-open      { background: var(--open-bg); color: var(--open-fg); }
.badge.s-inprogress { background: var(--prog-bg); color: var(--prog-fg); }
.badge.s-done      { background: var(--done-bg); color: var(--done-fg); }

/* Project status */
.badge.ps-planning { background: var(--plan-bg); color: var(--plan-fg); }
.badge.ps-active   { background: var(--active-bg); color: var(--active-fg); }
.badge.ps-complete { background: var(--comp-bg); color: var(--comp-fg); }

/* Issue type */
.badge.t-fix     { background: var(--fix-bg); color: var(--fix-fg); }
.badge.t-clean   { background: var(--clean-bg); color: var(--clean-fg); }
.badge.t-replace { background: var(--replace-bg); color: var(--replace-fg); }
.badge.t-build   { background: var(--build-bg); color: var(--build-fg); }
.badge.t-improve { background: var(--improve-bg); color: var(--improve-fg); }
.badge.t-other   { background: var(--other-bg); color: var(--other-fg); }

/* Priority */
.badge.p-low      { background: #f0fdf4; color: #15803d; }
.badge.p-medium   { background: #fffbeb; color: #b45309; }
.badge.p-high     { background: #fff7ed; color: #c2410c; }
.badge.p-critical { background: #fef2f2; color: #991b1b; }

/* Score chip — standalone tile, not a badge */
.issue-score-chip {
  flex-shrink: 0;
  width: 36px; height: 36px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.78rem; font-weight: 700;
  font-variant-numeric: tabular-nums;
  border: 1.5px solid transparent;
}
.issue-score-chip.score-high { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.issue-score-chip.score-mid  { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.issue-score-chip.score-low  { background: #f8fafc; color: var(--text-3); border-color: var(--border); }

/* ── Filter Dropdowns ───────────────────────────────────────── */
.filter-row {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 16px; flex-wrap: wrap;
}
.filter-dropdown { position: relative; }
.filter-dropdown-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface); color: var(--text-1);
  font-size: 0.82rem; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.filter-dropdown-btn:hover { border-color: var(--primary); }
.filter-dropdown-btn.has-filter {
  border-color: var(--primary); color: var(--primary);
  background: var(--primary-light);
}
.filter-dropdown-panel {
  display: none; position: absolute; top: calc(100% + 4px); left: 0; z-index: 200;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
  min-width: 155px; padding: 4px;
}
.filter-dropdown-panel.open { display: block; }
.filter-check-label {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 4px;
  font-size: 0.85rem; color: var(--text-1);
  cursor: pointer; white-space: nowrap; user-select: none;
}
.filter-check-label:hover { background: var(--bg); }
.filter-check-label input[type="checkbox"] { margin: 0; flex-shrink: 0; }
.filter-panel-footer {
  border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px;
}
.filter-clear-btn {
  width: 100%; text-align: left; padding: 5px 8px; border-radius: 4px;
  font-size: 0.8rem; color: var(--text-2); cursor: pointer;
  background: none; border: none;
}
.filter-clear-btn:hover { color: var(--primary); background: var(--bg); }
.filter-clear-all {
  padding: 6px 8px; border-radius: var(--radius-sm);
  font-size: 0.82rem; font-weight: 500; cursor: pointer;
  background: none; border: 1px solid transparent; color: var(--text-2);
}
.filter-clear-all:hover { color: var(--primary); }

/* ── Project Detail ─────────────────────────────────────────── */
.project-detail-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  margin-bottom: 20px;
}
.project-detail-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  margin-bottom: 8px;
}
.project-detail-header h3 { font-size: 1.1rem; font-weight: 600; }
.project-detail-desc { font-size: 0.88rem; color: var(--text-2); margin-top: 6px; }
.project-detail-actions { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }

/* ── Modal ──────────────────────────────────────────────────── */
#modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 23, 42, 0.45);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0;
  animation: fadeIn 0.15s ease;
}
@media (min-width: 480px) {
  #modal-overlay { align-items: center; padding: 20px; }
}
#modal-box {
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%; max-width: 500px;
  max-height: 90dvh;
  display: flex; flex-direction: column;
  animation: slideUp 0.2s ease;
  overflow: hidden;
}
@media (min-width: 480px) {
  #modal-box { border-radius: var(--radius-lg); }
}
#modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#modal-title { font-size: 1rem; font-weight: 600; }
#modal-body {
  padding: 16px; overflow-y: auto;
  flex: 1;
}
#modal-footer {
  padding: 12px 16px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
  flex-shrink: 0;
}
#modal-footer:empty { display: none; }

/* House Setup Overlay */
#house-setup-overlay {
  position: fixed; inset: 0; z-index: 150;
  background: rgba(15, 23, 42, 0.6);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.setup-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  width: 100%; max-width: 440px;
  box-shadow: var(--shadow-md);
  text-align: center;
}
.setup-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 64px; height: 64px; border-radius: 18px;
  background: var(--primary); color: white; margin-bottom: 16px;
}
.setup-icon svg { stroke: white; }
.setup-box h2 { font-size: 1.3rem; margin-bottom: 8px; }
.setup-box p { color: var(--text-2); font-size: 0.9rem; margin-bottom: 20px; }
.setup-box form { text-align: left; }

/* ── Confirm Dialog ─────────────────────────────────────────── */
.confirm-msg { font-size: 0.93rem; color: var(--text-2); margin-bottom: 4px; }
.confirm-name { font-weight: 600; color: var(--text); }

/* ── Animations ─────────────────────────────────────────────── */
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── Scrollbar ──────────────────────────────────────────────── */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* ── Supplies Section ───────────────────────────────────────── */
.supplies-section { margin-top: 4px; }

.supplies-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.supplies-title {
  font-size: 0.85rem; font-weight: 600; color: var(--text-2);
  display: flex; align-items: center; gap: 8px;
}
.supplies-cost-total {
  font-size: 0.78rem; font-weight: 700; color: var(--primary);
  background: var(--primary-light);
  border-radius: 999px; padding: 1px 8px;
}

/* Supply rows */
.supply-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 2px; border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}
.supply-row:last-child { border-bottom: none; }

.supply-thumb { flex-shrink: 0; width: 36px; height: 36px; }
.supply-img {
  width: 36px; height: 36px; object-fit: cover;
  border-radius: var(--radius-sm); border: 1px solid var(--border); display: block;
}
.supply-img-placeholder {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  border: 1px dashed var(--border); background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3);
}

.supply-info { flex: 1; min-width: 0; overflow: hidden; }
.supply-name {
  display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text); font-weight: 500; text-decoration: none;
}
a.supply-name { text-decoration: underline; text-underline-offset: 2px; }
a.supply-name:hover { color: var(--primary); }

.supply-qty   { flex-shrink: 0; color: var(--text-3); min-width: 24px; text-align: right; }
.supply-price { flex-shrink: 0; color: var(--text-2); min-width: 54px; text-align: right;
                font-variant-numeric: tabular-nums; }
.supply-total { flex-shrink: 0; color: var(--text); font-weight: 600; min-width: 58px;
                text-align: right; font-variant-numeric: tabular-nums; }

.supply-empty-msg { font-size: 0.82rem; color: var(--text-3); padding: 6px 0; margin: 0; }

/* Supply status pill (Needed / Purchased toggle) */
.supply-status-pill {
  flex-shrink: 0;
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.02em;
  padding: 2px 7px; border-radius: 999px; border: 1px solid transparent;
  cursor: pointer; white-space: nowrap; transition: opacity 0.1s;
}
.supply-status-pill:hover { opacity: 0.75; }
.supply-status-pill.needed {
  background: #fef3c7; color: #92400e; border-color: #fcd34d;
}
.supply-status-pill.purchased {
  background: #d1fae5; color: #065f46; border-color: #6ee7b7;
}
[data-theme="dark"] .supply-status-pill.needed {
  background: #451a03; color: #fcd34d; border-color: #92400e;
}
[data-theme="dark"] .supply-status-pill.purchased {
  background: #022c22; color: #6ee7b7; border-color: #065f46;
}

/* Purchased row dimmed */
.supply-row.purchased .supply-name,
.supply-row.purchased .supply-qty,
.supply-row.purchased .supply-price,
.supply-row.purchased .supply-total { opacity: 0.45; }

/* Supplies header cost breakdown */
.supply-outstanding { color: #b45309; font-weight: 600; font-variant-numeric: tabular-nums; }
.supply-total-cost  { color: var(--text-3); font-variant-numeric: tabular-nums; }
.supply-cost-sep    { color: var(--text-3); }
[data-theme="dark"] .supply-outstanding { color: #fcd34d; }

/* Outstanding supplies badge on issue cards */
.project-badge-row { display: flex; align-items: center; gap: 6px; margin: 3px 0 1px; }
.project-badge-label { font-size: 0.72rem; color: var(--text-3); font-weight: 500; flex-shrink: 0; }
.project-badge {
  display: inline-flex; align-items: center;
  font-size: 0.72rem; font-weight: 500;
  padding: 2px 8px; border-radius: 4px;
  border: 1px solid;
  cursor: pointer; transition: opacity 0.15s;
  max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: hsl(var(--pb-hue), 50%, 96%);
  color: hsl(var(--pb-hue), 55%, 28%);
  border-color: hsl(var(--pb-hue), 45%, 72%);
}
[data-theme="dark"] .project-badge {
  background: hsl(var(--pb-hue), 25%, 16%);
  color: hsl(var(--pb-hue), 55%, 62%);
  border-color: hsl(var(--pb-hue), 30%, 28%);
}
.project-badge:hover { opacity: 0.75; }
.supply-badge-needed {
  display: inline-flex; align-items: center;
  font-size: 0.72rem; font-weight: 600;
  padding: 1px 6px; border-radius: 999px;
  background: #fef3c7; color: #92400e; border: 1px solid #fcd34d;
  font-variant-numeric: tabular-nums;
}
[data-theme="dark"] .supply-badge-needed {
  background: #451a03; color: #fcd34d; border-color: #92400e;
}

/* Add supply inline form */
.supply-add-form {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px; margin-top: 8px;
}
.supply-url-wrap { position: relative; display: flex; align-items: center; }
.supply-url-wrap input { flex: 1; padding-right: 80px; }
.supply-fetch-indicator {
  position: absolute; right: 10px;
  font-size: 0.75rem; color: var(--text-3); pointer-events: none;
}
/* Image picker grid */
.supply-img-picker { margin-bottom: 10px; }
.supply-img-picker-label {
  font-size: 0.75rem; color: var(--text-3); margin: 0 0 6px;
}
.supply-img-picker-grid {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.supply-img-option {
  width: 60px; height: 60px; padding: 2px;
  border: 2px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); cursor: pointer; overflow: hidden;
  transition: border-color 0.15s;
}
.supply-img-option img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  border-radius: 3px;
}
.supply-img-option:hover   { border-color: var(--primary); }
.supply-img-option.selected { border-color: var(--primary); background: var(--primary-light); }

/* Upload button */
.supply-img-upload { margin-bottom: 10px; }
.supply-upload-btn {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.78rem; color: var(--text-3);
  cursor: pointer; padding: 4px 8px;
  border: 1px dashed var(--border); border-radius: var(--radius-sm);
  transition: color 0.15s, border-color 0.15s;
}
.supply-upload-btn:hover { color: var(--primary); border-color: var(--primary); }

.supply-img-preview-wrap {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
}
.supply-img-preview {
  width: 48px; height: 48px; object-fit: cover;
  border-radius: var(--radius-sm); border: 1px solid var(--border); display: block;
}
.supply-img-clear {
  font-size: 0.75rem; color: var(--text-3); background: none; border: none;
  cursor: pointer; padding: 2px 4px;
}
.supply-img-clear:hover { color: #dc2626; }
.supply-form-actions {
  display: flex; justify-content: flex-end; gap: 6px; margin-top: 4px;
}

/* Project cost row */
.project-cost-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0; border-top: 1px solid var(--border); margin-top: 8px;
}
.project-cost-label { font-size: 0.82rem; color: var(--text-2); }
.project-cost-value {
  font-size: 0.95rem; font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.project-cost-value.outstanding { color: #b45309; }
[data-theme="dark"] .project-cost-value.outstanding { color: #fcd34d; }

/* ── Misc ───────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 12px 0; }
.text-muted { color: var(--text-2); font-size: 0.85rem; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
