:root {
  --bg: #FBF7EE;
  --surface: #FFFFFF;
  --surface-2: #F3ECDA;
  --ink: #221D16;
  --ink-soft: #786D59;
  --ink-faint: #A79C86;
  --line: #E7DCC0;
  --line-soft: #EFE7D2;
  --gold: #A17F35;
  --gold-ink: #6E5B26;
  --gold-soft: #F1E4BE;
  --rose: #B4707A;
  --rose-soft: #F4E1E3;
  --sem-good: #3F7D5C;
  --sem-good-soft: #DEEBE2;
  --sem-warn: #B4740F;
  --sem-warn-soft: #F5E6CC;
  --sem-bad: #B14C56;
  --sem-bad-soft: #F5DEE0;
  --shadow: 0 1px 2px rgba(40, 32, 12, 0.06), 0 8px 24px -12px rgba(40, 32, 12, 0.18);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .display { font-family: 'Playfair Display', Georgia, serif; text-wrap: balance; letter-spacing: 0.01em; }
button { font-family: inherit; }
a { color: inherit; }
::selection { background: var(--gold-soft); }

.wrap { max-width: 1240px; margin: 0 auto; padding: 24px 20px 80px; }

/* ---------- Auth pages ---------- */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.auth-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow); padding: 34px 30px; width: min(380px, 100%);
  text-align: center;
}
.auth-logo { max-width: 220px; margin-bottom: 18px; }
.auth-card h1 { font-size: 22px; margin: 0 0 18px; }
.auth-sub { font-size: 12.5px; color: var(--ink-soft); margin: -10px 0 18px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.auth-error { background: var(--sem-bad-soft); color: var(--sem-bad); border-radius: 8px; padding: 8px 12px; font-size: 13px; margin-bottom: 14px; }
.auth-ok { background: var(--sem-good-soft); color: var(--sem-good); border-radius: 8px; padding: 8px 12px; font-size: 13px; margin-bottom: 14px; }

/* ---------- Header ---------- */
header.top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; padding-bottom: 18px; border-bottom: 1px solid var(--line); margin-bottom: 24px;
}
.brand-logo { height: 52px; max-width: 220px; object-fit: contain; }
.header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.user-menu { display: flex; align-items: center; gap: 8px; margin-left: 6px; padding-left: 10px; border-left: 1px solid var(--line); }
.user-name { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; gap: 7px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-size: 13px; font-weight: 600; padding: 8px 13px;
  cursor: pointer; transition: border-color .15s ease, background .15s ease, transform .05s ease;
  white-space: nowrap; text-decoration: none;
}
.btn:hover { border-color: var(--gold); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--gold); border-color: var(--gold); color: #241C0B; }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-soft); }
.btn-ghost:hover { border-color: var(--line); color: var(--ink); }
.btn-danger { color: var(--sem-bad); border-color: var(--sem-bad-soft); background: var(--sem-bad-soft); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: none; background: var(--surface); color: var(--ink-soft); font-size: 12.5px; font-weight: 600; padding: 8px 12px; cursor: pointer; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: none; }
.seg button.active { background: var(--surface-2); color: var(--ink); }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 26px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; box-shadow: var(--shadow); }
.stat .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-faint); font-weight: 600; margin: 0 0 10px; display: flex; justify-content: space-between; align-items: center; }
.stat .goal-edit { background: none; border: none; color: var(--ink-faint); cursor: pointer; font-size: 11px; text-decoration: underline; padding: 0; }
.stat-row { display: flex; align-items: baseline; gap: 6px; margin-bottom: 8px; }
.stat-row:last-child { margin-bottom: 0; }
.stat-num { font-family: 'Playfair Display', serif; font-size: 22px; font-weight: 700; }
.stat-of { font-size: 12px; color: var(--ink-faint); }
.stat-sub { font-size: 11.5px; color: var(--ink-soft); min-width: 62px; }
.bar { height: 5px; border-radius: 3px; background: var(--line-soft); overflow: hidden; flex: 1; }
.bar > span { display: block; height: 100%; background: var(--gold); border-radius: 3px; }
.stat-big { font-family: 'Playfair Display', serif; font-size: 26px; font-weight: 700; }
.stat-warn .stat-big { color: var(--sem-warn); }
.stat-money .stat-big { color: var(--sem-good); }

/* ---------- Board ---------- */
.board { display: grid; grid-template-columns: repeat(6, minmax(200px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; -webkit-overflow-scrolling: touch; }
.col { background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 12px; padding: 10px; min-height: 140px; display: flex; flex-direction: column; gap: 8px; }
.col.dragover { outline: 2px dashed var(--gold); outline-offset: -2px; }
.col-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 8px; }
.col-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.col-count { font-size: 11px; color: var(--ink-faint); background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 1px 8px; }
.col-empty { font-size: 12px; color: var(--ink-faint); text-align: center; padding: 18px 8px; border: 1px dashed var(--line); border-radius: 10px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; cursor: grab; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; }
.card:active { cursor: grabbing; }
.card.dragging { opacity: 0.45; }
.card-name { font-weight: 700; font-size: 13.5px; line-height: 1.3; }
.card-meta { font-size: 12px; color: var(--ink-soft); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 2px 7px; border-radius: 20px; }
.badge-quinceañera { background: var(--rose-soft); color: var(--rose); }
.badge-boda { background: var(--gold-soft); color: var(--gold-ink); }
.badge-bautizo { background: var(--sem-good-soft); color: var(--sem-good); }
.badge-retrato, .badge-otro { background: var(--line-soft); color: var(--ink-soft); }
.card-price { font-size: 12.5px; font-weight: 600; }
.dot-warn { width: 7px; height: 7px; border-radius: 50%; background: var(--sem-warn); flex: none; }
.card-follow { font-size: 11px; color: var(--sem-warn); display: flex; align-items: center; gap: 5px; }

/* ---------- List ---------- */
.list-toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.list-toolbar input, .list-toolbar select { font-family: inherit; font-size: 13px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
table.list { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
table.list th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-faint); font-weight: 700; padding: 10px 12px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
table.list td { padding: 10px 12px; font-size: 13px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.list tbody tr:last-child td { border-bottom: none; }
table.list tbody tr:hover { background: var(--surface-2); cursor: pointer; }
.list-wrap { overflow-x: auto; }
.etapa-pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; }
.empty-state { text-align: center; padding: 50px 20px; color: var(--ink-soft); border: 1px dashed var(--line); border-radius: 14px; background: var(--surface); }
.empty-state h3 { margin: 0 0 6px; }
.empty-state p { margin: 0 0 16px; font-size: 14px; }

/* ---------- Calendar ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.cal-head h2 { margin: 0; font-size: 19px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-faint); text-align: center; padding-bottom: 4px; }
.cal-day { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; min-height: 84px; padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.cal-day.out { background: var(--surface-2); opacity: 0.5; }
.cal-day.today { border-color: var(--gold); }
.cal-daynum { font-size: 11.5px; font-weight: 700; color: var(--ink-soft); }
.cal-event { font-size: 10.5px; padding: 2px 5px; border-radius: 5px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Reports ---------- */
.report-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.report-table th, .report-table td { padding: 10px 14px; font-size: 13px; border-bottom: 1px solid var(--line-soft); text-align: left; }
.report-table th { background: var(--surface-2); font-size: 11px; text-transform: uppercase; color: var(--ink-faint); }
.report-bar { height: 8px; border-radius: 4px; background: var(--gold); }

/* ---------- Drawer / Modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(20, 16, 8, 0.45); display: flex; justify-content: flex-end; z-index: 40; }
.drawer { width: min(460px, 100vw); background: var(--surface); height: 100%; box-shadow: -12px 0 40px rgba(0,0,0,0.2); overflow-y: auto; padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.drawer h2 { margin: 0 0 2px; font-size: 20px; }
.drawer-tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.drawer-tabs button { background: none; border: none; padding: 8px 10px; font-size: 12.5px; font-weight: 600; color: var(--ink-faint); cursor: pointer; border-bottom: 2px solid transparent; }
.drawer-tabs button.active { color: var(--ink); border-color: var(--gold); }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.field input, .field select, .field textarea { font-family: inherit; font-size: 13.5px; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); width: 100%; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: var(--gold); }
.field textarea { resize: vertical; min-height: 64px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.checkbox-row input { width: auto; }
.readout { background: var(--surface-2); border-radius: 8px; padding: 9px 10px; font-size: 13.5px; font-weight: 700; display: flex; justify-content: space-between; }
.drawer-actions { display: flex; gap: 8px; margin-top: 8px; }
.drawer-actions .btn { flex: 1; justify-content: center; }
.fieldset-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--gold-ink); margin: 10px 0 -4px; }
.modal-small { position: fixed; inset: 0; background: rgba(20,16,8,0.45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal-small .box { background: var(--surface); border-radius: 14px; padding: 22px; width: min(420px, 100%); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; max-height: 90vh; overflow-y: auto; }
.banner { background: var(--sem-warn-soft); color: var(--sem-warn); border: 1px solid var(--sem-warn); border-radius: 10px; padding: 10px 14px; font-size: 13px; margin-bottom: 18px; }
.banner-ok { background: var(--sem-good-soft); color: var(--sem-good); border-color: var(--sem-good); }

.checklist-item { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
.checklist-item.done { color: var(--ink-faint); text-decoration: line-through; }
.bitacora-entry { border-left: 2px solid var(--gold-soft); padding: 4px 0 4px 10px; margin-bottom: 8px; font-size: 12.5px; }
.bitacora-date { color: var(--ink-faint); font-size: 11px; }

@media (max-width: 980px) {
  .board { grid-template-columns: repeat(3, minmax(220px,1fr)); }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .cal-day { min-height: 64px; }
}
@media (max-width: 640px) {
  .board { grid-template-columns: repeat(2, minmax(180px,1fr)); }
  .stats { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  header.top { flex-direction: column; align-items: flex-start; }
  .header-actions { width: 100%; }
  .seg { width: 100%; }
  .seg button { flex: 1; }
  .drawer { width: 100vw; }
  .cal-grid { gap: 3px; }
  .cal-day { min-height: 54px; padding: 4px; }
  .cal-event { font-size: 9px; }
}
