:root {
    --bg: #f4f7f3;
    --panel: #ffffff;
    --ink: #1b2b23;
    --muted: #647067;
    --line: #dce5dc;
    --green: #1f7a4d;
    --green-dark: #145d3a;
    --mint: #d9f0df;
    --gold: #d7a840;
    --danger: #b42318;
    --shadow: 0 18px 45px rgba(22, 65, 43, .12);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--ink);
}

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

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(135deg, rgba(31,122,77,.92), rgba(20,93,58,.88)),
        radial-gradient(circle at 20% 20%, rgba(215,168,64,.24), transparent 32%),
        var(--bg);
}

.login-card, .install-card {
    width: min(100%, 460px);
    background: var(--panel);
    border: 1px solid rgba(255,255,255,.7);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 30px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--green), var(--gold));
    color: #fff;
    font-weight: 800;
}

.eyebrow {
    color: var(--green);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    margin: 0 0 8px;
}

h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 30px; line-height: 1.08; margin-bottom: 12px; }
h2 { font-size: 22px; margin-bottom: 12px; }
h3 { font-size: 16px; margin-bottom: 6px; }
.muted { color: var(--muted); }

label {
    display: grid;
    gap: 7px;
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 14px;
}

input, select {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    font: inherit;
    color: var(--ink);
    background: #fff;
}

select {
    cursor: pointer;
}

button, .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border: 0;
    border-radius: 10px;
    padding: 10px 14px;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.primary {
    background: var(--green);
    color: #fff;
}

.secondary {
    background: var(--mint);
    color: var(--green-dark);
}

.danger { color: var(--danger); }
.full { width: 100%; }

.flash {
    border-radius: 12px;
    padding: 12px 14px;
    margin: 0 0 16px;
    font-weight: 700;
}
.flash.error { background: #fde8e6; color: #9f1d15; }
.flash.success { background: #e4f7e9; color: #17653f; }
.flash.info { background: #edf4ff; color: #27456b; }

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px 1fr;
}

.sidebar {
    background: linear-gradient(180deg, #116c53, #0e593f);
    color: #fff;
    padding: 22px;
}

.sidebar .brand { margin-bottom: 28px; }
.sidebar .brand-mark { background: rgba(255,255,255,.16); }
.sidebar small { color: rgba(255,255,255,.72); }

.nav {
    display: grid;
    gap: 14px;
}

.nav a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 10px;
    color: rgba(255,255,255,.86);
    font-weight: 750;
    font-size: 14px;
}

.nav a.active, .nav a:hover {
    background: rgba(255,255,255,.14);
    color: #fff;
}

.nav a.inactive {
    opacity: .58;
}

.nav a small {
    color: rgba(255,255,255,.72);
    font-size: 11px;
    font-weight: 800;
}

.nav-group {
    display: grid;
    gap: 5px;
}

.nav-group p {
    color: rgba(255,255,255,.62);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .08em;
    margin: 7px 0 1px;
    text-transform: uppercase;
}

.main {
    padding: 28px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.tenant-switch {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(24, 56, 38, .06);
    padding: 18px;
}

.module-card {
    display: grid;
    gap: 10px;
}

.page-section {
    margin-bottom: 18px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.form-grid label {
    margin-bottom: 0;
}

.form-grid button {
    align-self: end;
}

td select {
    min-width: 150px;
}

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

.module-toggle {
    cursor: pointer;
}

.module-toggle input {
    width: auto;
    min-height: auto;
    margin-right: 8px;
}

.compact-check {
    width: 20px;
    min-height: 20px;
    accent-color: var(--green);
}

.spacer-top {
    margin-top: 16px;
}

.module-preview-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 18px;
}

.module-preview-grid article {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px;
    background: #fbfdfb;
}

.module-preview-grid strong,
.module-preview-grid span {
    display: block;
}

.module-preview-grid span {
    color: var(--muted);
    margin-top: 6px;
}

.badge {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 800;
    background: #eef2ee;
    color: var(--muted);
}
.badge.active { background: var(--mint); color: var(--green-dark); }
.badge.trial { background: #fff4d6; color: #795b0b; }

.stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.stat strong {
    display: block;
    font-size: 30px;
    line-height: 1;
}

table {
    width: 100%;
    border-collapse: collapse;
}
th, td {
    text-align: left;
    border-bottom: 1px solid var(--line);
    padding: 12px 10px;
}
th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

@media (max-width: 860px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: sticky;
        top: 0;
        z-index: 5;
        padding: 12px;
    }
    .sidebar .brand { margin-bottom: 10px; }
    .nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
        max-height: 42vh;
        overflow: auto;
    }
    .nav-group { gap: 4px; }
    .nav-group p { margin-top: 4px; }
    .nav a {
        justify-content: center;
        padding: 9px 8px;
        font-size: 13px;
    }
    .nav a small { display: none; }
    .main { padding: 18px; }
    .topbar { align-items: flex-start; flex-direction: column; }
    .grid, .stats { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .module-preview-grid { grid-template-columns: 1fr; }
}
