:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --text: #172033;
    --muted: #667085;
    --border: #e4e9f1;
    --primary: #166534;
    --primary-strong: #14532d;
    --primary-soft: #ecfdf3;
    --danger: #b42318;
    --danger-soft: #fef3f2;
    --warning: #b54708;
    --warning-soft: #fffaeb;
    --shadow: 0 10px 30px rgba(15, 23, 42, .07);
    --radius: 18px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
}
a { color: inherit; }
button, input, select, textarea { font: inherit; }

.login-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(420px, .95fr);
}
.login-brand {
    padding: 64px;
    background: linear-gradient(145deg, #0f3d24 0%, #166534 55%, #1e7a42 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.brand-mark {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
    letter-spacing: .02em;
}
.brand-logo {
    display: block;
    max-width: min(240px, 62vw);
    max-height: 90px;
    width: auto;
    height: auto;
    object-fit: contain;
    object-position: left center;
}
.brand-dot {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: rgba(255,255,255,.16);
    border: 1px solid rgba(255,255,255,.28);
    display: grid;
    place-items: center;
}
.login-copy { max-width: 660px; }
.login-copy h1 {
    font-size: clamp(38px, 5vw, 68px);
    line-height: 1.02;
    margin: 0 0 20px;
    letter-spacing: -.04em;
}
.login-copy p {
    margin: 0;
    font-size: 18px;
    line-height: 1.7;
    color: rgba(255,255,255,.82);
}
.login-note { color: rgba(255,255,255,.68); font-size: 13px; }

.login-panel {
    background: var(--surface);
    display: grid;
    place-items: center;
    padding: 40px;
}
.login-card { width: min(440px, 100%); }
.eyebrow {
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .12em;
}
.login-card h2 {
    margin: 10px 0 8px;
    font-size: 32px;
    letter-spacing: -.03em;
}
.login-card > p {
    color: var(--muted);
    margin: 0 0 28px;
    line-height: 1.6;
}

.field { margin-bottom: 18px; }
.field label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 7px;
}
.field input,
.field textarea,
.field select {
    width: 100%;
    border: 1px solid #d0d5dd;
    border-radius: 11px;
    padding: 12px 13px;
    color: var(--text);
    background: #fff;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.field textarea { min-height: 96px; resize: vertical; }
.company-picker {
    position: relative;
    width: min(100%, 560px);
}
.company-picker summary {
    min-height: 42px;
    display: flex;
    align-items: center;
    padding: 8px 36px 8px 10px;
    border: 1px solid #d0d5dd;
    border-radius: 11px;
    background: #fff;
    color: var(--text);
    cursor: pointer;
    list-style: none;
    position: relative;
}
.company-picker summary::-webkit-details-marker { display: none; }
.company-picker summary::after {
    content: "▾";
    position: absolute;
    right: 12px;
    color: var(--muted);
}
.company-picker[open] summary {
    border-color: #4d8e64;
    box-shadow: 0 0 0 4px rgba(22,101,52,.09);
}
.company-picker-menu {
    position: absolute;
    z-index: 20;
    top: calc(100% + 6px);
    left: 0;
    width: min(760px, calc(100vw - 48px));
    max-height: 280px;
    overflow-y: auto;
    padding: 8px;
    border: 1px solid #d0d5dd;
    border-radius: 11px;
    background: #fff;
    box-shadow: 0 14px 32px rgba(16,24,40,.14);
}
.company-picker-menu-static {
    position: static;
    width: min(760px, 100%);
    box-shadow: none;
}
.form-grid-spaced { margin-top: 20px; }
.field-actions-bottom {
    align-self: end;
    display: flex;
    align-items: flex-end;
}
.company-picker-option {
    display: flex !important;
    gap: 10px;
    align-items: flex-start;
    margin: 0 !important;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500 !important;
}
.company-picker-option:hover { background: #f5f7f8; }
.company-picker-option input {
    width: auto;
    margin-top: 3px;
    padding: 0;
}
.company-picker-option span { min-width: 0; }
.company-picker-option strong {
    display: block;
    font-size: 14px;
}
.company-picker-option small {
    margin-top: 2px !important;
    font-size: 12px;
}
.field input:focus,
.field textarea:focus,
.field select:focus {
    border-color: #4d8e64;
    box-shadow: 0 0 0 4px rgba(22,101,52,.09);
}
.field small { display: block; color: var(--muted); margin-top: 6px; line-height: 1.45; }

.btn {
    border: 0;
    border-radius: 11px;
    padding: 11px 16px;
    font-weight: 750;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-strong); }
.btn-secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-block { width: 100%; }

.alert {
    border-radius: 12px;
    padding: 12px 14px;
    margin: 0 0 18px;
    font-size: 14px;
    line-height: 1.5;
}
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-success { background: var(--primary-soft); color: var(--primary); }
.alert-warning { background: var(--warning-soft); color: var(--warning); }

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
}
.sidebar {
    background: #102a1b;
    color: #fff;
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
}
.sidebar .brand-mark { padding: 6px 8px 26px; }
.nav { display: grid; gap: 6px; }
.nav a {
    text-decoration: none;
    color: rgba(255,255,255,.76);
    padding: 10px 12px;
    border-radius: 10px;
    font-weight: 650;
    font-size: 14px;
}
.nav a:hover,
.nav a.active {
    background: rgba(255,255,255,.10);
    color: #fff;
}
.sidebar-footer {
    margin-top: auto;
    padding: 18px 8px 4px;
    color: rgba(255,255,255,.58);
    font-size: 12px;
}

.main { min-width: 0; padding: 28px 32px 46px; }
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 28px;
}
.topbar h1 { margin: 0; font-size: 28px; letter-spacing: -.025em; }
.topbar p { margin: 5px 0 0; color: var(--muted); font-size: 14px; }
.userbox { display: flex; align-items: center; gap: 12px; }
.user-meta { text-align: right; }
.user-meta strong { display: block; font-size: 13px; }
.user-meta span { color: var(--muted); font-size: 12px; }
.logout-form { margin: 0; }

.cards {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.metric,
.card,
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.metric { padding: 20px; }
.metric .label { color: var(--muted); font-size: 13px; font-weight: 650; }
.metric .value { font-size: 31px; font-weight: 850; margin-top: 8px; letter-spacing: -.03em; }

.modules {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}
.card {
    padding: 20px;
    min-height: 180px;
    display: flex;
    flex-direction: column;
}
.card h3 { margin: 12px 0 8px; font-size: 17px; }
.card p { color: var(--muted); margin: 0; line-height: 1.55; font-size: 14px; }
.card .actions { margin-top: auto; padding-top: 18px; }

.badge {
    display: inline-flex;
    width: max-content;
    border-radius: 999px;
    padding: 5px 9px;
    font-size: 11px;
    font-weight: 800;
}
.badge-live { background: var(--primary-soft); color: var(--primary); }
.badge-next { background: #eef2ff; color: #3538cd; }
.badge-pending { background: var(--warning-soft); color: var(--warning); }

.panel { padding: 22px; }
.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
}
.panel-head h2 { margin: 0; font-size: 20px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
    padding: 13px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
th {
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    font-size: 11px;
}
tr:last-child td { border-bottom: 0; }
.empty { text-align: center; padding: 44px 20px; color: var(--muted); }

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2px 18px;
}
.form-actions { display: flex; gap: 10px; margin-top: 22px; }
.color-row {
    display: grid;
    grid-template-columns: 90px 1fr;
    gap: 10px;
    align-items: center;
}
.color-row input[type="color"] { height: 44px; padding: 4px; }

.logo-preview,
.logo-placeholder {
    min-height: 110px;
    border: 1px dashed #d0d5dd;
    border-radius: 12px;
    background: var(--surface-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    padding: 14px;
}

.logo-preview img {
    display: block;
    max-width: 100%;
    max-height: 110px;
    object-fit: contain;
}

.logo-placeholder {
    color: var(--muted);
    font-size: 13px;
}

.muted { color: var(--muted); }

@media (max-width: 1050px) {
    .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .modules { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
    .login-shell { grid-template-columns: 1fr; }
    .login-brand { display: none; }
    .login-panel { min-height: 100vh; padding: 24px; }
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .main { padding: 20px 16px 34px; }
    .topbar { align-items: flex-start; }
    .user-meta { display: none; }
    .cards, .modules, .form-grid { grid-template-columns: 1fr; }
}
