:root {
    color-scheme: light dark;
    --bg: #0f172a;
    --surface: #1e293b;
    --accent: #38bdf8;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --success: #22c55e;
}

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

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

a:hover {
    text-decoration: underline;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: rgba(15, 23, 42, 0.9);
    position: sticky;
    top: 0;
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.branding .logo {
    font-weight: 700;
    font-size: 1.5rem;
}

.branding .tagline {
    margin-left: 1rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.nav-links {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.nav-links form button {
    background: transparent;
    border: 1px solid var(--muted);
    color: var(--text);
    padding: 0.35rem 0.75rem;
    border-radius: 0.5rem;
    cursor: pointer;
}

.app-content {
    padding: 2rem;
}

.page-header h1 {
    margin: 0 0 0.5rem;
}

.page-header p {
    margin: 0;
    color: var(--muted);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.card {
    background: var(--surface);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 20px 45px rgba(2, 6, 23, 0.35);
}

.card-subtitle {
    margin-top: -0.5rem;
    color: var(--muted);
}

.integration-status {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1rem;
    color: var(--muted);
}

.status-dot {
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 50%;
    background: var(--muted);
    box-shadow: 0 0 8px rgba(15, 23, 42, 0.35);
}

.status-dot.status-ok {
    background: var(--success);
    box-shadow: 0 0 12px rgba(34, 197, 94, 0.6);
}

.status-dot.status-error {
    background: #f87171;
    box-shadow: 0 0 12px rgba(248, 113, 113, 0.6);
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

tbody tr:hover {
    background: rgba(56, 189, 248, 0.08);
}

.form-field {
    display: flex;
    flex-direction: column;
    margin-bottom: 1rem;
}

.form-field input[type="text"],
.form-field input[type="password"],
.form-field input[type="number"],
.form-field input[type="datetime-local"],
.form-field select {
    padding: 0.6rem 0.8rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(148, 163, 184, 0.3);
    background: rgba(15, 23, 42, 0.8);
    color: var(--text);
}

.form-field.checkbox {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
}

.form-field.checkbox .checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.form-field.checkbox label {
    font-weight: 500;
}

.form-field.checkbox .hint {
    margin-left: 0;
    font-size: 0.75rem;
    color: var(--muted);
}

button {
    background: var(--accent);
    border: none;
    color: #0f172a;
    font-weight: 600;
    padding: 0.75rem 1.2rem;
    border-radius: 0.6rem;
    cursor: pointer;
}

button:hover {
    filter: brightness(1.1);
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: 0.6rem;
    margin-bottom: 1rem;
}

.alert-error {
    background: rgba(248, 113, 113, 0.18);
    border: 1px solid rgba(248, 113, 113, 0.45);
    color: #fca5a5;
}

.alert.success {
    background: rgba(34, 197, 94, 0.2);
    border: 1px solid rgba(34, 197, 94, 0.4);
    color: var(--success);
    padding: 0.75rem 1rem;
    border-radius: 0.6rem;
    margin-bottom: 1rem;
}

.history-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
}

.history-controls form {
    margin: 0;
}

.last-update {
    color: var(--muted);
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
}

.range-picker {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.range-picker input {
    width: 6rem;
    padding: 0.5rem 0.6rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(148, 163, 184, 0.3);
    background: rgba(15, 23, 42, 0.8);
    color: var(--text);
}

.chart-empty {
    margin-top: 1rem;
    text-align: center;
    color: var(--muted);
}

.chart-empty.hide {
    display: none;
}

.chart-wrapper {
    position: relative;
    width: 100%;
    height: 360px;
    margin-top: 1rem;
}

.chart-wrapper canvas {
    width: 100% !important;
    height: 100% !important;
}

@media (max-width: 768px) {
    .chart-wrapper {
        height: 280px;
    }
}

.error {
    color: #f87171;
    font-size: 0.85rem;
}

.hint {
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 400;
}

.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.auth-wrapper {
    background: var(--surface);
    padding: 2.5rem;
    border-radius: 1rem;
    box-shadow: 0 20px 45px rgba(2, 6, 23, 0.45);
    width: min(360px, 92vw);
}

.auth-form {
    margin-top: 1.5rem;
}

.loading {
    padding: 1.5rem;
    text-align: center;
    color: var(--muted);
}

.app-footer {
    text-align: center;
    padding: 2rem;
    color: var(--muted);
}

.muted {
    color: var(--muted);
    font-size: 0.85rem;
}

.forecasting {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.forecasting-form {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: 1rem;
    box-shadow: 0 18px 40px rgba(2, 6, 23, 0.35);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.form-actions {
    margin-top: 1rem;
}

.forecast-summary {
    background: rgba(30, 41, 59, 0.75);
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    border: 1px solid rgba(148, 163, 184, 0.2);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.forecast-table,
.history-table {
    margin-top: 1.5rem;
}

.forecast-comparison {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.forecast-table h2,
.history-table h2 {
    margin-bottom: 0.75rem;
}

