/* ============================================================
   BuildTrack UI - Construction Management System
   Design language: dark navy rail + neutral canvas + orange accent.
   ============================================================ */

:root {
    --ink: #0b0c0e;
    --sidebar: #15223c;
    --sidebar-soft: #20314f;
    --accent: #ff6a2b;
    --accent-soft: #fff1ea;
    --bg: #f0f1f4;
    --card: #ffffff;
    --line: #e6e8ec;
    --line-soft: #f0f1f4;
    --text: #16181d;
    --muted: #6b7280;
    --green: #04815a;
    --green-soft: #e6f6ef;
    --red: #c62828;
    --red-soft: #fdecec;
    --amber: #b26a00;
    --amber-soft: #fff4e0;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .05);
    --sidebar-w: 252px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

h1 { font-size: 25px; font-weight: 700; letter-spacing: -.02em; margin: 0 0 6px; }
h2 { font-size: 16px; font-weight: 600; letter-spacing: -.01em; margin: 0 0 14px; }
h3 { font-size: 14px; font-weight: 600; margin: 0 0 10px; }
p  { margin: 0 0 10px; }

/* ---------------- Side rail ---------------- */

.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--sidebar);
    color: #cfd8e8;
    display: flex;
    flex-direction: column;
    padding: 18px 14px;
    overflow-y: auto;
    z-index: 20;
}

.side-brand { display: flex; align-items: center; padding: 2px 8px 14px; }

/* The supplied logo is a transparent PNG, so it sits straight on the navy rail. */
.brand-logo {
    display: block;
    height: 30px;
    width: auto;
    max-width: 100%;
}

.side-nav { flex: 1; display: flex; flex-direction: column; gap: 0; }

.nav-cap {
    margin: 12px 10px 1px;
    font-size: 10px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: #71829f;
}

.side-nav .nav-cap:first-child { margin-top: 0; }

.side-nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 10px;
    line-height: 1.25;
    border-radius: 10px;
    font-size: 13.5px;
    color: #c3cede;
    transition: background .15s, color .15s;
}

.side-nav a svg { width: 16px; height: 16px; flex: none; opacity: .7; }
.side-nav a:hover { background: var(--sidebar-soft); color: #fff; }
.side-nav a:hover svg { opacity: 1; }
.side-nav a.active { background: var(--accent); color: #fff; font-weight: 600; }
.side-nav a.active svg { opacity: 1; }

.side-user {
    display: flex; align-items: center; gap: 10px;
    margin-top: 14px; padding: 14px 10px 12px;
    border-top: 1px solid rgba(255, 255, 255, .09);
}

.avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--sidebar-soft);
    color: #fff;
    display: grid; place-items: center;
    flex: none;
}

.avatar svg { width: 15px; height: 15px; }
.side-user strong { display: block; color: #fff; font-size: 13px; }
.side-user small  { display: block; color: #8ea0bd; font-size: 11px; }

/* ---------------- Top bar ---------------- */

.topbar {
    position: sticky; top: 0;
    margin-left: var(--sidebar-w);
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px;
    padding: 13px 28px;
    background: rgba(255, 255, 255, .88);
    backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--line);
    z-index: 15;
}

.topbar h2 { margin: 0; font-size: 17px; letter-spacing: -.01em; }
.topbar small { color: var(--muted); font-size: 12px; }
.top-actions { display: flex; align-items: center; gap: 10px; }

.bell {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 13px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    font-size: 13px; font-weight: 500;
    white-space: nowrap;
}

.bell:hover { border-color: #c9ced6; }

.badge {
    display: inline-grid; place-items: center;
    min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 999px;
    background: var(--accent); color: #fff;
    font-size: 11px; font-weight: 700;
}

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

.container {
    margin-left: var(--sidebar-w);
    max-width: 1240px;
    padding: 26px 28px 60px;
}

.page-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 16px; flex-wrap: wrap;
    margin-bottom: 18px;
}

.page-head h1 { font-size: 24px; }
.page-head p  { margin: 0; color: var(--muted); }

/* ---------------- Cards, grids, stats ---------------- */

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 18px;
}

.grid { display: grid; gap: 16px; margin-bottom: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid .card { margin-bottom: 0; }

.stat {
    position: relative;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
}

.stat .label {
    font-size: 10.5px; font-weight: 600;
    letter-spacing: .1em; text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 10px;
    padding-right: 30px;
}

.stat .value { font-size: 30px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; }

.stat::after {
    content: '';
    position: absolute; top: 16px; right: 16px;
    width: 22px; height: 22px;
    border-radius: 7px;
    background: var(--accent-soft);
}

.stat.good::after { background: var(--green-soft); }
.stat.warn::after { background: var(--amber-soft); }
.stat.bad::after  { background: var(--red-soft); }
.stat.good .value { color: var(--green); }
.stat.warn .value { color: var(--amber); }
.stat.bad .value  { color: var(--red); }

/* ---------------- Buttons ---------------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: var(--ink); color: #fff;
    font-family: inherit; font-size: 13.5px; font-weight: 600;
    cursor: pointer;
    transition: opacity .15s, background .15s, border-color .15s;
    margin: 0 6px 6px 0;
}

.btn:hover { opacity: .88; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-outline { background: #fff; color: var(--text); border-color: var(--line); }
.btn-outline:hover { background: #fafbfc; border-color: #b9c0cb; opacity: 1; }
.btn-amber { background: var(--accent); }
.btn-danger { background: var(--red-soft); color: var(--red); border-color: #f6d5d5; }
.btn-danger:hover { background: var(--red); color: #fff; opacity: 1; }
.btn-ghost {
    width: 100%;
    background: transparent; color: #c3cede;
    border-color: rgba(255, 255, 255, .18);
    margin: 0;
}
.btn-ghost:hover { background: rgba(255, 255, 255, .08); color: #fff; opacity: 1; }

/* ---------------- Tables ---------------- */

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

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

th {
    text-align: left;
    padding: 10px 12px;
    font-size: 10.5px; font-weight: 600;
    letter-spacing: .09em; text-transform: uppercase;
    color: var(--muted);
    background: #fafbfc;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

td { padding: 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfc; }

/* ---------------- Forms ---------------- */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12.5px; font-weight: 600; color: #38404d; }

input, select, textarea {
    width: 100%;
    font-family: inherit; font-size: 13.5px;
    padding: 10px 12px;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--ink);
    box-shadow: 0 0 0 3px rgba(11, 12, 14, .07);
}

input[type=checkbox], input[type=radio] { width: auto; }
textarea { min-height: 88px; resize: vertical; }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0 16px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.actions .btn { margin: 0; }
.actions select, .actions input { width: auto; min-width: 130px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.checkbox-row input { width: auto; }
.checkbox-row label { font-size: 13px; font-weight: 500; }

/* ---------------- Pills, alerts, progress ---------------- */

.pill {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 10px;
    border-radius: 999px;
    background: #f1f2f5; color: #45505f;
    font-size: 11.5px; font-weight: 600;
    white-space: nowrap;
}

.pill.good { background: var(--green-soft); color: var(--green); }
.pill.warn { background: var(--amber-soft); color: var(--amber); }
.pill.bad  { background: var(--red-soft); color: var(--red); }

.progress { height: 8px; margin: 10px 0; border-radius: 999px; background: #eceef2; overflow: hidden; }
.progress span { display: block; height: 100%; border-radius: 999px; background: var(--green); }
.progress.amber span { background: var(--accent); }

.alert {
    padding: 12px 14px;
    margin-bottom: 16px;
    border: 1px solid;
    border-radius: 12px;
    font-size: 13.5px; font-weight: 500;
}

.alert-success { background: var(--green-soft); border-color: #c8ebdb; color: #04654a; }
.alert-error   { background: var(--red-soft); border-color: #f6d5d5; color: #a51f1f; }
.error-text { color: var(--red); font-size: 12px; font-weight: 500; }
.empty { margin: 0; padding: 14px 0; color: var(--muted); font-size: 13.5px; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.gallery img { display: block; width: 100%; border: 1px solid var(--line); border-radius: 12px; }

.card ul { margin: 0; padding: 0; list-style: none; }
.card li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.card li:last-child { border-bottom: none; }

.inline { display: inline; }

.footer {
    margin-left: var(--sidebar-w);
    padding: 20px 28px 34px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
}

/* ---------------- Sign in / register ---------------- */

.auth-wrap {
    min-height: 100vh;
    display: grid; place-items: center;
    padding: 24px;
    background: radial-gradient(1200px 600px at 20% -10%, #22355a 0, #15223c 55%, #0f1929 100%);
}

.auth-card {
    width: 100%; max-width: 400px;
    padding: 32px;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(6, 12, 24, .35);
}

.auth-card h1 { font-size: 22px; margin-bottom: 2px; }
.auth-card .sub { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.auth-card .btn { margin: 6px 0 0; }
.auth-links { display: flex; justify-content: space-between; gap: 12px; margin-top: 16px; font-size: 12.5px; }
.auth-links a { color: var(--muted); font-weight: 500; }
.auth-links a:hover { color: var(--ink); }

.demo-note {
    margin-top: 20px; padding: 12px;
    background: #f6f7f9;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--muted);
    font-size: 11.5px; line-height: 1.6;
}

/* ---------------- Responsive ---------------- */

@media (max-width: 1100px) {
    .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
    .sidebar { position: static; width: 100%; }
    .container, .topbar, .footer { margin-left: 0; }
    .topbar { position: static; }
    .side-nav { flex-direction: row; overflow-x: auto; padding-bottom: 4px; }
    .side-nav a { white-space: nowrap; }
    .nav-cap { display: none; }
}

@media (max-width: 720px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .container { padding: 20px 16px 48px; }
    .topbar { padding: 12px 16px; }
}
