:root {
  --bg: #fdfdfc;
  --bg2: #f7f7f5;
  --ink: #1d1d1b;
  --ink2: #52524e;
  --ink3: #7d7d78;
  --line: #e2e2df;
  --accent: #3b9fe7;
  --f: 'Inter', system-ui, sans-serif;
  --fh: 'EB Garamond', 'Georgia', serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--f); font-size: 14px; line-height: 1.6; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }

/* Nav */
.dash-nav { padding: 12px 0; border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 10; }
.dash-nav-inner { max-width: 960px; margin: 0 auto; padding: 0 24px; display: flex; justify-content: space-between; align-items: center; }
.dash-logo { font-family: var(--fh); font-size: 18px; font-weight: 600; letter-spacing: -0.02em; }
.dash-logo span { color: var(--accent); font-style: italic; }
.dash-badge { font-family: var(--f); font-size: 10px; font-weight: 500; color: var(--ink3); background: var(--bg2); padding: 2px 8px; border-radius: 3px; margin-left: 8px; letter-spacing: 0.02em; font-style: normal; }
.dash-logout { font-size: 12px; color: var(--ink3); }
.dash-logout:hover { color: var(--ink); }

/* Main */
.dash-main { max-width: 960px; margin: 0 auto; padding: 32px 24px 80px; }

/* Header */
.dash-header { margin-bottom: 24px; }
.dash-header h1 { font-family: var(--fh); font-size: 1.5rem; font-weight: 500; letter-spacing: -0.01em; }
.dash-header-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.dash-sub { font-size: 14px; color: var(--ink2); margin-top: 4px; }
.back-link { font-size: 12px; color: var(--ink3); display: block; margin-bottom: 8px; }
.back-link:hover { color: var(--accent); }
.back-link::before { content: "\2190 "; }

/* Stats row */
.dash-stats { display: flex; gap: 16px; margin-bottom: 24px; }
.stat { background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; padding: 14px 20px; min-width: 120px; }
.stat-n { display: block; font-family: var(--fh); font-size: 1.25rem; font-weight: 500; color: var(--ink); }
.stat-l { font-size: 11px; color: var(--ink3); text-transform: uppercase; letter-spacing: 0.06em; }

/* Buttons */
.btn-p { display: inline-block; padding: 8px 18px; font-size: 13px; font-weight: 500; font-family: var(--f); background: var(--accent); color: #fff; border: none; border-radius: 4px; cursor: pointer; transition: opacity 0.15s; text-align: center; }
.btn-p:hover { opacity: 0.9; }
.btn-s { display: inline-block; padding: 8px 18px; font-size: 13px; font-weight: 500; font-family: var(--f); background: none; color: var(--ink); border: 1px solid var(--line); border-radius: 4px; cursor: pointer; transition: border-color 0.15s; }
.btn-s:hover { border-color: var(--ink3); }
.btn-xs { font-size: 11px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 3px; color: var(--ink3); transition: all 0.15s; background: none; cursor: pointer; font-family: var(--f); }
.btn-xs:hover { border-color: var(--ink3); color: var(--ink); }
.btn-danger { color: #c44; border-color: #e8c8c8; }
.btn-danger:hover { color: #a22; border-color: #c44; }

/* Actions */
.actions-section { margin-bottom: 32px; }
.actions-title { font-family: var(--fh); font-size: 1.1rem; font-weight: 500; margin-bottom: 12px; }
.actions-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.action-card { display: block; padding: 16px; border: 1px solid var(--line); border-radius: 6px; transition: border-color 0.15s; }
.action-card:hover { border-color: var(--accent); }
.action-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.action-name { font-size: 14px; font-weight: 500; }
.action-next { font-size: 12px; color: var(--ink2); margin-bottom: 10px; }
.action-progress { display: flex; align-items: center; gap: 8px; }
.action-bar { flex: 1; height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.action-fill { height: 100%; background: var(--accent); border-radius: 2px; }
.action-count { font-size: 11px; color: var(--ink3); }

/* Internal Tasks */
.todos-section { margin-top: 40px; padding-top: 32px; border-top: 1px solid var(--line); }
.todo-add { display: flex; gap: 8px; margin-bottom: 16px; }
.todo-add input { flex: 1; padding: 8px 12px; font-size: 13px; font-family: var(--f); border: 1px solid var(--line); border-radius: 4px; background: var(--bg); color: var(--ink); }
.todo-add input:focus { outline: none; border-color: var(--accent); }
.todo-date { font-size: 10px; color: var(--ink3); margin-left: 8px; }
.todos-section .task-row { display: flex; align-items: center; gap: 10px; }
.task-row-actions { margin-left: auto; }
.todo-editable { cursor: pointer; }
.todo-editable:hover { color: var(--accent); }
.todo-edit-form { display: inline-flex; gap: 6px; align-items: center; flex: 1; }
.todo-edit-input { padding: 4px 8px; font-size: 13px; font-family: var(--f); border: 1px solid var(--accent); border-radius: 3px; background: var(--bg); color: var(--ink); flex: 1; }
.todo-edit-input:focus { outline: none; }
.completed-section { margin-top: 12px; }
.completed-toggle { font-size: 12px; color: var(--ink3); cursor: pointer; padding: 8px 0; list-style: none; }
.completed-toggle::-webkit-details-marker { display: none; }
.completed-toggle::before { content: "\25B8 "; }
details[open] .completed-toggle::before { content: "\25BE "; }
.task-list--completed { margin-top: 8px; opacity: 0.6; }

/* Table */
.dash-table { width: 100%; border-collapse: collapse; }
.dash-table th { text-align: left; font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink3); padding: 10px 12px; border-bottom: 2px solid var(--line); }
.dash-table td { padding: 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
.dash-table tr.clickable { cursor: pointer; }
.dash-table tr.clickable:hover td { background: var(--bg2); }
.td-name { font-weight: 500; }
.td-date { color: var(--ink3); font-size: 12px; }
.td-money { font-size: 12px; color: var(--ink2); }

/* Pills */
.tag-pill { font-size: 11px; padding: 2px 8px; border-radius: 3px; font-weight: 500; }
.tag-audit { background: #e8f4fd; color: #1a7cc0; }
.tag-full-build { background: #e6f9ed; color: #1a8a4a; }
.tag-unsure { background: var(--bg2); color: var(--ink3); }
.stage-pill { font-size: 11px; color: var(--ink2); background: var(--bg2); padding: 2px 8px; border-radius: 3px; }

/* Empty state */
.empty-state { text-align: center; padding: 60px 0; }
.empty-state p { color: var(--ink3); margin-bottom: 16px; }
.empty-note { font-size: 13px; color: var(--ink3); padding: 16px 0; }

/* Timeline */
.timeline { display: flex; gap: 0; margin-bottom: 24px; padding: 20px 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tl-step { flex: 1; text-align: center; position: relative; min-width: 80px; }
.tl-step::before { content: ""; position: absolute; top: 6px; left: 0; right: 0; height: 2px; background: var(--line); z-index: 0; }
.tl-step:first-child::before { left: 50%; }
.tl-step:last-child::before { right: 50%; }
.tl-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--bg); border: 2px solid var(--line); margin: 0 auto 6px; position: relative; z-index: 1; }
.tl-done .tl-dot { background: var(--accent); border-color: var(--accent); }
.tl-done::before { background: var(--accent); }
.tl-current .tl-dot { border-color: var(--accent); background: var(--bg); box-shadow: 0 0 0 3px rgba(59,159,231,0.2); }
.tl-label { font-size: 10px; font-weight: 500; color: var(--ink3); }
.tl-done .tl-label { color: var(--ink2); }
.tl-current .tl-label { color: var(--accent); font-weight: 600; }
.tl-date { font-size: 9px; color: var(--ink3); margin-top: 2px; }

/* Client detail */
.client-sub { font-size: 13px; color: var(--ink3); margin-top: 2px; }

.client-meta { display: flex; gap: 24px; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.client-meta label { font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink3); display: block; margin-bottom: 4px; }
.stage-form { display: flex; flex-direction: column; }
.stage-form select, .form-field select { font-family: var(--f); font-size: 13px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 3px; background: var(--bg); color: var(--ink); }
.meta-item span { font-size: 13px; }

/* Client info form */
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.info-form { background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; padding: 20px; }
.info-form .form-field { margin-bottom: 12px; }
.info-form .form-field:last-of-type { margin-bottom: 16px; }
.info-form label { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink3); display: block; margin-bottom: 4px; }
.info-form input, .info-form textarea { width: 100%; padding: 6px 10px; font-size: 13px; font-family: var(--f); border: 1px solid var(--line); border-radius: 3px; background: var(--bg); color: var(--ink); }
.info-form input:focus, .info-form textarea:focus { outline: none; border-color: var(--accent); }
.info-form textarea { resize: vertical; }

/* Tasks */
.task-count { font-size: 12px; color: var(--ink3); background: var(--bg2); padding: 2px 8px; border-radius: 3px; }
.task-list { border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.task-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: none; }
.task-row:last-child { border-bottom: none; }
.task-row:hover { background: var(--bg2); }
.task-done { opacity: 0.5; }
.task-done .task-label { text-decoration: line-through; }
.task-check { width: 22px; height: 22px; border: 1.5px solid var(--line); border-radius: 4px; background: var(--bg); cursor: pointer; font-size: 12px; color: var(--accent); display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-family: var(--f); }
.task-check:hover { border-color: var(--accent); }
.task-done .task-check { background: var(--accent); color: #fff; border-color: var(--accent); }
.task-label { font-size: 13px; color: var(--ink2); }

/* Files */
.client-section { margin-bottom: 32px; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.section-header h2 { font-family: var(--fh); font-size: 1.1rem; font-weight: 500; }
.upload-btn { cursor: pointer; }

.file-list { border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.file-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.file-row:last-child { border-bottom: none; }
.file-row:hover { background: var(--bg2); }
.file-info { display: flex; align-items: center; gap: 10px; }
.file-icon { font-size: 9px; font-weight: 700; letter-spacing: 0.04em; color: var(--ink3); background: var(--bg2); padding: 3px 6px; border-radius: 2px; min-width: 32px; text-align: center; }
.file-name { font-size: 13px; font-weight: 500; }
.file-size { font-size: 11px; color: var(--ink3); }
.file-actions { display: flex; gap: 6px; align-items: center; }

/* Forms */
.dash-form { max-width: 540px; }
.form-field { margin-bottom: 20px; }
.form-field label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.form-field .opt { font-weight: 400; color: var(--ink3); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-field input[type="text"],
.form-field input[type="password"],
.form-field textarea,
.form-field select {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  font-family: var(--f);
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
  color: var(--ink);
}
.form-field input:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.form-field textarea { resize: vertical; }
.dash-form .btn-p { margin-top: 8px; }

/* Markdown viewer */
.md-viewer { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 32px; max-width: 680px; }
.md-viewer h1 { font-family: var(--fh); font-size: 1.25rem; font-weight: 500; margin-top: 24px; margin-bottom: 8px; }
.md-viewer h2 { font-family: var(--fh); font-size: 1rem; font-weight: 500; margin-top: 20px; margin-bottom: 6px; }
.md-viewer h3 { font-family: var(--fh); font-size: 0.9rem; font-weight: 500; margin-top: 16px; margin-bottom: 4px; }
.md-viewer p { color: var(--ink2); margin-bottom: 12px; line-height: 1.7; }
.md-viewer ul, .md-viewer ol { padding-left: 20px; margin-bottom: 12px; }
.md-viewer li { color: var(--ink2); margin-bottom: 4px; }
.md-viewer strong { color: var(--ink); font-weight: 500; }
.md-viewer hr { border: none; border-top: 1px solid var(--line); margin: 20px 0; }
.md-viewer code { font-size: 12px; background: var(--bg2); padding: 1px 5px; border-radius: 2px; }
.md-viewer pre { background: var(--bg2); border: 1px solid var(--line); padding: 14px; border-radius: 4px; overflow-x: auto; margin: 12px 0; }
.md-viewer table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.md-viewer th, .md-viewer td { padding: 6px 10px; border-bottom: 1px solid var(--line); font-size: 13px; text-align: left; }
.md-viewer th { font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink3); }

/* Login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }
.login-box { width: 320px; text-align: center; }
.login-logo { font-family: var(--fh); font-size: 22px; font-weight: 600; letter-spacing: -0.02em; margin-bottom: 32px; }
.login-logo span { color: var(--accent); font-style: italic; }
.login-box input { width: 100%; padding: 10px 14px; font-size: 14px; font-family: var(--f); border: 1px solid var(--line); border-radius: 4px; margin-bottom: 12px; text-align: center; }
.login-box input:focus { outline: none; border-color: var(--accent); }
.login-box .btn-p { width: 100%; padding: 10px; }
.login-error { color: #d44; font-size: 13px; margin-bottom: 12px; }

/* Mobile */
@media (max-width: 640px) {
  .dash-main { padding: 24px 16px 60px; }
  .dash-header h1 { font-size: 1.25rem; }
  .dash-header-row { flex-direction: column; }
  .dash-stats { flex-direction: column; gap: 8px; }
  .stat { min-width: auto; }
  .client-meta { flex-direction: column; gap: 12px; align-items: flex-start; }
  .timeline { gap: 0; }
  .tl-step { min-width: 60px; }
  .tl-label { font-size: 8px; }
  .info-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .dash-table th, .dash-table td { padding: 8px; font-size: 12px; }
  .file-row { flex-direction: column; gap: 8px; align-items: flex-start; }
  .md-viewer { padding: 20px; }
}
