:root {
  --ink: #1d2733;
  --ink-soft: #4a5868;
  --muted: #6b7785;
  --line: #dfe3e8;
  --bg: #f4f5f7;
  --card: #ffffff;
  --brand: #1f3a52;
  --accent: #e0752d;
  --accent-dark: #c2601d;
  --success: #2e7d4f;
  --danger: #b3261e;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
a { color: var(--brand); }
a:hover { color: var(--accent-dark); }
h1, h2 { line-height: 1.25; margin: 0 0 0.5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.1rem; }
p { margin: 0 0 0.75rem; }

.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.main { flex: 1; padding-top: 24px; padding-bottom: 48px; }

/* Top bar */
.topbar { background: var(--brand); color: #fff; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; }
.brand:hover { color: #fff; }
.brand small { display: block; font-weight: 500; font-size: 0.75rem; opacity: 0.75; letter-spacing: 0.04em; text-transform: uppercase; }
.brand-mark { width: 28px; height: 28px; background: var(--accent); clip-path: polygon(50% 0, 100% 100%, 0 100%); flex: none; }
.nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.nav a, .nav-button {
  color: #fff; text-decoration: none; padding: 8px 12px; border-radius: 6px; font: inherit; font-size: 0.95rem;
  background: none; border: 0; cursor: pointer;
}
.nav a:hover, .nav-button:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }

.footer { color: var(--muted); font-size: 0.85rem; padding: 24px 0; border-top: 1px solid var(--line); background: #fff; }

/* Layout pieces */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumbs { font-size: 0.9rem; color: var(--muted); margin-bottom: 8px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.columns { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 900px) { .columns { grid-template-columns: 1fr; } }
.form-card { max-width: 760px; }
.empty { text-align: center; padding: 40px 20px; }
.auth-card { max-width: 420px; margin: 40px auto; }

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; margin: 0; }
.text-danger { color: var(--danger); font-weight: 600; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.inline { display: inline; margin: 0; }

/* Forms */
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack > .btn:not(.btn-block) { align-self: flex-start; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 0.9rem; color: var(--ink-soft); }
label.checkbox { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
input, select, textarea {
  font: inherit; font-weight: 400; color: var(--ink); background: #fff;
  border: 1px solid #c9d0d8; border-radius: 8px; padding: 9px 11px; width: 100%;
}
input[type="checkbox"] { width: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
input:disabled { background: var(--bg); color: var(--muted); }
textarea { resize: vertical; }
.row-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row-form label { min-width: 160px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; font-size: 0.95rem; text-decoration: none; cursor: pointer;
  padding: 9px 16px; border-radius: 8px; border: 1px solid #c9d0d8; background: #fff; color: var(--ink);
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { color: #fff; opacity: 0.9; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-small { padding: 6px 12px; font-size: 0.85rem; }
.btn-block { width: 100%; }
.icon-btn { border: 0; background: none; color: var(--muted); font-size: 1.25rem; line-height: 1; cursor: pointer; padding: 2px 6px; border-radius: 4px; }
.icon-btn:hover { color: var(--danger); background: #fbeaea; }

details.add-form { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 12px; }
details.add-form summary { cursor: pointer; font-weight: 600; color: var(--brand); margin-bottom: 12px; }

/* Flash */
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 20px; border: 1px solid; }
.flash-success { background: #eaf6ef; border-color: #b7dfc6; color: #1d5a37; }
.flash-error { background: #fbeaea; border-color: #efc1be; color: #7e1c16; }
.flash-info { background: #eaf1f8; border-color: #bcd2e6; color: #1f3a52; }
.flash-credentials { background: #fff6e5; border-color: #f0cf8e; color: #6a4a0c; font-weight: 600; overflow-wrap: anywhere; }

/* Badges */
.badge { display: inline-block; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.02em; padding: 3px 9px; border-radius: 999px; background: #e7ebef; color: var(--ink-soft); vertical-align: middle; white-space: nowrap; }
.badge-planning, .badge-design { background: #e8eefc; color: #2a4a9c; }
.badge-permitting { background: #f3e9fb; color: #6b2f96; }
.badge-in_progress { background: #fff0e3; color: #9a4a10; }
.badge-on_hold { background: #fbeaea; color: #8b1f18; }
.badge-completed { background: #e6f4ec; color: #22603c; }
.badge-cancelled { background: #eceef0; color: #5b6570; }
.badge-inv-draft { background: #eceef0; }
.badge-inv-sent { background: #fff0e3; color: #9a4a10; }
.badge-inv-paid { background: #e6f4ec; color: #22603c; }
.badge-inv-void { background: #eceef0; color: #8a929b; text-decoration: line-through; }
.tag { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; background: var(--brand); color: #fff; padding: 2px 6px; border-radius: 4px; vertical-align: middle; }
.tag-new { background: var(--accent); }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { display: flex; flex-direction: column; gap: 4px; margin: 0; text-decoration: none; color: inherit; }
.stat-value { font-size: 1.7rem; font-weight: 700; color: var(--brand); }
.stat-value-sm { font-size: 1.2rem; }
.stat-label { color: var(--muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; }
a.stat:hover { border-color: var(--accent); }

.progress { height: 8px; background: #e7ebef; border-radius: 999px; overflow: hidden; margin: 8px 0; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #f0a05a); border-radius: inherit; }
.progress-sm { height: 6px; margin: 4px 0; max-width: 120px; }

/* Project cards */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; margin-bottom: 20px; }
.project-card { display: block; text-decoration: none; color: inherit; margin: 0; transition: border-color 0.15s, transform 0.15s; }
.project-card:hover { border-color: var(--accent); color: inherit; transform: translateY(-2px); }
.project-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.facts { margin: 12px 0 0; display: grid; gap: 6px; }
.facts div { display: flex; justify-content: space-between; gap: 12px; font-size: 0.9rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; text-align: right; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th { text-align: left; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--line); }
td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.inactive td { opacity: 0.55; }

/* Feeds and lists */
.feed { list-style: none; margin: 16px 0 0; padding: 0; }
.feed li { padding: 14px 0; border-top: 1px solid var(--line); }
.feed li.from-consultant { border-left: 3px solid var(--accent); padding-left: 12px; }
.feed li.from-client { border-left: 3px solid var(--brand); padding-left: 12px; }
.feed-meta { font-size: 0.85rem; color: var(--muted); margin-bottom: 4px; }
.feed-meta strong { color: var(--ink); }
.feed p { margin: 0; }

.checklist, .files, .invoices { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.checklist-body { flex: 1; display: flex; flex-direction: column; }
.check { width: 20px; height: 20px; border: 2px solid #b6bfc9; border-radius: 5px; background: #fff; flex: none; margin-top: 2px; padding: 0; display: inline-block; }
button.check { cursor: pointer; }
button.check:hover { border-color: var(--accent); }
.checklist li.done .check { background: var(--success); border-color: var(--success); box-shadow: inset 0 0 0 3px #fff; }
.checklist li.done .checklist-body > span:first-child { text-decoration: line-through; color: var(--muted); }
.checklist li.late .checklist-body .small { color: var(--danger); font-weight: 600; }

.files li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.files li a { font-weight: 600; overflow-wrap: anywhere; }
.files li .small { flex: 1; }
.upload-form { margin-top: 16px; }

.invoices li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.invoice-line { display: flex; justify-content: space-between; gap: 8px; }
.invoice-admin { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.invoice-admin select { width: auto; padding: 4px 8px; font-size: 0.85rem; }

.inquiry.handled { opacity: 0.7; }
.danger-zone { border-color: #efc1be; max-width: 760px; }
