:root {
    --bg: #f6f7fb;
    --card: #ffffff;
    --text: #182230;
    --muted: #64748b;
    --line: #d9e1ec;
    --primary: #0f766e;
    --primary-dark: #115e59;
    --danger: #b42318;
    --gain: #067647;
    --warning: #b54708;
    --shadow: 0 12px 30px rgba(15, 23, 42, .08);
}

* {
    box-sizing: border-box;
}

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

a {
    color: var(--primary);
    text-decoration: none;
}

h1, h2 {
    margin: 0;
    line-height: 1.1;
}

h1 {
    font-size: 28px;
}

h2 {
    font-size: 18px;
    margin-bottom: 16px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 24px;
    background: rgba(255, 255, 255, .94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(10px);
}

.brand {
    display: block;
    color: var(--text);
    font-weight: 800;
    font-size: 18px;
}

.subtitle, .muted, small {
    color: var(--muted);
}

.nav {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.nav a {
    color: var(--muted);
    padding: 8px 10px;
    border-radius: 8px;
    font-weight: 650;
}

.nav a.active, .nav a:hover {
    color: var(--primary);
    background: #e6f4f1;
}

.container {
    width: min(1180px, calc(100% - 32px));
    margin: 28px auto 48px;
}

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

.page-head p {
    margin: 8px 0 0;
    color: var(--muted);
}

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

.metric, .panel, .auth-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.metric {
    padding: 18px;
}

.metric span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 8px;
}

.metric strong {
    font-size: 25px;
}

.metric.negative strong, .loss {
    color: var(--danger);
}

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

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

.align-start {
    align-items: start;
}

.panel {
    padding: 18px;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 620px;
}

th, td {
    padding: 11px 10px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

tr:last-child td {
    border-bottom: 0;
}

.stack, .form-card {
    display: grid;
    gap: 14px;
}

label {
    display: grid;
    gap: 7px;
    color: #344054;
    font-weight: 650;
}

input, select, textarea {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 11px 12px;
    color: var(--text);
    background: #fff;
    font: inherit;
}

textarea {
    resize: vertical;
}

button, .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 14px;
    border: 0;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font: inherit;
    font-weight: 750;
    cursor: pointer;
}

button:hover, .button:hover {
    background: var(--primary-dark);
    color: #fff;
}

button:disabled {
    cursor: not-allowed;
    opacity: .55;
}

.button.secondary {
    background: #eef2f7;
    color: #243447;
}

.button.secondary:hover {
    background: #dce4ee;
    color: #243447;
}

.button.full {
    width: 100%;
}

.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.row-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.row-actions form {
    margin: 0;
}

.link {
    min-height: auto;
    padding: 0;
    color: var(--primary);
    background: transparent;
    border: 0;
    font-weight: 650;
}

.link:hover {
    color: var(--primary-dark);
    background: transparent;
}

.alert {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    border: 1px solid #b7dbc8;
    color: #075c36;
    background: #ecfdf3;
}

.alert.danger {
    border-color: #f6c7c2;
    color: var(--danger);
    background: #fff0ee;
}

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
    background: linear-gradient(140deg, #eefcf8 0%, #f6f7fb 55%, #eef2f7 100%);
}

.auth-card {
    width: min(440px, 100%);
    padding: 24px;
}

.auth-card h1 {
    margin-bottom: 8px;
}

.filters {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 12px;
    align-items: end;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 18px;
}

.pill {
    display: inline-flex;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 750;
}

.pill.on {
    color: #075c36;
    background: #dcfae6;
}

.pill.off {
    color: #667085;
    background: #eef2f7;
}

.empty {
    color: var(--muted);
    margin: 0;
}

.mini-list {
    display: grid;
    gap: 10px;
}

.mini-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
}

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

.calc-preview div {
    padding: 12px;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid var(--line);
}

.calc-preview span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 4px;
}

@media (max-width: 860px) {
    .topbar, .page-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .metrics, .grid-2, .filters, .calc-preview {
        grid-template-columns: 1fr;
    }

    .container {
        width: min(100% - 20px, 1180px);
        margin-top: 18px;
    }

    .metric strong {
        font-size: 22px;
    }
}

.password-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: stretch;
}

.password-row input {
    min-height: 44px;
}

.toggle-password {
    min-width: 64px;
    background: #eef2f7;
    color: #243447;
}

.toggle-password:hover {
    background: #dce4ee;
    color: #243447;
}
