:root {
  /* Surfaces and structure */
  --bg: #F2EFE8;
  --surface: #FFFFFF;
  --surface-2: #ECEAE3;
  --border: #D8D5CE;
  --border-strong: #C4C1BA;

  /* Text */
  --text: #1C1A18;
  --text-2: #5C6164;
  --text-3: #8B9194;

  /* Primary action — blueprint teal */
  --accent: #2A6A82;
  --accent-hover: #235A6E;
  --accent-light: #E4EFF3;
  --accent-text: #1A4F62;

  /* Semantic states */
  --ok: #186035;
  --ok-light: #E5F2EB;
  --ok-text: #124D2A;
  --warn: #A07A1A;
  --warn-light: #FAF2DC;
  --warn-text: #7A5C10;
  --danger: #9E2A2A;
  --danger-light: #F8ECEC;
  --danger-text: #7A1F1F;
  --info: #2D4A54;
  --info-light: #E4EDF0;
  --info-text: #1E3540;

  /* Role identity colours */
  --role-client-bg: #E4EDF0;
  --role-client-text: #1E3540;
  --role-con-bg: #E5F2EB;
  --role-con-text: #124D2A;
  --role-mod-bg: #FAF2DC;
  --role-mod-text: #7A5C10;

  /* Spacing — tighter density for information-dense screens */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 14px;
  --sp-5: 20px; --sp-6: 28px; --sp-8: 40px;

  /* Radius — tighter, more technical */
  --r: 8px; --r-lg: 12px; --r-xl: 18px;

  --font-body: system-ui, 'Segoe UI', sans-serif;
  --font-data: 'Courier New', 'Consolas', monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1C1F22;
    --surface: #242729;
    --surface-2: #2C3033;
    --border: #3A3E42;
    --border-strong: #4A4F54;

    --text: #F0EDE6;
    --text-2: #A8ACB0;
    --text-3: #6E7478;

    --accent: #7EB5C8;
    --accent-hover: #91C2D2;
    --accent-light: #1A2E36;
    --accent-text: #A8D4E0;

    --ok: #5A9E6E;
    --ok-light: #152B1E;
    --ok-text: #8EC8A0;
    --warn: #C4922A;
    --warn-light: #2A2010;
    --warn-text: #DDB86A;
    --danger: #C25050;
    --danger-light: #2A1414;
    --danger-text: #E08888;
    --info: #7EB5C8;
    --info-light: #1A2E36;
    --info-text: #A8D4E0;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  font-size: 13px; line-height: 1.55;
  color: var(--text); background: var(--bg);
  font-weight: 400;
}
h1, h2, h3, h4 { margin: 0 0 var(--sp-3); }
h1 { font-size: 24px; font-weight: 600; }
h2 { font-size: 19px; font-weight: 600; }
h3 { font-size: 16px; font-weight: 500; }
h4 { font-size: 14px; font-weight: 500; }
p { margin: 0 0 var(--sp-3); color: var(--text-2); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Data values: prices, CIDB grades, dates, IDs, statuses — precise and consequential */
.data-val { font-family: var(--font-data); font-size: 12px; }

/* ---- Public nav / footer ---- */
.pubnav {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--sp-4) var(--sp-6); background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.pubnav-brand { font-weight: 600; font-size: 19px; color: var(--text); }
.pubnav-links a { margin-left: var(--sp-4); color: var(--text); font-weight: 600; }
.pubmain { max-width: 1100px; margin: 0 auto; padding: var(--sp-6); }
.pubfooter { text-align: center; padding: var(--sp-6); color: var(--text-3); font-size: 12px; }

/* ---- Dashboard topbar / layout ---- */
.topbar {
  display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-5); background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar-brand { font-weight: 600; font-size: 17px; }
.topbar-title { color: var(--text-2); font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: var(--sp-3); }
.topbar-user { font-weight: 600; }
.bell { position: relative; text-decoration: none; font-size: 16px; }
.bell-count {
  position: absolute; top: -6px; right: -10px; background: var(--accent); color: #fff;
  border-radius: 999px; font-size: 10px; padding: 1px 5px; font-weight: 600;
}

/* Role badge — role-specific identity colour */
.role-badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-family: var(--font-data); font-size: 10px; font-weight: 500;
  letter-spacing: .04em; text-transform: uppercase;
}
.role-badge.role-client { background: var(--role-client-bg); color: var(--role-client-text); }
.role-badge.role-contractor { background: var(--role-con-bg); color: var(--role-con-text); }
.role-badge.role-moderator { background: var(--role-mod-bg); color: var(--role-mod-text); }

.layout { display: flex; align-items: flex-start; max-width: 1300px; margin: 0 auto; }
.sidebar {
  width: 220px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border);
  min-height: calc(100vh - 53px); padding: var(--sp-5) 0;
}
.sidebar-brand { font-weight: 600; padding: 0 var(--sp-5) var(--sp-4); color: var(--text-3); font-size: 10px; text-transform: uppercase; letter-spacing: .04em; }
.sidebar-nav { display: flex; flex-direction: column; }
.sidebar-nav a {
  padding: var(--sp-3) var(--sp-5); color: var(--text); font-weight: 600; border-left: 3px solid transparent;
}
.sidebar-nav a:hover { background: var(--surface-2); text-decoration: none; }
.sidebar-nav a.active { border-left-color: var(--accent); background: var(--accent-light); color: var(--accent-text); }
.nav-badge { background: var(--accent); color: #fff; border-radius: 999px; font-family: var(--font-data); font-size: 10px; padding: 1px 6px; margin-left: var(--sp-1); }

.content-area { flex: 1; padding: var(--sp-6); min-width: 0; background: var(--bg); }

/* ---- Buttons ---- */
.btn {
  display: inline-block; padding: 7px 14px; border-radius: var(--r);
  font-weight: 500; font-size: 13px; border: 1px solid transparent; cursor: pointer;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-success { background: var(--ok); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 10px 20px; font-size: 14px; }

/* ---- Cards ---- */
.card { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--r-lg); margin-bottom: var(--sp-5); }
.card-header { padding: 12px 14px; border-bottom: 1px solid var(--border); font-weight: 600; }
.card-body { padding: var(--sp-4); }

/* ---- Forms ---- */
.form-group { margin-bottom: var(--sp-4); }
.form-label {
  display: block; font-family: var(--font-data); font-size: 10px; font-weight: 500;
  text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); margin-bottom: var(--sp-1);
}
.form-control {
  width: 100%; padding: var(--sp-2) var(--sp-3); border: 1.5px solid var(--border); border-radius: var(--r);
  font-size: 13px; font-family: var(--font-body); background: var(--surface); color: var(--text);
}
.form-control:focus { outline: none; border-color: var(--accent); }
.form-error { color: var(--danger); font-size: 12px; margin-top: var(--sp-1); }
.form-hint { color: var(--text-3); font-size: 12px; margin-top: var(--sp-1); }
.form-row { display: flex; gap: var(--sp-4); }
.form-row .form-group { flex: 1; }

/* ---- Alerts ---- */
.alert { padding: var(--sp-3) var(--sp-4); border-radius: var(--r); margin-bottom: var(--sp-4); font-weight: 600; border-left: 3px solid transparent; }
.alert-success { background: var(--ok-light); color: var(--ok-text); border-left-color: var(--ok); }
.alert-error { background: var(--danger-light); color: var(--danger-text); border-left-color: var(--danger); }
.alert-warning { background: var(--warn-light); color: var(--warn-text); border-left-color: var(--warn); }
.alert-info { background: var(--info-light); color: var(--info-text); border-left-color: var(--info); }

/* ---- Badges ---- */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-family: var(--font-data); font-size: 10px; font-weight: 500; letter-spacing: .04em; text-transform: uppercase;
}
.badge-ok { background: var(--ok-light); color: var(--ok-text); }
.badge-warn { background: var(--warn-light); color: var(--warn-text); }
.badge-info { background: var(--info-light); color: var(--info-text); }
.badge-danger { background: var(--danger-light); color: var(--danger-text); }
.badge-gray { background: var(--surface-2); color: var(--text-2); }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--r-lg); overflow: hidden; }
.table th, .table td { padding: var(--sp-3) var(--sp-4); text-align: left; border-bottom: 1px solid var(--border); }
.table th { background: var(--surface-2); font-family: var(--font-data); font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); font-weight: 500; }
.table tbody tr:hover { background: var(--surface-2); }

/* ---- Flow steps ---- */
.flow-steps { display: flex; gap: var(--sp-3); margin-bottom: var(--sp-5); }
.flow-step { flex: 1; background: var(--surface); border: 1px solid var(--border); border-top: 2px solid transparent; border-radius: var(--r); padding: var(--sp-3) var(--sp-4); text-align: center; color: var(--text-3); font-weight: 600; }
.flow-step.active { border-top-color: var(--accent); background: var(--accent-light); color: var(--accent-text); }
.flow-step.done { border-top-color: var(--ok); background: var(--ok-light); color: var(--ok-text); }

/* ---- Stat cards ---- */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-4); margin-bottom: var(--sp-5); }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 0; padding: var(--sp-4); }
.stat-card .num { font-family: var(--font-data); font-size: 22px; font-weight: 600; color: var(--accent); }
.stat-card .label { color: var(--text-2); font-family: var(--font-data); font-size: 10px; text-transform: uppercase; letter-spacing: .04em; }

/* ---- Role cards (landing) ---- */
.role-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-5); margin: var(--sp-6) 0; }
.role-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); padding: var(--sp-6); text-align: center; }
.role-card .icon { font-size: 36px; margin-bottom: var(--sp-3); }
.hero { text-align: center; padding: var(--sp-8) 0 var(--sp-5); }
.features-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-5); margin: var(--sp-6) 0; }
.feature-col { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-5); }

/* ---- Match card ---- */
.match-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-4); margin-bottom: var(--sp-3); }
.match-card.top-pick { border: 1.5px solid var(--accent); background: var(--accent-light); }
.match-score { font-family: var(--font-data); font-size: 28px; font-weight: 600; color: var(--accent); }
.match-reasons { list-style: none; padding: 0; margin: var(--sp-2) 0; color: var(--text-2); font-size: 13px; }
.match-reasons li::before { content: "✓ "; color: var(--ok); font-weight: 600; }

/* ---- Marketplace (phase 2 groundwork) ---- */
.product-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); }
.product-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: var(--sp-3); }
.product-card .price { font-family: var(--font-data); color: var(--accent); font-weight: 600; }

.two-col { display: grid; grid-template-columns: 1fr 1.3fr; gap: var(--sp-5); align-items: start; }

@media (max-width: 768px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; min-height: auto; }
  .content-area { padding: var(--sp-4); }
  .role-cards, .features-strip, .two-col, .stats-row, .product-grid { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; gap: 0; }
  .table-wrap { overflow-x: auto; }
  .card-body { padding: var(--sp-3); }
}
