:root {
  --bg: #e8e1d4;
  --paper: #f7f1e6;
  --ink: #1c1914;
  --muted: #6b645a;
  --line: rgba(28, 25, 20, 0.12);
  --clay: #b85c38;
  --clay-dark: #8f3f22;
  --moss: #2f3d32;
  --moss-2: #3d5244;
  --gold: #c9a227;
  --ok: #2f6b4f;
  --err: #8f2d2d;
  --purchase: #6b5344;
  --done: #b85c38;
  --plan: #c9a227;
  --shadow: 0 18px 40px rgba(47, 61, 50, 0.12);
  --radius: 18px;
  --side: 268px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Outfit, system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at -10% -20%, rgba(184, 92, 56, 0.12), transparent 50%),
    radial-gradient(900px 400px at 110% 0%, rgba(47, 61, 50, 0.14), transparent 45%),
    var(--bg);
}
h1, h2, h3, .brand strong {
  font-family: Fraunces, Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.02em;
}
a { color: var(--clay-dark); }
.muted { color: var(--muted); }
.small, .hint { font-size: 0.85rem; color: var(--muted); }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  color: var(--clay);
  margin: 0 0 0.4rem;
}

.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--side);
  background: var(--moss);
  color: #f3ece2;
  display: flex;
  flex-direction: column;
  padding: 1.4rem 1rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  color: inherit;
  text-decoration: none;
  padding: 0.3rem 0.5rem 1.2rem;
}
.brand-mark {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: grid; place-items: center;
  background: #f3ece2;
  color: var(--moss);
  font-size: 1.3rem;
}
.brand small { display: block; color: #c9c0b3; font-size: 0.78rem; }
.nav { display: flex; flex-direction: column; gap: 0.2rem; flex: 1; }
.nav-link {
  color: #e7dfd3;
  text-decoration: none;
  padding: 0.55rem 0.8rem;
  border-radius: 10px;
}
.nav-link:hover, .nav-link.is-active { background: var(--moss-2); color: #fff; }
.sidebar-foot {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
.who small { display: block; color: #c9c0b3; }
.main { flex: 1; min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 1.1rem 1.4rem 0.2rem;
}
.topbar h1 { margin: 0; font-size: 1.7rem; }
.menu-btn {
  display: none;
  border: 0;
  background: var(--paper);
  width: 42px; height: 42px;
  border-radius: 12px;
  font-size: 1.2rem;
}
.content { padding: 1rem 1.4rem 2.5rem; }
.nav-backdrop { display: none; }

.hero, .panel, .stat-card, .auth-card, .inv-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.hero {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.3rem 1.4rem;
  margin-bottom: 1rem;
  align-items: center;
}
.hero h2 { margin: 0 0 0.3rem; font-size: 2rem; }
.hero-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.8rem;
  margin-bottom: 1rem;
}
.stat-card { padding: 1rem 1.1rem; }
.stat-card span, .stat-card small { color: var(--muted); display: block; }
.stat-card strong { font-family: Fraunces, serif; font-size: 1.35rem; display: block; margin: 0.25rem 0; }
.stat-card.accent { background: var(--moss); color: #f7f1e6; }
.stat-card.accent span, .stat-card.accent small { color: #c9c0b3; }

.grid-2 { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 1rem; margin-bottom: 1rem; }
.panel { padding: 1.15rem 1.2rem; }
.panel h3 { margin: 0 0 0.7rem; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 0.8rem; margin-bottom: 0.8rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  padding: 0.62rem 1.05rem;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.btn-primary { background: var(--clay); color: #fff; }
.btn-primary:hover { background: var(--clay-dark); }
.btn-ghost { background: transparent; color: inherit; border: 1px solid var(--line); }
.sidebar .btn-ghost { border-color: rgba(255,255,255,0.2); color: #f3ece2; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.88rem; }

.alert { padding: 0.75rem 0.9rem; border-radius: 12px; margin-bottom: 1rem; }
.alert-ok { background: #dceadf; color: var(--ok); }
.alert-err { background: #f3d8d4; color: var(--err); }

label { display: flex; flex-direction: column; gap: 0.35rem; font-weight: 500; }
input, select, textarea {
  font: inherit;
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fffdf8;
  color: var(--ink);
  width: 100%;
}
.stack { display: grid; gap: 0.75rem; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
}
.span-2 { grid-column: span 2; }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.check { flex-direction: row; align-items: center; gap: 0.5rem; }
.check input { width: auto; }

.filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.8rem;
}
.filters select { width: auto; min-width: 160px; }
.filters input[type="search"] {
  width: auto;
  min-width: min(100%, 240px);
  flex: 1;
}

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.7rem 0.55rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.num { text-align: right; white-space: nowrap; }
.pill {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--c) 18%, white);
  color: var(--ink);
  font-size: 0.85rem;
}
.linkish {
  background: none;
  border: 0;
  color: var(--err);
  cursor: pointer;
  font: inherit;
  padding: 0;
}

.bars { display: grid; gap: 1rem; }
.bar-meta, .bar-legend, .legend { display: flex; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; }
.bar-meta span, .bar-legend, .legend { color: var(--muted); font-size: 0.82rem; }
.bar {
  height: 12px;
  background: rgba(28,25,20,0.08);
  border-radius: 99px;
  overflow: hidden;
  display: flex;
  margin: 0.35rem 0;
}
.bar i { display: block; height: 100%; }
.seg.purchase { background: var(--purchase); }
.seg.done { background: var(--done); }
.seg.plan { background: var(--plan); }
.dot {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 0.3rem;
}
.dot.purchase { background: var(--purchase); }
.dot.done { background: var(--done); }
.dot.plan { background: var(--plan); }

.cat-list, .simple-list { list-style: none; margin: 0; padding: 0; }
.cat-list li, .simple-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  align-items: center;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--line);
}
.cat-list small, .simple-list small { display: block; color: var(--muted); font-weight: 400; }
.swatch {
  width: 12px; height: 12px; border-radius: 4px; display: inline-block; margin-right: 0.45rem;
}
.row-actions { display: flex; gap: 0.7rem; align-items: center; }

.cards-invoices {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.9rem;
}
.inv-mini {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 10px;
  display: block;
  border: 1px solid var(--line);
}
.inv-link { display: inline-block; }
.inv-preview {
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--line);
  display: block;
  margin: 0.5rem 0;
}
.invoice-box { margin-bottom: 0.4rem; }
.invoice-box h3 { margin: 0 0 0.3rem; }
.inv-card { padding: 1rem; }
.inv-card h3 { margin: 0 0 0.3rem; }
.inv-card .amount { font-family: Fraunces, serif; font-size: 1.3rem; }

.drop {
  border: 1.5px dashed var(--line);
  border-radius: 16px;
  padding: 1.4rem;
  text-align: center;
  background: #fffdf8;
}
.share-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; }

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.2rem;
}
.auth-card { width: min(520px, 100%); padding: 1.6rem; }
.install-card { width: min(640px, 100%); }
.auth-card h1 { margin: 0 0 0.4rem; }
.lead { color: var(--muted); margin-top: 0; }

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
}

@media (max-width: 820px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    transform: translateX(-105%);
    z-index: 20;
    transition: transform 0.2s ease;
  }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-grid; place-items: center; }
  .nav-backdrop.show {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(28,25,20,0.4);
    z-index: 15;
  }
  .hero { flex-direction: column; align-items: flex-start; }
  .share-grid { grid-template-columns: 1fr; }
  .content, .topbar { padding-left: 1rem; padding-right: 1rem; }
}

.gallery-upload { margin-bottom: 1rem; }
.timeline { display: grid; gap: 1.4rem; }
.timeline-day h3 { margin: 0 0 0.7rem; font-size: 1.15rem; }
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
}
.gal-card { margin: 0; }
.gal-thumb {
  display: block;
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  background: #d9d0c3;
  aspect-ratio: 4 / 3;
}
.gal-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.gal-card figcaption {
  display: grid;
  gap: 0.15rem;
  padding: 0.45rem 0.1rem 0;
  font-size: 0.85rem;
}
.gal-card figcaption span { color: var(--muted); }
.gallery-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.55rem;
}
.gallery-strip .gal-thumb span {
  position: absolute;
  left: 0.45rem;
  bottom: 0.4rem;
  background: rgba(28, 25, 20, 0.72);
  color: #f7f1e6;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
}
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(18, 16, 12, 0.88);
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  cursor: zoom-out;
}
.lightbox[hidden] { display: none !important; }
.lightbox img {
  max-width: min(1100px, 96vw);
  max-height: 88vh;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.35);
  cursor: default;
}
.gal-thumb, .inv-link, [data-lightbox] { cursor: zoom-in; }
.lightbox img {
  max-width: min(1100px, 96vw);
  max-height: 88vh;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.35);
}
.lightbox-close {
  position: absolute;
  top: 0.8rem;
  right: 1rem;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 2.2rem;
  cursor: pointer;
}
@media (max-width: 1100px) {
  .gallery-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .gallery-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
