* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #0f0f0f;
    color: #e0e0e0;
    min-height: 100vh;
}

header {
    background: #1a1a2e;
    border-bottom: 1px solid #333;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 1.4rem;
    color: #e82127;
}

nav { display: flex; gap: 1rem; align-items: center; }
nav a {
    color: #999;
    text-decoration: none;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    transition: color 0.2s;
}
nav a:hover, nav a.active { color: #fff; }
nav button {
    background: none;
    border: 1px solid #555;
    color: #ccc;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
}
nav button:hover { border-color: #e82127; color: #e82127; }

main {
    max-width: 800px;
    margin: 2rem auto;
    padding: 0 1rem;
}

main:has(.view-auth:not(.hidden)) {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 60px);
    margin: 0 auto;
}

.hidden { display: none !important; }

.view {
    background: #1a1a2e;
    border-radius: 8px;
    padding: 2rem;
}

.view-auth {
    max-width: 420px;
    width: 100%;
    text-align: center;
}

.view-auth form { margin: 0 auto; }
.view-auth .tagline { color: #888; margin-bottom: 1.5rem; font-size: 0.95rem; }
.view-auth h2 { margin-bottom: 0.5rem; }

h2 { margin-bottom: 1.5rem; color: #fff; }
h3 { margin: 1.5rem 0 1rem; color: #ccc; }

/* Forms */
form { display: flex; flex-direction: column; gap: 1rem; max-width: 400px; }
label { color: #aaa; font-size: 0.9rem; }
input[type="email"],
input[type="password"],
input[type="text"],
input[type="number"],
textarea {
    background: #0f0f0f;
    border: 1px solid #333;
    color: #e0e0e0;
    padding: 0.6rem 0.8rem;
    border-radius: 4px;
    font-size: 1rem;
    width: 100%;
}
input:focus, textarea:focus {
    outline: none;
    border-color: #e82127;
}

/* Buttons */
.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: opacity 0.2s;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: #e82127; color: #fff; }
.btn-primary:hover:not(:disabled) { background: #c41d22; }
.btn-danger { background: #333; color: #e82127; border: 1px solid #e82127; }
.btn-danger:hover:not(:disabled) { background: #e82127; color: #fff; }

/* Messages */
.message { padding: 0.6rem; border-radius: 4px; margin-top: 0.5rem; font-size: 0.9rem; }
.message:empty { display: none; }
.message.error { background: #2a1012; color: #f87171; }
.message.success { background: #0a2a12; color: #6ee7b7; }

/* Status */
.status-running { color: #34d399; font-weight: 600; font-size: 1.2rem; }
.status-idle { color: #999; font-weight: 600; font-size: 1.2rem; }

/* Countdown */
.countdown-section {
    margin-top: 0.75rem;
    padding: 0.75rem 1rem;
    background: #0f0f0f;
    border: 1px solid #333;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.countdown-label { color: #888; font-size: 0.9rem; }
.countdown-timer { font-size: 1.3rem; font-weight: 600; color: #fff; font-variant-numeric: tabular-nums; }
.countdown-buttons { display: flex; gap: 0.4rem; }

/* TeslaMate link */
.teslamate-link {
    margin-top: 0.75rem;
    padding: 0.75rem 1rem;
    background: #0f0f0f;
    border: 1px solid #333;
    border-left: 3px solid #34d399;
    border-radius: 4px;
}
.teslamate-link a {
    color: #34d399;
    font-weight: 500;
    text-decoration: none;
    font-size: 1.05rem;
}
.teslamate-link a:hover { text-decoration: underline; }
.teslamate-link .link-hint {
    display: block;
    color: #888;
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

/* Task controls */
#task-controls {
    margin-top: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}
#task-controls label { white-space: nowrap; }
#task-controls input[type="number"] { width: 80px; }

/* Session list */
.session-card {
    background: #0f0f0f;
    border: 1px solid #333;
    border-radius: 4px;
    padding: 1rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: border-color 0.2s;
}
.session-card:hover { border-color: #e82127; }

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    font-size: 0.9rem;
}
th, td {
    padding: 0.5rem;
    text-align: left;
    border-bottom: 1px solid #222;
}
th { color: #aaa; font-weight: 500; }

/* Profile */
#profile-status {
    padding: 0.6rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
#profile-status.success { background: #0a2a12; color: #6ee7b7; }
#profile-status.error { background: #2a1012; color: #f87171; }

/* Links in views */
.view a { color: #e82127; text-decoration: none; }
.view a:hover { text-decoration: underline; }

/* Token display */
.token-box {
    background: #0f0f0f;
    border: 1px solid #333;
    border-radius: 4px;
    padding: 0.5rem 0.8rem;
    font-family: monospace;
    font-size: 0.8rem;
    word-break: break-all;
    color: #ccc;
    margin-bottom: 0.5rem;
    max-height: 60px;
    overflow-y: auto;
}
.btn-inline {
    background: none;
    border: 1px solid #555;
    color: #ccc;
    padding: 0.1rem 0.5rem;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.75rem;
    margin-left: 0.5rem;
}
.btn-inline:hover { border-color: #e82127; color: #e82127; }

/* Back link */
.back-link { display: inline-block; margin-bottom: 1rem; color: #999 !important; }

/* Charts and maps */
.chart-container { position: relative; height: 250px; margin-bottom: 1.5rem; }
.chart-container.chart-small { height: 200px; max-width: 300px; }
.map-container { height: 350px; border-radius: 8px; margin-bottom: 1.5rem; border: 1px solid #333; }

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: #0f0f0f;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 0.75rem;
    text-align: center;
}
.stat-card .stat-value { font-size: 1.3rem; font-weight: 600; color: #fff; }
.stat-card .stat-label { font-size: 0.8rem; color: #888; margin-top: 0.25rem; }

/* Drive/charge cards in session view */
.item-card {
    background: #0f0f0f;
    border: 1px solid #333;
    border-radius: 4px;
    padding: 1rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: border-color 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.item-card:hover { border-color: #e82127; }

/* Info box */
.info-box {
    background: #0f0f0f;
    border: 1px solid #333;
    border-left: 3px solid #3b82f6;
    border-radius: 4px;
    padding: 1rem 1.2rem;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    line-height: 1.6;
    color: #ccc;
}
.info-box p { margin-bottom: 0.5rem; }
.info-box p:last-child { margin-bottom: 0; }
.info-box ol, .info-box ul { margin: 0.5rem 0; padding-left: 1.2rem; }
.info-box li { margin-bottom: 0.4rem; }
.info-box code {
    background: #1a1a2e;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-size: 0.85rem;
    color: #e82127;
}
.item-card .item-main { font-weight: 500; }
.item-card .item-detail { color: #888; font-size: 0.9rem; }
