:root {
  --cream: #F6F1E4;
  --cream-deep: #EFE7D3;
  --white: #FFFFFF;
  --emerald: #167d5a;
  --emerald-dark: #0d3d2c;
  --ink-deep: #101816;
  --gold: #c99a3d;
  --gold-light: #e8c77a;
  --ink: #17211e;
  --muted: #6b7772;
  --border: #e5dfcd;
  --danger: #b33a34;
  --danger-bg: #fae4e1;
  --warning-bg: #fff3df;
  --warning-ink: #9a5c00;
  --ok-bg: #dff1e8;
  --ok-ink: #106748;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(16,24,22,.08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font: 15px/1.5 "Georgia", "Iowan Old Style", ui-serif, serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
body.sans { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif; }
h1, h2, h3, h4 { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif; margin: 0 0 6px; color: var(--ink-deep); }
p { margin: 0 0 10px; }
a { color: var(--emerald); }
button, input, textarea, select { font: inherit; }
img { max-width: 100%; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 20px; }
.narrow { max-width: 720px; }

/* ---------- Top bar ---------- */
.topbar {
  background: var(--ink-deep);
  color: #eef4f0;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 700; letter-spacing: .01em; }
.topbar .brand .mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  color: var(--ink-deep); display: grid; place-items: center; font-weight: 800; font-size: 13px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
}
.topbar .brand small { display: block; color: #9caaa4; font-size: 10px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; }
.topbar .who { display: flex; align-items: center; gap: 12px; font-size: 13px; color: #cfd8d3; }
.topbar button.linklike {
  background: transparent; border: 1px solid #33413c; color: #eef4f0; border-radius: 8px;
  padding: 7px 12px; cursor: pointer; font-size: 12px;
}
.topbar button.linklike:hover { border-color: var(--gold); color: var(--gold-light); }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh; display: grid; place-items: center;
  background: radial-gradient(circle at 20% 10%, #16301f 0%, var(--ink-deep) 55%, #0a1210 100%);
  padding: 24px;
}
.login-card {
  background: var(--white); border-radius: 20px; width: min(420px, 100%);
  padding: 36px 30px; box-shadow: 0 30px 80px rgba(0,0,0,.35);
}
.login-card .mark { width: 52px; height: 52px; border-radius: 14px; margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--gold), var(--gold-light)); color: var(--ink-deep);
  display: grid; place-items: center; font-weight: 800; font-family: -apple-system, sans-serif; font-size: 18px; }
.login-card h1 { text-align: center; font-size: 20px; }
.login-card .sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.login-card .disclaimer { text-align: center; color: #9aa39d; font-size: 11px; margin-top: 18px; }

/* ---------- Forms ---------- */
label { display: block; font-size: 12px; font-weight: 700; color: var(--ink-deep); margin-bottom: 5px; font-family: -apple-system, sans-serif; }
.field { margin-bottom: 16px; }
.field .hint { font-size: 11px; color: var(--muted); margin-top: 4px; font-family: -apple-system, sans-serif; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=date], textarea, select {
  width: 100%; border: 1px solid var(--border); border-radius: 9px; background: var(--white);
  padding: 11px 12px; color: var(--ink); font-family: -apple-system, sans-serif; font-size: 14px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid #cfe6db; border-color: var(--emerald); }
.checkbox-row { display: flex; align-items: flex-start; gap: 9px; padding: 7px 0; font-family: -apple-system, sans-serif; font-size: 13px; }
.checkbox-row input { width: 17px; height: 17px; margin-top: 2px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.field-grid.three { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 640px) { .field-grid, .field-grid.three { grid-template-columns: 1fr; } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 10px; padding: 11px 18px; font-weight: 700; cursor: pointer;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif; font-size: 13px;
  text-decoration: none;
}
.btn-primary { background: var(--emerald); color: #fff; }
.btn-primary:hover { background: var(--emerald-dark); }
.btn-gold { background: var(--gold); color: var(--ink-deep); }
.btn-gold:hover { background: var(--gold-light); }
.btn-ghost { background: var(--cream-deep); color: var(--ink-deep); }
.btn-ghost:hover { background: #e6dcc0; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Layout shell (portal + admin) ---------- */
.shell { display: flex; min-height: 100vh; }
.side-nav {
  width: 232px; flex: 0 0 auto; background: var(--white); border-right: 1px solid var(--border);
  padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.side-nav .company { padding: 8px 10px 18px; font-family: -apple-system, sans-serif; }
.side-nav .company b { display: block; font-size: 14px; color: var(--ink-deep); }
.side-nav .company small { color: var(--muted); font-size: 11px; }
.side-nav nav { display: grid; gap: 3px; }
.side-nav nav button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: transparent; border: 0; padding: 10px 12px; border-radius: 9px; cursor: pointer;
  color: #3f4a45; font-family: -apple-system, sans-serif; font-size: 13px; font-weight: 600;
}
.side-nav nav button:hover { background: var(--cream); }
.side-nav nav button.active { background: var(--emerald); color: #fff; }
.side-nav nav button .badge-count {
  margin-left: auto; background: var(--danger); color: #fff; font-size: 10px; font-weight: 800;
  border-radius: 10px; padding: 1px 7px;
}
.main-area { flex: 1; min-width: 0; }
.page { padding: 28px 24px 60px; max-width: 980px; }
.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: 24px; }
.page-head p { color: var(--muted); font-family: -apple-system, sans-serif; font-size: 13px; }

.mobile-menu-btn { display: none; }
@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .side-nav { position: fixed; inset: 0 20% 0 0; z-index: 40; transform: translateX(-105%); transition: .2s; height: 100vh; width: 78%; max-width: 300px; }
  .side-nav.open { transform: translateX(0); box-shadow: 0 0 60px rgba(0,0,0,.3); }
  .main-area { width: 100%; }
  .page { padding: 18px 16px 50px; }
  .mobile-menu-btn { display: inline-flex; }
  .nav-scrim { display: none; position: fixed; inset: 0; background: rgba(10,18,15,.5); z-index: 39; }
  .nav-scrim.show { display: block; }
}

/* ---------- Cards / content ---------- */
.card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.card h2 { font-size: 17px; }
.card h3 { font-size: 14px; margin-top: 4px; }
.muted { color: var(--muted); font-family: -apple-system, sans-serif; font-size: 13px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }

.badge { display: inline-block; font-size: 10px; font-weight: 800; padding: 3px 9px; border-radius: 20px; font-family: -apple-system, sans-serif; letter-spacing: .02em; text-transform: uppercase; }
.badge-pending { background: var(--warning-bg); color: var(--warning-ink); }
.badge-progress { background: #e6effb; color: #1d5aa8; }
.badge-done { background: var(--ok-bg); color: var(--ok-ink); }
.badge-required { background: var(--danger-bg); color: var(--danger); }
.badge-optional { background: var(--cream-deep); color: var(--ink-deep); }
.badge-gold { background: #f6e9cc; color: #8a6414; }

.list-row, .stage-row, .doc-row { display: flex; align-items: flex-start; gap: 12px; padding: 13px 0; border-top: 1px solid #f0ece0; }
.list-row:first-child, .stage-row:first-child, .doc-row:first-child { border-top: 0; }
.grow { flex: 1 1 0%; min-width: 0; }
.list-row b { display: block; font-size: 13.5px; font-family: -apple-system, sans-serif; }
.list-row .detail { color: var(--muted); font-size: 12px; margin-top: 3px; font-family: -apple-system, sans-serif; }
.list-row select, .stage-row select, .doc-row select,
.list-row > .btn, .list-row > a.btn, .doc-row > .btn, .doc-row > a.btn { width: auto; flex: 0 0 auto; }
select.status-select { min-width: 150px; }
@media (max-width: 640px) { .list-row, .doc-row { flex-wrap: wrap; } select.status-select { min-width: 100%; } }

.progress-bar { height: 8px; border-radius: 999px; background: #ece5d2; overflow: hidden; }
.progress-bar i { display: block; height: 100%; background: var(--emerald); border-radius: inherit; }
.stage-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-top: 1px solid #f0ece0; }
.stage-row:first-child { border-top: 0; }
.stage-dot { width: 26px; height: 26px; border-radius: 50%; flex: 0 0 auto; display: grid; place-items: center; font-size: 12px; font-weight: 800; color: #fff; background: #cfc6a9; }
.stage-dot.complete { background: var(--emerald); }
.stage-dot.in_progress { background: var(--gold); color: var(--ink-deep); }
.stage-row .grow b { font-family: -apple-system, sans-serif; font-size: 14px; }
.stage-row .grow small { color: var(--muted); font-family: -apple-system, sans-serif; }

.upload-drop {
  border: 2px dashed var(--border); border-radius: 12px; padding: 26px; text-align: center;
  color: var(--muted); font-family: -apple-system, sans-serif; font-size: 13px; cursor: pointer; background: var(--cream);
}
.upload-drop.drag { border-color: var(--emerald); background: #eef7f2; }
.doc-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid #f0ece0; font-family: -apple-system, sans-serif; }
.doc-row:first-child { border-top: 0; }
.doc-row .file-icon { width: 34px; height: 34px; border-radius: 8px; background: var(--cream-deep); display: grid; place-items: center; flex: 0 0 auto; font-size: 11px; font-weight: 800; color: var(--emerald-dark); }
.doc-row .grow { flex: 1; min-width: 0; }
.doc-row b { display: block; font-size: 13px; overflow-wrap: anywhere; }
.doc-row small { color: var(--muted); font-size: 11px; }

.update-item { padding: 12px 0; border-top: 1px solid #f0ece0; font-family: -apple-system, sans-serif; }
.update-item:first-child { border-top: 0; }
.update-item .meta { font-size: 11px; color: var(--muted); margin-bottom: 4px; display: flex; gap: 8px; align-items: center; }
.update-item .meta b { color: var(--ink-deep); }
.update-item .meta.from-admin b { color: var(--emerald); }

.pay-hero { background: linear-gradient(135deg, var(--ink-deep), #16301f); color: #fff; border-radius: var(--radius); padding: 26px; }
.pay-hero .amount { font-size: 34px; font-weight: 800; font-family: -apple-system, sans-serif; }
.pay-hero .row { display: flex; justify-content: space-between; padding: 8px 0; border-top: 1px solid rgba(255,255,255,.14); font-family: -apple-system, sans-serif; font-size: 13px; }
.pay-hero .row:first-of-type { border-top: 0; }
.pay-hero .gold-text { color: var(--gold-light); }

table.simple { width: 100%; border-collapse: collapse; font-family: -apple-system, sans-serif; font-size: 13px; }
table.simple th { text-align: left; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; padding: 8px 10px; border-bottom: 1px solid var(--border); }
table.simple td { padding: 10px; border-bottom: 1px solid #f0ece0; vertical-align: top; }
table.simple tr:hover td { background: #fbf8f0; }

.empty-note { color: var(--muted); font-family: -apple-system, sans-serif; font-size: 13px; padding: 10px 0; }
.toast { position: fixed; right: 20px; bottom: 20px; background: var(--ink-deep); color: #fff; padding: 12px 18px; border-radius: 10px; z-index: 90; font-family: -apple-system, sans-serif; font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,.3); }
.toast.error { background: var(--danger); }
.error-text { color: var(--danger); font-size: 13px; font-family: -apple-system, sans-serif; margin-top: 8px; }

.overlay { position: fixed; inset: 0; background: rgba(10,18,15,.55); z-index: 60; display: grid; place-items: center; padding: 20px; }
.modal { background: #fff; border-radius: 16px; width: min(520px, 100%); max-height: 88vh; overflow: auto; padding: 26px; }
.modal h2 { margin-bottom: 4px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }

.client-tile { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 12px; border: 1px solid var(--border); background: #fff; cursor: pointer; margin-bottom: 10px; }
.client-tile:hover { border-color: var(--emerald); }
.client-tile .avatar { width: 40px; height: 40px; border-radius: 10px; background: var(--emerald); color: #fff; display: grid; place-items: center; font-weight: 800; font-family: -apple-system, sans-serif; }
.client-tile .grow b { display: block; font-family: -apple-system, sans-serif; font-size: 14px; }
.client-tile .grow small { color: var(--muted); font-family: -apple-system, sans-serif; }

.welcome-hero { background: linear-gradient(160deg, #16301f, var(--ink-deep)); color: #fff; border-radius: 18px; padding: 30px 26px; margin-bottom: 20px; }
.welcome-hero h1 { color: #fff; font-size: 24px; }
.welcome-hero p { color: #cfe0d7; font-family: -apple-system, sans-serif; }
.step-num { width: 26px; height: 26px; border-radius: 50%; background: var(--gold); color: var(--ink-deep); font-weight: 800; display: grid; place-items: center; font-size: 12px; flex: 0 0 auto; font-family: -apple-system, sans-serif; }
