/* Sales CRM - shared theme (matches NG Advantage Capital Projects app) */

:root {
    --blue: #134596;
    --blue-dark: #0d3169;
    --blue-deep: #0b295a;
    --logo-blue: #327ebd;
    --green: #0a652e;
    --green-action: #2e7d32;
    --green-dark: #1b5e20;
    --red: #ea1f26;
    --orange: #fd7e14;
    --soft-blue: #9dc2ff;
    --white: #ffffff;
    --off-white: #f5f7fa;
    --border: #e2e8f0;
    --gray: #64748b;
    --text: #0f172a;
    --row-hover: #f8fafc;
    --font: "Outfit", system-ui, -apple-system, sans-serif;
    --mono: "JetBrains Mono", monospace;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --topbar-bg: linear-gradient(135deg, var(--blue-deep) 0%, var(--blue-dark) 100%);
}

:root[data-theme="dark"] {
    --white: #1e293b;
    --off-white: #0f172a;
    --border: #334155;
    --gray: #94a3b8;
    --text: #f8fafc;
    --row-hover: #0f172a;
    --blue-deep: #f8fafc;
    --blue: #38bdf8;
    --blue-dark: #0284c7;
    --soft-blue: #93c5fd;
    --green-action: #4ade80;
    --green-dark: #22c55e;
    --orange: #fb923c;
    --red: #f87171;
    --topbar-bg: linear-gradient(135deg, #0b1329 0%, #1e293b 100%);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background: var(--off-white);
    color: var(--text);
    font-family: var(--font);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---------- Top bar ---------- */
.topbar {
    background: var(--topbar-bg);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 24px;
    height: 64px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-md);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo-section { display: flex; align-items: center; gap: 14px; }
.logo-link { display: flex; align-items: center; text-decoration: none; }
.logo-section .ng-st0 { fill: #327ebd; }
.logo-section .ng-st1 { fill: #fff; }
.logo-section .ng-st2 { fill: #ea1f26; }
.logo-divider { font-size: 20px; font-weight: 700; color: rgba(255,255,255,0.35); user-select: none; }
.app-name { font-size: 18px; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; color: #fff; white-space: nowrap; }

.nav { display: flex; gap: 8px; }

.nav a {
    text-decoration: none;
    color: #b8cff5;
    font-size: 14px;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.nav a svg { width: 16px; height: 16px; }
.nav a.active {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.1);
}
.nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.08);
    padding: 6px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.1);
    white-space: nowrap;
}
.user-profile svg { width: 16px; height: 16px; }
.user-profile .icon-soft { color: var(--soft-blue); }
.user-profile .user-name { font-weight: 700; color: var(--soft-blue); }
.user-profile a {
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    opacity: 0.85;
    display: inline-flex;
    align-items: center;
    transition: var(--transition);
}
.user-profile a:hover { opacity: 1; }
.user-profile .sep { color: rgba(255, 255, 255, 0.25); }

/* ---------- Layout ---------- */
.wrap {
    max-width: 1280px;
    margin: 0 auto;
    padding: 32px 24px;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

h1 {
    font-size: 28px;
    color: var(--blue-deep);
    font-weight: 800;
    margin-bottom: 24px;
    letter-spacing: -0.02em;
}
h1 .muted { font-size: 14px; font-weight: 400; color: var(--gray); margin-left: 12px; }
h2 { font-size: 18px; color: var(--blue-deep); font-weight: 700; margin-bottom: 16px; }
.muted { color: var(--gray); }
.mono { font-family: var(--mono); }

.grid2 { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; }
@media (max-width: 992px) { .grid2 { grid-template-columns: 1fr; } }

/* ---------- KPI cards ---------- */
.kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.kpi {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}
.kpi::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 4px;
    background: var(--blue);
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.kpi .v { font-size: 28px; font-weight: 800; color: var(--blue-deep); line-height: 1.2; }
.kpi .l {
    font-size: 11px;
    color: var(--gray);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 6px;
}
.kpi.good::before { background: var(--green-action); }
.kpi.good .v { color: var(--green-action); }
.kpi.warn::before { background: var(--orange); }
.kpi.warn .v { color: var(--orange); }
.kpi.bad::before { background: var(--red); }
.kpi.bad .v { color: var(--red); }

/* ---------- Cards ---------- */
.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

/* ---------- Tables ---------- */
.table-container { width: 100%; overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th {
    text-align: left;
    color: var(--gray);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 12px 16px;
    border-bottom: 2px solid var(--border);
}
td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    color: var(--text);
}
tr.clickable { cursor: pointer; transition: var(--transition); }
tr.clickable:hover td { background: var(--row-hover); }

/* ---------- Buttons ---------- */
.btn {
    border: 0;
    border-radius: var(--radius-sm);
    padding: 10px 20px;
    color: #fff;
    background: var(--blue);
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: var(--blue-dark); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn.green { background: var(--green-action); }
.btn.green:hover { background: var(--green-dark); }
.btn.orange { background: var(--orange); }
.btn.orange:hover { background: #d96608; }
.btn.red { background: var(--red); }
.btn.red:hover { background: #c5141b; }
.btn.ghost { background: transparent; color: var(--blue); border: 1.5px solid var(--blue); }
.btn.ghost:hover { background: rgba(19, 69, 150, 0.05); }
.btn.sm { padding: 6px 12px; font-size: 11px; }

/* ---------- Badges / status ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    background: var(--off-white);
    border: 1px solid var(--border);
    color: var(--gray);
}
.badge svg { width: 14px; height: 14px; }
.badge.good { color: var(--green-action); border-color: var(--green-action); }
.badge.bad  { color: var(--red); border-color: var(--red); }

/* ---------- Forms ---------- */
label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}
input, select, textarea {
    width: 100%;
    font-family: inherit;
    font-size: 14px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--white);
    color: var(--text);
    transition: var(--transition);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(19, 69, 150, 0.12);
}

/* ---------- Responsive top bar ---------- */
@media (max-width: 1100px) {
    .nav a { padding: 8px 10px; }
    .nav a span.label { display: none; }
}
@media (max-width: 900px) {
    .topbar { height: auto; flex-wrap: wrap; padding: 12px 16px; }
    .nav { order: 3; width: 100%; overflow-x: auto; }
    .wrap { padding: 24px 16px; }
}
