:root {
    --bg: #f0f2f5;
    --bg-card: #ffffff;
    --bg-topbar: #1a1a2e;
    --text: #1a1a2e;
    --text-secondary: #6b7280;
    --border: #e5e7eb;
    --primary: #0057B7;
    --primary-hover: #004499;
    --green: #10B981;
    --yellow: #F59E0B;
    --red: #EF4444;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

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

/* Topbar */
.topbar {
    background: var(--bg-topbar);
    color: white;
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

.topbar-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.topbar-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.refresh-indicator {
    font-size: 0.8rem;
    padding: 4px 10px;
    background: rgba(255,255,255,0.1);
    border-radius: 20px;
}

/* Main */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px 24px;
}

/* Filters */
.filters {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 20px;
    background: var(--bg-card);
    padding: 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 160px;
}

.filter-group label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Form elements */
.form-input {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    background: white;
    color: var(--text);
    transition: border-color 0.15s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,87,183,0.1);
}

select.form-input {
    cursor: pointer;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn-xs { padding: 3px 8px; font-size: 0.75rem; border-radius: 4px; }
.btn-block { width: 100%; justify-content: center; }

/* Cards */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
}

@media (max-width: 900px) {
    .dashboard-grid { grid-template-columns: 1fr; }
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-full {
    grid-column: 1 / -1;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

.card-body {
    padding: 16px 20px;
}

/* Tables */
.table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.data-table tr:hover td {
    background: #f8f9ff;
}

.empty-state {
    text-align: center;
    padding: 40px !important;
    color: var(--text-secondary);
}

/* Status badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
}

.status-green { color: var(--green); }
.status-yellow { color: var(--yellow); }
.status-red { color: var(--red); }
.status-neutral { color: #9CA3AF; }

.updated-at {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Login */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0057B7 0%, #1e40af 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: 16px;
    padding: 40px 32px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    text-align: center;
}

.login-logo {
    font-size: 4rem;
    margin-bottom: 16px;
}

.login-card h1 {
    font-size: 1.5rem;
    margin-bottom: 4px;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 24px;
}

.login-form {
    text-align: left;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group .form-input {
    width: 100%;
}

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.alert-error {
    background: #fef2f2;
    color: var(--red);
    border: 1px solid #fecaca;
}

.muted {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Cameras */
.camera-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.camera-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.15s;
}

.camera-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.camera-card-header {
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.camera-country {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.camera-thumb {
    width: 100%;
    height: 140px;
    object-fit: cover;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.camera-placeholder {
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    background: #f3f4f6;
}

.camera-card-footer {
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.camera-ppid {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: monospace;
}

.camera-list {
    max-height: 400px;
    overflow-y: auto;
}

.camera-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

.camera-name {
    font-size: 0.85rem;
}

/* Forecast */
.forecast-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 600px) {
    .forecast-grid { grid-template-columns: 1fr; }
}

.forecast-block h4 {
    font-size: 0.95rem;
    margin-bottom: 12px;
}

.forecast-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.bar-label {
    width: 40px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.bar-track {
    flex: 1;
    height: 18px;
    background: #f3f4f6;
    border-radius: 9px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 9px;
    transition: width 0.3s;
}

.bar-peak { background: var(--red); }
.bar-best { background: var(--green); }

.bar-value {
    width: 50px;
    text-align: right;
    font-size: 0.8rem;
    font-weight: 500;
    flex-shrink: 0;
}
