/* ═══════════════════════════════════════════════════════════
   HomeBase — styles.css
   ═══════════════════════════════════════════════════════════ */

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

:root {
  --bg:           #F5F2EC;
  --bg2:          #EDE9E0;
  --nav:          #1E2528;
  --nav2:         #2C3336;
  --surface:      #FFFFFF;
  --border:       #DDD9CF;
  --text:         #1E2528;
  --text2:        #5A6068;
  --text3:        #8A9099;
  --amber:        #C8860A;
  --amber-light:  #FDF3DC;
  --amber-mid:    #F0C060;
  --green:        #2E7D5E;
  --green-light:  #E8F5EE;
  --red:          #C0392B;
  --red-light:    #FDECEA;
  --blue:         #2260A8;
  --blue-light:   #EAF1FB;
  --slate:        #4A5568;
  --radius:       8px;
  --shadow:       0 1px 3px rgba(0,0,0,0.08), 0 4px 16px rgba(0,0,0,0.05);
  --shadow-lg:    0 4px 24px rgba(0,0,0,0.12);
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ── LOGIN ─────────────────────────────────────────────── */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--nav);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(200,134,10,0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(34,96,168,0.06) 0%, transparent 50%);
}

.login-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 44px 48px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  text-align: center;
}

.login-logo {
  font-family: 'DM Serif Display', serif;
  font-size: 42px;
  color: var(--text);
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}
.login-logo span { color: var(--amber); }

.login-subtitle {
  color: var(--text3);
  font-size: 14px;
  font-weight: 400;
  margin-bottom: 24px;
}

.login-divider {
  height: 1px;
  background: var(--border);
  margin: 0 0 24px;
}

.login-prompt {
  font-size: 13.5px;
  color: var(--text2);
  margin-bottom: 24px;
  line-height: 1.6;
}

.login-error {
  margin-top: 16px;
  padding: 10px 14px;
  background: var(--red-light);
  color: var(--red);
  border-radius: 6px;
  font-size: 13px;
}

/* ── NAV ───────────────────────────────────────────────── */
.nav {
  background: var(--nav);
  display: flex;
  align-items: center;
  padding: 0 20px;
  height: 54px;
  gap: 6px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.nav-logo {
  font-family: 'DM Serif Display', serif;
  font-size: 22px;
  color: #F5F2EC;
  letter-spacing: -0.3px;
  margin-right: 10px;
  flex-shrink: 0;
  white-space: nowrap;
}
.nav-logo span { color: var(--amber-mid); }

.nav-tabs { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.nav-tabs::-webkit-scrollbar { display: none; }

.nav-tab {
  background: none;
  border: none;
  color: #8A9099;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
  white-space: nowrap;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.nav-tab:hover { background: var(--nav2); color: #CCC; }
.nav-tab.active { background: var(--nav2); color: #F5F2EC; }
.nav-tab.active::after {
  content: '';
  display: block;
  height: 2px;
  width: 100%;
  background: var(--amber-mid);
  border-radius: 2px;
  margin-top: 3px;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}

.ask-ai-btn {
  background: none;
  border: 1px solid #3A4348;
  color: #8A9099;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 500;
  transition: all 0.15s;
  font-family: 'DM Sans', sans-serif;
  white-space: nowrap;
}
.ask-ai-btn:hover { border-color: var(--amber-mid); color: var(--amber-mid); }

.nav-user {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--nav2);
  border-radius: 20px;
  padding: 4px 10px 4px 4px;
}

.nav-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--amber);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}
.nav-avatar img { width: 100%; height: 100%; object-fit: cover; }

.nav-user-name { color: #CCC; font-size: 13px; font-weight: 500; white-space: nowrap; }

.signout-btn {
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.15s;
  line-height: 1;
}
.signout-btn:hover { color: var(--amber-mid); }

/* ── LAYOUT ────────────────────────────────────────────── */
.main-content { max-width: 1200px; margin: 0 auto; padding: 24px 20px; }

.page { display: none; animation: fadeIn 0.2s ease; }
.page.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}
.page-title {
  font-family: 'DM Serif Display', serif;
  font-size: 26px;
  color: var(--text);
}
.page-subtitle { color: var(--text2); font-size: 13px; margin-top: 2px; }

/* ── CARDS ─────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card-header {
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title { font-weight: 600; font-size: 13.5px; }
.card-body { padding: 16px 18px; }

/* ── GRID ──────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }

/* ── STAT WIDGETS ──────────────────────────────────────── */
.stat-widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat-widget.stat-accent { border-top: 3px solid var(--amber); }
.stat-widget.stat-red    { border-top: 3px solid var(--red); }
.stat-widget.stat-green  { border-top: 3px solid var(--green); }
.stat-widget.stat-blue   { border-top: 3px solid var(--blue); }
.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text3); }
.stat-value { font-family: 'DM Serif Display', serif; font-size: 32px; color: var(--text); margin: 4px 0; line-height: 1; }
.stat-sub   { font-size: 12.5px; color: var(--text2); }

/* ── RECOMMENDATION STRIP ──────────────────────────────── */
.rec-strip {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 20px;
}
.rec-strip::-webkit-scrollbar { height: 4px; }
.rec-strip::-webkit-scrollbar-track { background: var(--bg2); border-radius: 2px; }
.rec-strip::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.rec-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  min-width: 210px;
  max-width: 240px;
  flex-shrink: 0;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  overflow: hidden;
}
.rec-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.rec-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.rec-card.urgent::before   { background: var(--red); }
.rec-card.soon::before     { background: var(--amber); }
.rec-card.quick::before    { background: var(--green); }
.rec-card.priority::before { background: var(--blue); }
.rec-section { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text3); margin-bottom: 6px; }
.rec-task    { font-weight: 600; font-size: 13.5px; color: var(--text); margin-bottom: 6px; line-height: 1.3; }
.rec-meta    { font-size: 12px; color: var(--text2); display: flex; flex-wrap: wrap; gap: 8px; }

/* ── BUTTONS ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 6px;
  border: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--text); color: white; }
.btn-primary:hover:not(:disabled) { background: #2E3638; }
.btn-amber   { background: var(--amber); color: white; }
.btn-amber:hover:not(:disabled) { background: #A87009; }
.btn-ghost   { background: transparent; border: 1px solid var(--border); color: var(--text2); }
.btn-ghost:hover:not(:disabled) { border-color: #AAA; color: var(--text); background: var(--bg2); }
.btn-sm      { padding: 4px 10px; font-size: 12.5px; }

/* ── BADGES ────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-critical    { background: var(--red-light);  color: var(--red); }
.badge-high        { background: #FEF0E7;            color: #B85C1A; }
.badge-medium      { background: var(--amber-light); color: var(--amber); }
.badge-low         { background: #EEF2F7;            color: var(--slate); }
.badge-someday     { background: var(--bg2);         color: var(--text3); }
.badge-done        { background: var(--green-light); color: var(--green); }
.badge-in-progress { background: var(--blue-light);  color: var(--blue); }
.badge-not-started { background: var(--bg2);         color: var(--text2); }
.badge-blocked     { background: var(--red-light);   color: var(--red); }

/* ── TASK TOOLBAR ──────────────────────────────────────── */
.task-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.search-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13.5px;
  color: var(--text);
  outline: none;
  width: 200px;
  transition: border-color 0.15s;
}
.search-input:focus { border-color: #AAA; background: white; }
.filter-select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  color: var(--text2);
  outline: none;
  cursor: pointer;
}

/* ── TABLES ────────────────────────────────────────────── */
.task-table, .ledger-table {
  width: 100%;
  border-collapse: collapse;
}
.task-table th, .ledger-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text3);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
.task-table th:hover, .ledger-table th:hover { color: var(--text2); }
.task-table td, .ledger-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--bg2);
  font-size: 13.5px;
  vertical-align: middle;
}
.task-table tr:last-child td,
.ledger-table tr:last-child td { border-bottom: none; }
.task-table tr:hover td,
.ledger-table tr:hover td { background: var(--bg); }

.task-name  { font-weight: 500; color: var(--text); }
.task-area  { color: var(--text2); font-size: 12.5px; }
.sort-arrow { margin-left: 4px; opacity: 0.4; font-size: 11px; }
.table-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text3);
  font-size: 12.5px;
}
.table-loading {
  text-align: center;
  padding: 32px;
  color: var(--text3);
  font-size: 13.5px;
}

.task-assignee {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--bg2);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 12px;
  color: var(--text2);
}
.mini-avatar {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--slate);
  color: white;
  font-size: 9px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.due-date     { font-size: 12.5px; white-space: nowrap; }
.due-overdue  { color: var(--red);   font-weight: 600; }
.due-soon     { color: var(--amber); font-weight: 500; }
.due-ok       { color: var(--text2); }
.tag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11.5px;
  background: var(--bg2);
  color: var(--text2);
}
.cat-chip {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--bg2);
  color: var(--text2);
}
.amount-col {
  font-weight: 600;
  font-family: 'DM Serif Display', serif;
  font-size: 16px;
}

/* ── LEDGER SUMMARY ────────────────────────────────────── */
.ledger-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  padding: 18px;
}
.person-total {
  text-align: center;
  padding: 14px 20px;
  flex: 1;
  min-width: 100px;
}
.person-name   { font-size: 12.5px; color: var(--text2); font-weight: 500; margin-bottom: 4px; }
.person-amount { font-family: 'DM Serif Display', serif; font-size: 26px; color: var(--text); }

/* ── MODALS ────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: white;
  border-radius: 10px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to   { opacity: 1; transform: none; }
}
.modal-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: white;
  z-index: 1;
}
.modal-title { font-family: 'DM Serif Display', serif; font-size: 20px; }
.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text3);
  padding: 2px 8px;
  border-radius: 4px;
  transition: background 0.15s;
}
.modal-close:hover { background: var(--bg2); }
.modal-body   { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  position: sticky;
  bottom: 0;
  background: white;
}

.field-group { display: flex; flex-direction: column; gap: 5px; }
.field-group label { font-size: 12.5px; font-weight: 600; color: var(--text2); }
.field-input, .field-select, .field-textarea {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13.5px;
  color: var(--text);
  outline: none;
  background: var(--bg);
  transition: border-color 0.15s;
  width: 100%;
}
.field-input:focus, .field-select:focus, .field-textarea:focus {
  border-color: #888;
  background: white;
}
.field-textarea { resize: vertical; min-height: 80px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── SECTION LABEL ─────────────────────────────────────── */
.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text3);
  margin-bottom: 10px;
}

/* ── HOUSE MAP ─────────────────────────────────────────── */
.deferred-notice {
  background: var(--amber-light);
  border: 1px solid var(--amber-mid);
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

/* ── AMBITIONS ─────────────────────────────────────────── */
.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  overflow: hidden;
}
.post-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
}
.post-title {
  font-family: 'DM Serif Display', serif;
  font-size: 19px;
  color: var(--text);
  margin-top: 6px;
}
.post-body   { padding: 16px 20px; }
.post-text   { color: var(--text2); font-size: 13.5px; line-height: 1.7; margin-bottom: 12px; }
.post-reply-input {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.reply-bubble {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}
.reply-content {
  background: var(--bg);
  border-radius: 6px;
  padding: 10px 14px;
  flex: 1;
}
.reply-meta  { font-size: 12px; color: var(--text3); margin-bottom: 4px; }
.reply-text  { font-size: 13.5px; color: var(--text2); }

/* ── TOAST ─────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--text);
  color: white;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  transition: transform 0.3s ease;
  white-space: nowrap;
  pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--green); }
.toast.error   { background: var(--red); }

/* ── MISC ──────────────────────────────────────────────── */
.list-loading {
  padding: 20px;
  color: var(--text3);
  font-size: 13.5px;
  text-align: center;
}
.rec-loading {
  padding: 16px;
  color: var(--text3);
  font-size: 13px;
}
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ── RESPONSIVE ────────────────────────────────────────── */
@media (max-width: 900px) {
  .grid-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 680px) {
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .task-table th:nth-child(n+7),
  .task-table td:nth-child(n+7) { display: none; }
  .ask-ai-btn { display: none; }
  .nav-user-name { display: none; }
  .login-card { padding: 32px 24px; }
}
