:root {
    --ink: #14202e;
    --ink-2: #233348;
    --surface: #f5f7fa;
    --paper: #ffffff;
    --line: #dbe2ea;
    --line-strong: #c2cdda;
    --muted: #5d6b7c;
    --amber: #e8a13b;
    --amber-dark: #c97f17;
    --green: #2f7d5b;
    --green-soft: #e6f2ec;
    --red: #c0492f;
    --red-soft: #fbe9e5;
    --shadow: 0 1px 2px rgba(20,32,46,.06), 0 8px 24px rgba(20,32,46,.06);
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    color: var(--ink);
    background: var(--surface);
    margin: 0;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .display {
    font-family: 'Space Grotesk', 'Inter', sans-serif;
    letter-spacing: -.01em;
    color: var(--ink);
}

a { color: var(--ink); text-decoration: none; }
a:hover { color: var(--amber-dark); }

.mono, .num { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }

/* ---------- Top bar ---------- */
.topbar {
    background: var(--ink);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar .navbar-brand { color: #fff; font-family: 'Space Grotesk', sans-serif; font-weight: 700; letter-spacing: .02em; }
.topbar .brand-mark {
    display: inline-flex; width: 30px; height: 30px; margin-right: .5rem;
    background: var(--amber); color: var(--ink); border-radius: 7px;
    align-items: center; justify-content: center; font-weight: 700;
}
.topbar .nav-link { color: rgba(255,255,255,.82) !important; font-size: .92rem; font-weight: 500; }
.topbar .nav-link:hover, .topbar .nav-link.active { color: #fff !important; }
.topbar .navbar-toggler { border-color: rgba(255,255,255,.3); }

.role-chip {
    font-size: .68rem; text-transform: uppercase; letter-spacing: .08em;
    background: rgba(232,161,59,.18); color: var(--amber);
    padding: .15rem .5rem; border-radius: 999px; font-weight: 600;
}

/* ---------- Blueprint hero ---------- */
.hero {
    background: var(--ink);
    color: #fff;
    position: relative;
    overflow: hidden;
    padding: 4.5rem 0 4rem;
}
.hero::before {
    content: "";
    position: absolute; inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px);
    background-size: 28px 28px;
    mask-image: radial-gradient(ellipse at 70% 30%, #000 30%, transparent 75%);
}
.hero h1 { color: #fff; font-size: clamp(2rem, 6vw, 3.4rem); font-weight: 700; line-height: 1.05; }
.hero .lead { color: rgba(255,255,255,.8); max-width: 36rem; }
.hero .eyebrow { color: var(--amber); text-transform: uppercase; letter-spacing: .18em; font-size: .78rem; font-weight: 600; }

/* ---------- Cards & layout ---------- */
.app-main { padding: 1.75rem 0 4rem; }
.page-head { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.55rem; margin: 0; }
.eyebrow-sm { text-transform: uppercase; letter-spacing: .14em; font-size: .72rem; color: var(--muted); font-weight: 600; }

.card-x {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card-x .card-x-head { padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: .75rem; }
.card-x .card-x-body { padding: 1.25rem; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .9rem; }
.stat {
    background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 1.1rem 1.2rem; position: relative; overflow: hidden;
}
.stat::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--amber); }
.stat .v { font-family: 'Space Grotesk', sans-serif; font-size: 1.9rem; font-weight: 700; line-height: 1; }
.stat .l { color: var(--muted); font-size: .82rem; margin-top: .35rem; }

/* ---------- Buttons ---------- */
.btn-primary { background: var(--ink); border-color: var(--ink); font-weight: 600; }
.btn-primary:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn-amber { background: var(--amber); border-color: var(--amber); color: var(--ink); font-weight: 700; }
.btn-amber:hover { background: var(--amber-dark); border-color: var(--amber-dark); color: #fff; }
.btn-outline-dark { border-color: var(--line-strong); }

/* ---------- Auth pages ---------- */
.auth-wrap { min-height: calc(100vh - 60px); display: grid; grid-template-columns: 1fr; }
.auth-card { max-width: 460px; margin: 2.5rem auto; width: 100%; padding: 0 1rem; }
.auth-card .card-x-body { padding: 1.6rem; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg a { padding: .35rem .9rem; font-size: .85rem; font-weight: 600; color: var(--muted); }
.seg a.active { background: var(--ink); color: #fff; }

/* ---------- Tables / BOQ ---------- */
.table-x { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table-x th { text-align: left; font-weight: 600; color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; padding: .6rem .7rem; border-bottom: 1px solid var(--line-strong); }
.table-x td { padding: .6rem .7rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table-x tr:last-child td { border-bottom: none; }
.table-x .r { text-align: right; }
.stage-row td { background: var(--ink); color: #fff; font-family: 'Space Grotesk', sans-serif; font-weight: 600; }
.stage-row .stage-no { color: var(--amber); margin-right: .6rem; font-variant-numeric: tabular-nums; }
.stage-subtotal td { background: #eef2f7; font-weight: 600; }

.pill { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .74rem; font-weight: 600; }
.pill-green { background: var(--green-soft); color: var(--green); }
.pill-red { background: var(--red-soft); color: var(--red); }
.pill-muted { background: #eef2f7; color: var(--muted); }
.pill-amber { background: rgba(232,161,59,.16); color: var(--amber-dark); }

/* cost distribution bar */
.dist { display: flex; height: 12px; border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.dist span { display: block; height: 100%; }

.rating-bar { height: 8px; background: #eef2f7; border-radius: 999px; overflow: hidden; }
.rating-bar i { display: block; height: 100%; background: var(--amber); }

.flash { border-left: 4px solid var(--green); background: var(--green-soft); padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; color: #1d5e42; }

.footer { background: var(--ink); color: rgba(255,255,255,.6); padding: 1.5rem 0; font-size: .85rem; margin-top: auto; }

label.form-label { font-weight: 600; font-size: .85rem; }
.text-muted-2 { color: var(--muted); }
.hint { font-size: .8rem; color: var(--muted); }

@media (max-width: 575px) {
    .stat .v { font-size: 1.5rem; }
    .table-responsive-sm { overflow-x: auto; }
}
