:root {
    --navy: #10233b;
    --navy-light: #16304f;
    --white: #ffffff;
    --gray-bg: #f4f5f7;
    --gray-border: #e1e4e9;
    --gray-text: #5b6472;
    --text: #1c2530;
    --accent: #2f6fed;
    --accent-dark: #1f52c0;
    --danger: #c0392b;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    color: var(--text);
    background: var(--gray-bg);
    font-size: 15px;
    line-height: 1.5;
}

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

h1, h2, h3 { font-weight: 600; letter-spacing: -0.01em; margin: 0 0 0.6em; }

/* ---- Authenticated app shell ---- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 220px;
    background: var(--navy);
    color: var(--white);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar .brand {
    padding: 24px 20px;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: 0.02em;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar .brand span { font-weight: 300; opacity: 0.85; }

.sidebar nav ul {
    list-style: none;
    margin: 0;
    padding: 12px 0;
}

.sidebar nav a {
    display: block;
    padding: 11px 20px;
    color: rgba(255,255,255,0.75);
    font-size: 14px;
}
.sidebar nav a:hover {
    background: var(--navy-light);
    color: var(--white);
    text-decoration: none;
}
.sidebar nav a.active {
    background: var(--navy-light);
    color: var(--white);
    border-left: 3px solid var(--accent);
    padding-left: 17px;
}

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

.topbar {
    background: var(--white);
    border-bottom: 1px solid var(--gray-border);
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.topbar h1 { font-size: 19px; }

.user-menu {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 14px;
    color: var(--gray-text);
}

.link-button {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 14px;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
}
.link-button:hover { text-decoration: underline; }

.content {
    padding: 28px 32px;
    flex: 1;
}

/* ---- Login / plain (unauthenticated) pages ---- */
.content-plain {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--navy);
    padding: 20px;
}

.auth-card {
    background: var(--white);
    border-radius: 6px;
    padding: 40px 36px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.25);
}

.auth-card .brand {
    font-size: 18px;
    font-weight: 600;
    color: var(--navy);
    margin-bottom: 4px;
}
.auth-card .brand span { font-weight: 300; color: var(--gray-text); }

.auth-card h1 {
    font-size: 16px;
    color: var(--gray-text);
    font-weight: 400;
    margin-bottom: 24px;
}

.auth-card p.lede {
    color: var(--gray-text);
    font-size: 13.5px;
    margin: -14px 0 22px;
}

/* ---- Forms ---- */
.field { margin-bottom: 16px; }
.field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-text);
    margin-bottom: 5px;
}
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-border);
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
}
.field input:focus, .field select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(47,111,237,0.15);
}

.btn {
    display: inline-block;
    background: var(--accent);
    color: var(--white);
    border: none;
    padding: 10px 18px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
.btn:hover { background: var(--accent-dark); }
.btn.btn-block { width: 100%; padding: 11px; }
.btn.btn-danger { background: var(--danger); }
.btn.btn-secondary { background: var(--white); color: var(--text); border: 1px solid var(--gray-border); }

.alert {
    padding: 11px 14px;
    border-radius: 4px;
    font-size: 13.5px;
    margin-bottom: 18px;
}
.alert-error { background: #fdecea; color: var(--danger); border: 1px solid #f3c6c1; }
.alert-success { background: #eaf6ec; color: #256b34; border: 1px solid #c3e6c9; }
.alert-info { background: #eaf1fd; color: var(--accent-dark); border: 1px solid #c9dbfa; }

/* ---- Tables / cards ---- */
.card {
    background: var(--white);
    border: 1px solid var(--gray-border);
    border-radius: 6px;
    padding: 24px;
    margin-bottom: 20px;
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--gray-border); }
th { color: var(--gray-text); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }

.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
}
.badge-admin { background: #eaf1fd; color: var(--accent-dark); }
.badge-employee { background: var(--gray-bg); color: var(--gray-text); }
.badge-inactive { background: #fdecea; color: var(--danger); }

.actions-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.text-muted { color: var(--gray-text); font-size: 13px; }

/* ---- CRM sub-nav ---- */
.crm-subnav {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--gray-border);
}
.crm-subnav a {
    padding: 9px 14px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--gray-text);
    border-bottom: 2px solid transparent;
}
.crm-subnav a:hover {
    color: var(--text);
    text-decoration: none;
}
.crm-subnav a.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ---- AG Grid theme override (CRM) ---- */
.crm-grid {
    margin-bottom: 20px;
    --ag-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    --ag-font-size: 14px;
    --ag-foreground-color: var(--text);
    --ag-background-color: var(--white);
    --ag-header-background-color: var(--navy);
    --ag-header-foreground-color: var(--white);
    --ag-border-color: var(--gray-border);
    --ag-row-border-color: var(--gray-border);
    --ag-row-hover-color: var(--gray-bg);
    --ag-selected-row-background-color: #eaf1fd;
    --ag-accent-color: var(--accent);
    --ag-odd-row-background-color: var(--white);
    --ag-border-radius: 6px;
    --ag-wrapper-border-radius: 6px;
    cursor: default;
}
.crm-grid .ag-row { cursor: pointer; }
