/* ── Reset & Tokens ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand:       #8C1C13;
  --brand-dark:  #6B1510;
  --brand-light: #F5EDEC;
  --bg:          #FAFAF8;
  --surface:     #FFFFFF;
  --border:      #E8E6E1;
  --text:        #1A1A18;
  --text-2:      #6B6B67;
  --text-3:      #A0A09C;
  --green:       #16a34a;
  --amber:       #d97706;
  --blue:        #2563eb;
  --radius:      8px;
  --shadow:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:   0 4px 12px rgba(0,0,0,.10);
  --nav-h:       56px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

/* ── Layout ── */
#app { display: flex; flex-direction: column; min-height: 100dvh; }
#view { flex: 1; padding-bottom: 80px; }

/* ── Nav ── */
nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}
nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; text-decoration: none;
  color: var(--text-3); font-size: 10px; font-weight: 500;
  transition: color .15s;
}
nav a.active, nav a:hover { color: var(--brand); }
nav a svg { width: 22px; height: 22px; stroke-width: 1.5; }

/* ── Top bar ── */
.topbar {
  position: sticky; top: 0; z-index: 90;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  height: 52px; display: flex; align-items: center; gap: 12px;
}
.topbar h1 { font-size: 16px; font-weight: 600; flex: 1; }
.topbar .logo { font-size: 13px; font-weight: 700; color: var(--brand); letter-spacing: .02em; }
.topbar .badge {
  font-size: 10px; padding: 2px 8px; border-radius: 20px;
  background: var(--brand-light); color: var(--brand); font-weight: 600;
}

/* ── Login ── */
#login-screen {
  min-height: 100dvh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 24px;
  background: var(--bg);
}
.login-box {
  width: 100%; max-width: 380px;
  background: var(--surface); border-radius: 12px;
  border: 1px solid var(--border);
  padding: 32px 28px;
  box-shadow: var(--shadow-md);
}
.login-logo {
  font-size: 14px; font-weight: 700; color: var(--brand);
  letter-spacing: .04em; text-transform: uppercase;
  margin-bottom: 4px;
}
.login-sub { font-size: 13px; color: var(--text-2); margin-bottom: 28px; }
.login-box h2 { font-size: 20px; font-weight: 600; margin-bottom: 20px; }

/* ── Forms ── */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
label { font-size: 12px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg);
  font-size: 14px; font-family: var(--font); color: var(--text);
  transition: border-color .15s, box-shadow .15s; outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(140,28,19,.1);
}
textarea { resize: vertical; min-height: 80px; }
.error-msg { font-size: 12px; color: #dc2626; margin-top: 4px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: var(--radius); font-size: 14px;
  font-weight: 600; font-family: var(--font); cursor: pointer;
  border: none; transition: background .15s, opacity .15s; text-decoration: none;
}
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--brand); color: white; width: 100%; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: transparent; color: var(--text-2); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon { padding: 8px; border-radius: 50%; }
.btn-google {
  width: 100%; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); padding: 12px 18px;
  font-size: 15px; font-weight: 500;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.btn-google:hover { background: var(--bg); box-shadow: 0 2px 6px rgba(0,0,0,.12); }

/* ── Cards ── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 8px; }

/* ── Page padding ── */
.page { padding: 16px; max-width: 640px; margin: 0 auto; }
.page-header { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.page-header h2 { font-size: 18px; font-weight: 600; flex: 1; }

/* ── Status pills ── */
.pill {
  display: inline-block; font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 20px; white-space: nowrap;
}
.pill-prospect  { background: #f3f4f6; color: #374151; }
.pill-design    { background: #eff6ff; color: #1d4ed8; }
.pill-dwg       { background: #fdf4ff; color: #7e22ce; }
.pill-tender    { background: #fff7ed; color: #c2410c; }
.pill-construction { background: #f0fdf4; color: #15803d; }
.pill-completed { background: #f1f5f9; color: #475569; }
.pill-on-hold   { background: #fefce8; color: #a16207; }

/* ── Dashboard stats ── */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
  display: flex; flex-direction: column; gap: 2px;
}
.stat-label { font-size: 11px; color: var(--text-2); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1.1; }
.stat-sub   { font-size: 11px; color: var(--text-3); }

/* ── Project list item ── */
.project-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 6px;
  cursor: pointer; transition: border-color .15s, box-shadow .15s;
  text-decoration: none; color: inherit;
}
.project-item:hover { border-color: var(--brand); box-shadow: var(--shadow-md); }
.project-item + .project-item { margin-top: 8px; }
.project-code { font-size: 11px; font-weight: 700; color: var(--text-3); letter-spacing: .06em; text-transform: uppercase; }
.project-name { font-size: 15px; font-weight: 600; }
.project-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.project-client { font-size: 12px; color: var(--text-2); }

/* ── Section header ── */
.section-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-3); margin: 20px 0 10px;
}

/* ── Divider ── */
hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ── Empty state ── */
.empty { text-align: center; padding: 40px 20px; color: var(--text-2); }
.empty svg { width: 40px; height: 40px; stroke: var(--text-3); margin-bottom: 10px; }
.empty p { font-size: 14px; }

/* ── Modal overlay ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  z-index: 200; display: flex; align-items: flex-end;
  animation: fade-in .15s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface); border-radius: 16px 16px 0 0;
  width: 100%; max-height: 90dvh; overflow-y: auto;
  padding: 20px 20px 40px;
  animation: slide-up .2s ease;
}
@keyframes slide-up { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-handle { width: 36px; height: 4px; background: var(--border); border-radius: 2px; margin: 0 auto 16px; }
.modal h3 { font-size: 17px; font-weight: 600; margin-bottom: 16px; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: calc(var(--nav-h) + 16px); left: 50%; transform: translateX(-50%);
  background: var(--text); color: white; padding: 10px 18px; border-radius: 20px;
  font-size: 13px; font-weight: 500; z-index: 300; white-space: nowrap;
  animation: toast-in .2s ease; pointer-events: none;
}
@keyframes toast-in { from { opacity: 0; transform: translateX(-50%) translateY(8px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ── Loading spinner ── */
.spinner {
  width: 20px; height: 20px; border: 2px solid var(--border);
  border-top-color: var(--brand); border-radius: 50%; animation: spin .6s linear infinite;
  margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Role indicator ── */
.role-partner { color: var(--brand); }
.role-employee { color: var(--blue); }
.role-contractor { color: #7e22ce; }

/* ── Responsive desktop ── */
@media (min-width: 768px) {
  nav { top: 0; bottom: auto; border-top: none; border-bottom: 1px solid var(--border); height: 60px; }
  nav a { flex-direction: row; gap: 6px; font-size: 13px; max-width: 160px; }
  nav a svg { width: 18px; height: 18px; }
  #view { padding-bottom: 0; padding-top: 60px; }
  .modal-overlay { align-items: center; }
  .modal { border-radius: 12px; max-width: 480px; margin: auto; padding: 24px; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}
