:root {
  --navy: #1f3864;
  --green: #2e6f40;
  --gray: #6b6b6b;
  --amber: #c9861a;
  --bg: #f4f6fa;
  --card-bg: #ffffff;
  --border: #d9dee6;
  --text: #1f2937;
  --muted: #6b7280;
  --danger: #b3261e;
  --radius: 10px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.centered-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.centered-view[hidden] {
  display: none;
}
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { color: var(--navy); margin: 0 0 4px; font-size: 22px; }
.muted { color: var(--muted); margin-top: 0; font-size: 14px; }

label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
textarea { resize: vertical; }

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 14px;
}
.btn-primary { background: var(--navy); color: white; }
.btn-primary:hover { background: #16294d; }
.btn-secondary { background: var(--green); color: white; }
.btn-secondary:hover { background: #235731; }
.btn-small { background: var(--navy); color: white; padding: 7px 12px; font-size: 13px; margin-top: 0; }
.btn-link {
  background: none; border: none; color: var(--navy); font-size: 13px;
  cursor: pointer; text-decoration: underline; padding: 0; margin-top: 12px;
}
.error-text { color: var(--danger); font-size: 13px; margin-top: 8px; }
.success-text { color: var(--green); font-size: 13px; margin-top: 8px; }
hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--navy); color: white; padding: 12px 20px;
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 16px; }
.topnav { display: flex; gap: 8px; }
.nav-btn {
  background: transparent; border: 1px solid rgba(255,255,255,0.3); color: white;
  padding: 6px 14px; border-radius: 20px; font-size: 13px; cursor: pointer;
}
.nav-btn.active { background: white; color: var(--navy); font-weight: 600; }
.user-chip { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.role-badge {
  background: var(--amber); color: white; padding: 3px 9px; border-radius: 12px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px;
}
#logout-btn { color: white; }

main { max-width: 1400px; margin: 0 auto; padding: 20px; }

/* KPIs */
.kpis { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.kpi-card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 18px; min-width: 150px; flex: 1;
}
.kpi-card .kpi-label { font-size: 12px; color: var(--muted); text-transform: uppercase; }
.kpi-card .kpi-value { font-size: 22px; font-weight: 700; color: var(--navy); margin-top: 4px; }

.board-toolbar { display: flex; align-items: center; justify-content: space-between; margin: 10px 0; }
.board-toolbar h2 { color: var(--navy); font-size: 18px; }

/* Kanban board */
.board {
  display: grid;
  grid-template-columns: repeat(6, minmax(220px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 12px;
}
.board-col {
  background: #eef2f9;
  border-radius: var(--radius);
  padding: 10px;
  min-height: 200px;
}
.board-col h4 {
  font-size: 12.5px; color: var(--navy); margin: 2px 4px 10px;
  text-transform: uppercase; letter-spacing: 0.3px;
}
.project-card {
  background: white; border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; margin-bottom: 10px; cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.project-card:hover { border-color: var(--navy); }
.project-card .ref { font-weight: 700; font-size: 13px; color: var(--navy); }
.project-card .client { font-size: 12.5px; color: var(--text); margin: 3px 0; }
.project-card .value { font-size: 12px; color: var(--muted); }
.progress-row { display: flex; align-items: center; gap: 8px; margin: 6px 0 4px; }
.progress-bar { flex: 1; height: 6px; background: #e3e8f0; border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--navy); }
.progress-pct { font-size: 11px; color: var(--muted); min-width: 28px; text-align: right; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.status-on_track { background: #2e6f40; }
.status-delayed { background: var(--amber); }
.status-at_risk { background: var(--danger); }
.status-closed { background: var(--gray); }

/* Table (users) */
.table { width: 100%; border-collapse: collapse; background: white; border-radius: var(--radius); overflow: hidden; }
.table th, .table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.table th { background: #eef2f9; color: var(--navy); font-size: 12px; text-transform: uppercase; }

/* Modals */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,0.45); z-index: 20;
}
.modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: white; border-radius: var(--radius); z-index: 21;
  width: min(760px, 92vw); max-height: 88vh; overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: white;
}
.modal-header h3 { margin: 0; color: var(--navy); font-size: 17px; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--muted); }
.modal-body { padding: 18px 20px 24px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 680px) {
  .grid-2 { grid-template-columns: 1fr; }
  .board { grid-template-columns: 1fr; }
}

.party-list, .note-list { list-style: none; padding: 0; margin: 6px 0; max-height: 140px; overflow-y: auto; }
.party-list li, .note-list li {
  font-size: 13px; padding: 6px 8px; border-bottom: 1px solid var(--border);
}
.note-list li .note-meta { color: var(--muted); font-size: 11px; display: block; }
.inline-form { display: flex; gap: 6px; margin-top: 8px; }
.inline-form input, .inline-form select { flex: 1; }

.invoice-summary { margin: 2px 0 6px; font-size: 12.5px; }
.invoice-row { display: flex; flex-direction: column; gap: 4px; }
.invoice-main { display: flex; justify-content: space-between; font-weight: 600; }
.invoice-actions { display: flex; align-items: center; gap: 8px; }
.invoice-actions select { width: auto; flex: 0 0 140px; padding: 5px 6px; font-size: 12.5px; }
.invoice-amount-input { max-width: 130px; }
