/* Renofy CRM — clean professional workspace */
@font-face {
  font-family: 'Optima';
  src: url('/static/fonts/AGOptimaCyr_Roman.ttf') format('truetype');
  font-weight: 400;
}
:root {
  --bg: #f4f7f6;
  --card: #ffffff;
  --ink: #172421;
  --ink-soft: #5b6b67;
  --teal: #16796f;
  --teal-dark: #0f5a53;
  --green-deep: #102722;
  --gold: #9a6d32;
  --line: #e3eae8;
  --danger: #b4433a;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
h1, h2, h3, .serif { font-family: 'Optima', Georgia, serif; font-weight: 400; letter-spacing: .01em; }
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- layout ---------- */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0; width: 232px;
  background: var(--green-deep); color: #dbe7e4;
  display: flex; flex-direction: column; z-index: 40;
}
.sidebar .brand { padding: 22px 20px 14px; }
.sidebar .brand .wordmark { font-family: 'Optima', Georgia, serif; font-size: 24px; letter-spacing: .28em; color: #fff; }
.sidebar .brand .tag { font-size: 10.5px; letter-spacing: .22em; color: #9fc4bd; margin-top: 4px; }
.sidebar nav { flex: 1; padding: 8px 10px; overflow-y: auto; }
.sidebar nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; margin: 2px 0; border-radius: 8px;
  color: #c8d9d5; font-size: 14px; font-weight: 500;
}
.sidebar nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.sidebar nav a.active { background: rgba(22,121,111,.35); color: #fff; }
.sidebar nav a svg { width: 19px; height: 19px; flex: 0 0 19px; opacity: .85; }
.sidebar .foot { padding: 14px 20px; font-size: 12px; color: #7fa09a; border-top: 1px solid rgba(255,255,255,.08); }
.main { margin-left: 232px; padding: 28px 32px 90px; max-width: 1180px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 30px; }
.page-head p.sub { margin: 4px 0 0; color: var(--ink-soft); }

/* ---------- cards / grids ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: 0 1px 2px rgba(16,39,34,.04); }
.card h3 { margin: 0 0 8px; font-size: 19px; }
.card .meta { color: var(--ink-soft); font-size: 13px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 900px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

/* ---------- metrics ---------- */
.metric .num { font-family: 'Optima', Georgia, serif; font-size: 30px; margin: 4px 0 0; }
.metric .lbl { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); }
.metric .delta { font-size: 13px; color: var(--teal); }

/* ---------- bars ---------- */
.bar-row { display: grid; grid-template-columns: 110px 1fr 90px; gap: 10px; align-items: center; margin: 8px 0; font-size: 13px; }
.bar-track { background: #e9efed; border-radius: 6px; height: 12px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--teal), #1fa393); border-radius: 6px; transition: width .4s; }
.bar-fill.gold { background: linear-gradient(90deg, var(--gold), #c1934f); }
.bar-row .val { text-align: right; color: var(--ink-soft); }

/* ---------- forms ---------- */
label.f { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin: 12px 0 5px; letter-spacing: .02em; }
input[type=text], input[type=email], input[type=tel], input[type=number],
input[type=date], input[type=time], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 14.5px; font-family: inherit; color: var(--ink); background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(22,121,111,.35); border-color: var(--teal); }
textarea { min-height: 90px; resize: vertical; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--teal); color: #fff; border: none; border-radius: 8px;
  padding: 10px 18px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--teal-dark); text-decoration: none; color: #fff; }
.btn.ghost { background: #fff; color: var(--teal); border: 1px solid var(--teal); }
.btn.ghost:hover { background: #eef6f4; color: var(--teal-dark); }
.btn.gold { background: var(--gold); }
.btn.gold:hover { background: #7f5927; }
.btn.danger { background: #fff; color: var(--danger); border: 1px solid #e4b7b2; }
.btn.danger:hover { background: #fbeeec; }
.btn.sm { padding: 7px 12px; font-size: 13px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 700px) { .form-row { grid-template-columns: 1fr; } }

/* ---------- tables ---------- */
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); padding: 10px 12px; border-bottom: 2px solid var(--line); }
table.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: none; }

/* ---------- badges / pills ---------- */
.pill { display: inline-block; padding: 4px 11px; border-radius: 999px; font-size: 12px; font-weight: 600; letter-spacing: .03em; }
.pill.new { background: #e8f1f0; color: #0f5a53; }
.pill.contacted { background: #e3ecfb; color: #2c4f9e; }
.pill.qualified { background: #f3e9d6; color: #8a5f1e; }
.pill.won, .pill.accepted, .pill.paid, .pill.complete, .pill.active { background: #dff0e8; color: #176b43; }
.pill.lost, .pill.declined, .pill.overdue { background: #f9e3e0; color: #a03a32; }
.pill.draft, .pill.planning, .pill.sent { background: #eef1f0; color: #5b6b67; }
.pill.on_hold { background: #f7ecd9; color: #8a5f1e; }

/* ---------- misc ---------- */
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.flash.ok { background: #e2f3ea; color: #14563a; border: 1px solid #bfe3d0; }
.flash.err { background: #fbe7e4; color: #8f352d; border: 1px solid #f0c3bd; }
.inline-form { display: inline; }
select.inline { width: auto; padding: 6px 8px; font-size: 13px; }
.progress { background: #e9efed; border-radius: 6px; height: 10px; overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--teal), #1fa393); }
.agenda li { list-style: none; }
.agenda { padding: 0; margin: 0; }
.agenda li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--line); }
.agenda li:last-child { border-bottom: none; }
.agenda .done .t { text-decoration: line-through; color: var(--ink-soft); }
.kind { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0; }
.divider { height: 1px; background: var(--line); margin: 18px 0; }
.muted { color: var(--ink-soft); }
.right { text-align: right; }
.center { text-align: center; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.copybox { display: flex; gap: 8px; }
.copybox input { flex: 1; }

/* line-item grid */
.linegrid .lrow { display: grid; grid-template-columns: 1fr 70px 80px 110px 46px; gap: 8px; margin-bottom: 8px; align-items: center; }
.linegrid .lhead { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); }
.totalbox { display: flex; justify-content: flex-end; align-items: baseline; gap: 14px; margin-top: 12px; }
.totalbox .t { font-family: 'Optima', Georgia, serif; font-size: 26px; }
@media (max-width: 700px) { .linegrid .lrow { grid-template-columns: 1fr 56px 70px 96px 40px; } }

/* module hub */
.modgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.modtile { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.modtile:hover { border-color: var(--teal); text-decoration: none; }
.modtile .cnt { font-family: 'Optima', Georgia, serif; font-size: 24px; }
.modtile h4 { margin: 6px 0 2px; font-size: 16px; color: var(--ink); }

/* signature pad */
#sigpad { border: 2px dashed var(--line); border-radius: 8px; background: #fff; touch-action: none; cursor: crosshair; width: 100%; height: 220px; }

/* email review */
.preview-frame { width: 100%; height: 560px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: radial-gradient(1200px 600px at 20% -10%, #dfeeea 0%, var(--bg) 60%); }
.login-card { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 36px 32px; box-shadow: 0 12px 40px rgba(16,39,34,.08); }
.login-card .wm { font-family: 'Optima', Georgia, serif; font-size: 30px; letter-spacing: .3em; }
.login-card .tg { font-size: 11px; letter-spacing: .24em; color: var(--ink-soft); margin: 4px 0 22px; }

/* sign page (public) */
.sign-wrap { max-width: 860px; margin: 0 auto; padding: 32px 20px 80px; }
.sign-doc { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 28px; }

/* mobile tab bar */
.tabbar { display: none; }
.mobile-topbar { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 18px 16px 110px; }
  .mobile-topbar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 2px 2px 14px;
  }
  .mobile-topbar .wordmark { letter-spacing: 3px; font-weight: 700; color: #0f2e2a; font-size: 15px; }
  .mobile-topbar a { font-size: 13.5px; color: var(--teal); font-weight: 600; }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: var(--green-deep); padding: 6px 2px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a {
    flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 3px;
    color: #b9d2cd; font-size: 10px; padding: 6px 4px; border-radius: 8px;
  }
  .tabbar a svg { width: 21px; height: 21px; }
  .tabbar a.active { color: #fff; background: rgba(22,121,111,.4); }
  .tabbar a:hover { text-decoration: none; }
  .page-head h1 { font-size: 24px; }
  .cards { grid-template-columns: 1fr; }
  table.tbl { display: block; overflow-x: auto; }
}
@media print { .sidebar, .tabbar, .no-print { display: none !important; } .main { margin: 0; } }

/* ---- project schedule / daily log (Phase 2) ---- */
.subnav{display:flex;gap:6px;flex-wrap:wrap}
.subnav a{padding:8px 14px;border:1px solid var(--line,#2a2d33);border-radius:999px;font-size:13.5px;color:inherit;text-decoration:none}
.subnav a:hover{border-color:var(--teal,#17bfae)}
.gantt{min-width:520px}
.gantt-scale{display:flex;justify-content:space-between;font-size:12px;color:var(--muted,#8a8f98);margin-bottom:6px;padding-left:38%}
.gantt-row{display:flex;align-items:center;gap:8px;margin-bottom:6px}
.gantt-label{width:38%;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.gantt-track{position:relative;flex:1;height:22px;background:rgba(255,255,255,.04);border-radius:6px}
.gantt-bar{position:absolute;top:3px;height:16px;border-radius:5px;min-width:8px}
.gantt-bar.st-todo{background:#8a8f98}
.gantt-bar.st-in_progress{background:var(--teal,#17bfae)}
.gantt-bar.st-done{background:#3fae5a}
.gantt-key{display:inline-block;width:12px;height:12px;border-radius:3px;margin:0 4px 0 12px;vertical-align:-1px}
.gantt-key.st-todo{background:#8a8f98}
.gantt-key.st-in_progress{background:var(--teal,#17bfae)}
.gantt-key.st-done{background:#3fae5a}
.task-row{display:flex;gap:10px;align-items:flex-start;padding:10px 0;border-top:1px solid var(--line,#2a2d33)}
.task-row:first-of-type{border-top:none}
.task-row.done .task-main .t{color:var(--muted,#8a8f98);text-decoration:line-through}
.task-main{flex:1;min-width:0}
.log-photos{display:flex;gap:8px;flex-wrap:wrap;margin-top:10px}
.log-photos img{width:110px;height:110px;object-fit:cover;border-radius:8px;border:1px solid var(--line,#2a2d33)}
.log-photos a:hover img{border-color:var(--teal,#17bfae)}
/* ---------- Phase 3: budget / change orders / POs ---------- */
.budget-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:10px;margin-top:8px}
.budget-cell{background:rgba(255,255,255,.03);border:1px solid var(--line,#2a2d33);border-radius:10px;padding:10px 12px;display:flex;flex-direction:column;gap:4px}
.budget-cell.hi{border-color:var(--teal,#17bfae)}
.budget-cell .lbl{font-size:11.5px;color:var(--muted,#8a8f98);letter-spacing:.4px;text-transform:uppercase}
.budget-cell .val{font-size:19px;font-weight:700}
.budget-cell .val.ok{color:#3fae5a}
.budget-cell .val.neg{color:#d9534f}
.amt{font-weight:700;margin-left:8px;white-space:nowrap}
.amt.neg{color:#d9534f}
.pay-history{width:100%;border-collapse:collapse;margin-top:8px;font-size:14px}
.pay-history td,.pay-history th{padding:8px 6px;border-top:1px solid var(--line,#2a2d33);text-align:left}
.pay-history th{font-size:12px;text-transform:uppercase;letter-spacing:.5px;color:var(--muted,#8a8f98);border-top:none}
.msg{display:flex;margin-bottom:14px}
.msg .bubble{max-width:78%;padding:10px 14px;border-radius:12px;font-size:14.5px}
.msg.them{justify-content:flex-start}
.msg.them .bubble{background:#eef1f0;color:#172421;border-bottom-left-radius:3px}
.msg.me{justify-content:flex-end}
.msg.me .bubble{background:#0a0b0d;color:#fff;border-bottom-right-radius:3px}
.msg .who{font-size:12px;color:var(--ink-soft);margin-bottom:3px}
