/* ==================================================================
   Builders CRM
   A deliberately light interface: this is a screen people sit in front
   of all day, entering numbers. One stylesheet, no build step, no
   third-party requests.
   ================================================================== */

:root {
    /* structure */
    --nav:        #0E1A2B;
    --nav-hi:     #17293F;
    --nav-line:   #1E3247;
    --nav-text:   #A8B7C9;
    --nav-bright: #FFFFFF;

    --paper:      #F1F4F8;
    --surface:    #FFFFFF;
    --surface-2:  #F7F9FC;
    --line:       #DCE3EC;
    --line-soft:  #EAEFF5;

    --ink:        #16202D;
    --ink-2:      #4A586A;
    --ink-3:      #7B8899;

    /* actions */
    --primary:      #1B5FA8;
    --primary-dark: #164E8B;
    --primary-soft: #E7F0FA;

    /* status — meaning, not decoration */
    --emerald:      #0E7A54;
    --emerald-soft: #E2F3EC;
    --amber:        #93650B;
    --amber-soft:   #FBF0DA;
    --rose:         #AF2338;
    --rose-soft:    #FBE7EA;
    --violet:       #5A3FA6;
    --violet-soft:  #EDE9F8;
    --slate:        #5A6879;
    --slate-soft:   #EDF1F6;

    --radius:    7px;
    --radius-sm: 5px;
    --shadow:    0 1px 2px rgba(22,32,45,.06), 0 4px 12px -8px rgba(22,32,45,.24);
    --shadow-lg: 0 2px 6px rgba(22,32,45,.09), 0 14px 34px -16px rgba(22,32,45,.34);

    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --sidebar-w: 236px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 .35em; line-height: 1.25; font-weight: 650; letter-spacing: -.011em; }
h1 { font-size: 21px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }

p { margin: 0 0 .9em; }
p:last-child { margin-bottom: 0; }

.muted    { color: var(--ink-3); }
.small    { font-size: 12.5px; }
.tiny     { font-size: 11.5px; }
.mono     { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num      { font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap   { white-space: nowrap; }
.right    { text-align: right; }
.grow     { flex: 1 1 auto; min-width: 0; }
.strong   { font-weight: 650; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------------- shell ---------------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: var(--nav);
    color: var(--nav-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand {
    display: flex; align-items: center; gap: 10px;
    padding: 17px 18px;
    border-bottom: 1px solid var(--nav-line);
    color: var(--nav-bright);
    text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand .mark {
    width: 30px; height: 30px; border-radius: 6px; flex: 0 0 auto;
    background: linear-gradient(140deg, #2E7CC9, #16497F);
    color: #fff; font-weight: 700; font-size: 13px;
    display: flex; align-items: center; justify-content: center;
}
.brand .name { font-size: 14.5px; font-weight: 650; letter-spacing: -.01em; line-height: 1.2; }
.brand .sub { font-size: 11px; color: var(--nav-text); font-weight: 400; }

.nav { padding: 12px 10px 24px; }
.nav-group { margin-bottom: 16px; }
.nav-group h4 {
    font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
    color: #6C7F94; margin: 0 0 6px; padding: 0 9px; font-weight: 650;
}
.nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; margin-bottom: 1px;
    border-radius: var(--radius-sm);
    color: var(--nav-text);
    font-size: 13.5px; font-weight: 500;
    text-decoration: none;
}
.nav a:hover { background: var(--nav-hi); color: var(--nav-bright); text-decoration: none; }
.nav a.active { background: var(--primary); color: #fff; }
.nav a .ico { width: 16px; text-align: center; opacity: .85; flex: 0 0 auto; font-size: 13px; }
.nav a .tally {
    margin-left: auto; font-size: 11px; font-family: var(--mono);
    background: rgba(255,255,255,.14); padding: 1px 6px; border-radius: 9px;
}
.nav a.active .tally { background: rgba(255,255,255,.25); }

.sidebar-foot {
    margin-top: auto; padding: 12px 14px;
    border-top: 1px solid var(--nav-line);
    font-size: 11.5px; color: #6C7F94;
}

/* ---------------- topbar + content ---------------- */

.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 0 24px;
    display: flex; align-items: center; gap: 16px;
    min-height: 58px;
    position: sticky; top: 0; z-index: 20;
}
.topbar h1 { margin: 0; font-size: 17px; }
.topbar .crumb { font-size: 12px; color: var(--ink-3); margin-bottom: 1px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 9px; }

.who { display: flex; align-items: center; gap: 9px; padding-left: 14px; border-left: 1px solid var(--line); }
.who .nm { font-size: 12.5px; font-weight: 600; line-height: 1.2; }
.who .rl { font-size: 11px; color: var(--ink-3); }

.avatar {
    width: 31px; height: 31px; border-radius: 50%;
    background: var(--primary); color: #fff;
    font-size: 11.5px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
    flex: 0 0 auto; text-decoration: none;
}
.avatar.sm { width: 24px; height: 24px; font-size: 9.5px; }
.avatar.slate { background: var(--slate); }

.content { padding: 22px 24px 70px; max-width: 1500px; width: 100%; }

.linkbtn {
    background: none; border: 0; padding: 0; font: inherit; font-size: 12.5px;
    color: var(--ink-3); cursor: pointer; text-decoration: underline;
}
.linkbtn:hover { color: var(--ink); }

/* ---------------- cards ---------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 18px;
}
.card-head {
    padding: 13px 17px;
    border-bottom: 1px solid var(--line-soft);
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.card-head h2, .card-head h3 { margin: 0; font-size: 14px; }
.card-body { padding: 17px; }
.card-body > :last-child { margin-bottom: 0; }
.card-foot {
    padding: 11px 17px; border-top: 1px solid var(--line-soft);
    background: var(--surface-2); font-size: 12.5px;
    border-radius: 0 0 var(--radius) var(--radius);
}

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 18px; align-items: start; }

/* ---------------- stat tiles ---------------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 14px; margin-bottom: 20px; }

.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}
.stat::before {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
    background: var(--slate);
}
.stat.primary::before { background: var(--primary); }
.stat.emerald::before { background: var(--emerald); }
.stat.amber::before   { background: var(--amber); }
.stat.rose::before    { background: var(--rose); }
.stat.violet::before  { background: var(--violet); }

.stat .lbl { font-size: 11.5px; color: var(--ink-3); font-weight: 600; letter-spacing: .02em; margin-bottom: 5px; }
.stat .val { font-size: 23px; font-weight: 680; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat .sub { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; }
.stat.primary .val { color: var(--primary); }
.stat.emerald .val { color: var(--emerald); }
.stat.amber   .val { color: var(--amber); }
.stat.rose    .val { color: var(--rose); }
.stat.violet  .val { color: var(--violet); }

/* ---------------- tables ---------------- */

.table-wrap { overflow-x: auto; }

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td {
    text-align: left; padding: 10px 15px;
    border-bottom: 1px solid var(--line-soft); vertical-align: middle;
}
table.data thead th {
    font-size: 11px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase;
    color: var(--ink-3); background: var(--surface-2);
    border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.right, table.data th.right { text-align: right; }
table.data .ref { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }

.empty { padding: 34px 20px; text-align: center; color: var(--ink-3); }
.empty h3 { color: var(--ink-2); margin-bottom: 4px; }

/* ---------------- pills ---------------- */

.pill {
    display: inline-block; font-size: 11px; font-weight: 650;
    padding: 2.5px 9px; border-radius: 11px; white-space: nowrap;
    letter-spacing: .01em;
}
.pill-slate   { background: var(--slate-soft);   color: var(--slate); }
.pill-primary { background: var(--primary-soft); color: var(--primary); }
.pill-emerald { background: var(--emerald-soft); color: var(--emerald); }
.pill-amber   { background: var(--amber-soft);   color: var(--amber); }
.pill-rose    { background: var(--rose-soft);    color: var(--rose); }
.pill-violet  { background: var(--violet-soft);  color: var(--violet); }
.pill-solid   { background: var(--rose); color: #fff; }

/* ---------------- pipeline board ---------------- */

.pipeline {
    display: grid;
    grid-template-columns: repeat(6, minmax(190px, 1fr));
    gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: start;
}
.stage {
    background: var(--surface-2);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    min-width: 190px;
}
.stage-head {
    padding: 10px 13px; border-bottom: 1px solid var(--line-soft);
    display: flex; align-items: center; gap: 8px;
}
.stage-head .dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.stage-head h3 { margin: 0; font-size: 12px; font-weight: 650; }
.stage-head .n { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.stage-body { padding: 9px; display: flex; flex-direction: column; gap: 8px; }

.lead-card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius-sm); padding: 10px 11px;
    display: block; text-decoration: none; color: inherit;
}
.lead-card:hover { border-color: var(--primary); text-decoration: none; box-shadow: var(--shadow); }
.lead-card .nm { font-size: 13px; font-weight: 640; margin-bottom: 3px; }
.lead-card .mt { font-size: 11.5px; color: var(--ink-3); display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }

.stage-empty { padding: 12px 4px; text-align: center; color: var(--ink-3); font-size: 11.5px; }

/* ---------------- inventory grid ---------------- */

.units { display: flex; flex-wrap: wrap; gap: 7px; }
.unit-chip {
    min-width: 74px; padding: 8px 9px; border-radius: var(--radius-sm);
    border: 1px solid var(--line); background: var(--surface);
    text-decoration: none; color: inherit; text-align: center; line-height: 1.3;
}
.unit-chip:hover { text-decoration: none; box-shadow: var(--shadow); }
.unit-chip .u { font-size: 12.5px; font-weight: 650; font-family: var(--mono); }
.unit-chip .t { font-size: 10.5px; color: var(--ink-3); }
.unit-chip.available { border-color: var(--emerald); background: var(--emerald-soft); }
.unit-chip.held      { border-color: var(--amber);   background: var(--amber-soft); }
.unit-chip.booked    { border-color: var(--violet);  background: var(--violet-soft); }
.unit-chip.sold      { border-color: var(--slate);   background: var(--slate-soft); color: var(--ink-3); }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; border: 1px solid; }

/* ---------------- progress ---------------- */

.bar { height: 6px; background: var(--line-soft); border-radius: 4px; overflow: hidden; min-width: 80px; }
.bar span { display: block; height: 100%; background: var(--emerald); border-radius: 4px; }
.bar.amber span { background: var(--amber); }
.bar-row { display: flex; align-items: center; gap: 9px; }
.bar-row .pct { font-family: var(--mono); font-size: 11.5px; color: var(--ink-2); min-width: 34px; text-align: right; }

/* ---------------- forms ---------------- */

.field { margin-bottom: 15px; }
.field:last-child { margin-bottom: 0; }

label { display: block; font-size: 12.5px; font-weight: 620; margin-bottom: 5px; color: var(--ink-2); }
label .opt { font-weight: 400; color: var(--ink-3); }

input[type=text], input[type=email], input[type=password], input[type=date],
input[type=datetime-local], input[type=number], input[type=tel], input[type=search],
select, textarea {
    width: 100%; padding: 8px 11px;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--ink);
    font: inherit; font-size: 13.5px;
}
textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
input[type=file] { font-size: 12.5px; max-width: 100%; }

input:focus, select:focus, textarea:focus {
    outline: 0; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
input:disabled, select:disabled { background: var(--surface-2); color: var(--ink-3); }

.field-error { color: var(--rose); font-size: 12px; margin-top: 4px; }
.field-hint  { color: var(--ink-3); font-size: 12px; margin-top: 4px; }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 15px; }
.form-row.tight { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.input-group { display: flex; gap: 8px; align-items: stretch; }
.input-group input, .input-group select { flex: 1 1 auto; min-width: 0; }

.filters {
    display: flex; gap: 11px; align-items: flex-end; flex-wrap: wrap;
    padding: 13px 17px; background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--radius);
    margin-bottom: 18px; box-shadow: var(--shadow);
}
.filters .field { margin: 0; min-width: 150px; }
.filters label { font-size: 11.5px; }

/* ---------------- buttons ---------------- */

.btn {
    display: inline-flex; align-items: center; gap: 6px;
    font: inherit; font-size: 13px; font-weight: 620;
    padding: 8px 15px; border-radius: var(--radius-sm);
    border: 1px solid var(--primary); background: var(--primary); color: #fff;
    cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--primary-dark); border-color: var(--primary-dark); text-decoration: none; }
.btn-secondary { background: var(--surface); color: var(--ink-2); border-color: var(--line); }
.btn-secondary:hover { background: var(--surface-2); color: var(--ink); border-color: var(--ink-3); }
.btn-emerald { background: var(--emerald); border-color: var(--emerald); }
.btn-emerald:hover { filter: brightness(1.1); background: var(--emerald); border-color: var(--emerald); }
.btn-danger { background: var(--surface); color: var(--rose); border-color: var(--rose); }
.btn-danger:hover { background: var(--rose-soft); }
.btn-sm { font-size: 12px; padding: 5px 11px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.actions { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; margin-top: 18px; }

/* ---------------- alerts ---------------- */

.alert {
    padding: 11px 15px; border-radius: var(--radius-sm);
    border: 1px solid; margin-bottom: 18px; font-size: 13px;
}
.alert-success { background: var(--emerald-soft); border-color: var(--emerald); color: var(--emerald); }
.alert-error   { background: var(--rose-soft);    border-color: var(--rose);    color: var(--rose); }
.alert-info    { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.alert ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------------- detail lists ---------------- */

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px 18px; }
.fact .k { font-size: 11px; color: var(--ink-3); font-weight: 620; letter-spacing: .04em; text-transform: uppercase; margin-bottom: 2px; }
.fact .v { font-size: 13.5px; font-weight: 520; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
    display: flex; gap: 12px; padding: 12px 0;
    border-bottom: 1px solid var(--line-soft);
}
.timeline li:last-child { border-bottom: 0; }
.timeline .body { flex: 1 1 auto; min-width: 0; }
.timeline .who { font-size: 13px; font-weight: 620; }
.timeline .when { font-size: 11.5px; color: var(--ink-3); font-weight: 400; margin-left: 6px; }
.timeline .txt { font-size: 13px; color: var(--ink-2); white-space: pre-wrap; overflow-wrap: anywhere; }

.doc-row { display: flex; align-items: center; gap: 11px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.doc-row:last-child { border-bottom: 0; }
.doc-thumb { width: 38px; height: 38px; border-radius: 4px; object-fit: cover; border: 1px solid var(--line); flex: 0 0 auto; }
.doc-ext {
    width: 38px; height: 38px; border-radius: 4px; background: var(--slate-soft);
    color: var(--ink-3); font-size: 10px; font-weight: 700; text-transform: uppercase;
    display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
}

/* ---------------- sign in ---------------- */

.signin-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 30px 20px; background: var(--nav);
    background-image: radial-gradient(1100px 480px at 50% -8%, #1B3A5C 0%, transparent 62%);
}
.signin { width: 100%; max-width: 396px; }
.signin .card { box-shadow: var(--shadow-lg); margin: 0; }
.signin .card-body { padding: 28px; }
.signin-brand { text-align: center; margin-bottom: 20px; color: #fff; }
.signin-brand .mark {
    width: 46px; height: 46px; border-radius: 11px; margin: 0 auto 11px;
    background: linear-gradient(140deg, #2E7CC9, #16497F);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 17px; color: #fff;
}
.signin-brand h1 { font-size: 18px; margin: 0; color: #fff; }
.signin-brand p { font-size: 12.5px; color: #8FA1B6; margin: 2px 0 0; }

@media (max-width: 980px) {
    .split { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
    .shell { flex-direction: column; }
    .sidebar { width: 100%; flex: none; height: auto; position: static; }
    .nav { display: flex; flex-wrap: wrap; gap: 4px; padding: 10px; }
    .nav-group { margin: 0; display: contents; }
    .nav-group h4 { display: none; }
    .sidebar-foot { display: none; }
    .content { padding: 16px 14px 60px; }
    .topbar { padding: 0 14px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------------- notification bell ---------------- */

.bell {
    position: relative;
    color: var(--ink-2);
    text-decoration: none;
    font-size: 15px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    line-height: 1;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.bell:hover { background: var(--surface-2); text-decoration: none; }
.bell .count {
    background: var(--rose); color: #fff;
    font-size: 10.5px; font-weight: 700;
    border-radius: 9px; padding: 1px 6px;
    font-variant-numeric: tabular-nums;
}

.notice-row {
    display: flex; gap: 12px; padding: 13px 0;
    border-bottom: 1px solid var(--line-soft); align-items: flex-start;
}
.notice-row:last-child { border-bottom: 0; }
.notice-row.unread { background: linear-gradient(90deg, var(--primary-soft), transparent 55%); }
.notice-row .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: 0 0 auto; }

/* the brand's two lines are a stacked block, not inline text that can wrap */
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.brand .name { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand .sub { display: block; white-space: nowrap; }
