:root {
    --bg-primary: #000000;
    --bg-secondary: #111111;
    --bg-card: #0a0a0a;
    --bg-card-hover: #1a1a1a;
    --bg-navbar: #181918;
    --border-primary: #333333;
    --border-secondary: #222222;
    --border-accent: #666666;
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --text-tertiary: #999999;
    --text-muted: #666666;
    --accent-green: #00ff00;
    --accent-red: #ff0000;
    --accent-yellow: #ffff00;
    --accent-cyan: #00ffff;
    --white: #ffffff;
}

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

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

/* ── Login Screen ────────────────────────────────────────── */
.login-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 32px;
}

.login-card {
    background: var(--bg-card);
    border: 2px solid var(--white);
    border-radius: 12px;
    padding: 48px;
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}

.login-card img {
    height: 64px;
    filter: invert(1);
    margin-bottom: 24px;
}

.login-card h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.login-card p {
    color: var(--text-tertiary);
    font-size: 14px;
    margin-bottom: 32px;
}

.login-card .btn {
    width: 100%;
    padding: 14px 24px;
    font-size: 15px;
}

.login-error {
    color: var(--accent-red);
    font-size: 13px;
    margin-top: 16px;
}

/* ── Header ──────────────────────────────────────────────── */
.header {
    background: var(--bg-navbar);
    border-bottom: 1px solid var(--border-primary);
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-left img {
    height: 36px;
    filter: invert(1);
}

.header-left h1 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.header-left span {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 400;
    margin-left: 4px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-tertiary);
    padding: 6px 12px;
    border: 1px solid var(--border-primary);
    border-radius: 8px;
}

.user-badge .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-green);
    box-shadow: 0 0 6px var(--accent-green);
}

.btn-logout {
    background: none;
    border: 1px solid var(--border-primary);
    color: var(--text-tertiary);
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-logout:hover {
    border-color: var(--white);
    color: var(--white);
}

/* ── Controls ────────────────────────────────────────────── */
.controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.controls label {
    font-size: 12px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.controls input[type="date"] {
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.controls input[type="date"]:focus {
    border-color: var(--white);
}

.controls input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.7);
}

.controls select {
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    padding: 8px 28px 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    cursor: pointer;
    max-width: 220px;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.controls select:focus {
    border-color: var(--white);
}

.controls select:hover {
    border-color: var(--border-accent);
}

.controls select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
    padding: 8px 20px;
    border-radius: 8px;
    border: none;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background: #e5e5e5;
}

.btn-outline {
    background: transparent;
    color: var(--white);
    border: 1px solid var(--white);
}

.btn-outline:hover {
    background: var(--white);
    color: #000000;
}

.btn-ghost {
    background: transparent;
    color: var(--text-tertiary);
    border: 1px solid var(--border-primary);
}

.btn-ghost:hover {
    border-color: var(--border-accent);
    color: var(--text-primary);
}

.controls-divider {
    width: 1px;
    height: 24px;
    background: var(--border-primary);
    margin: 0 4px;
}

.btn-export {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid var(--border-accent);
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-export:hover {
    border-color: var(--white);
    color: var(--white);
    background: rgba(255, 255, 255, 0.05);
}

.btn-export:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-export svg {
    flex-shrink: 0;
}

.spinner-sm {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid var(--border-primary);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* ── Layout ──────────────────────────────────────────────── */
.container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 32px;
}

.period-banner {
    text-align: center;
    padding: 14px;
    font-size: 13px;
    color: var(--text-tertiary);
    border-bottom: 1px solid var(--border-secondary);
    background: var(--bg-secondary);
}

.period-banner strong {
    color: var(--text-primary);
}

/* ── Metric Cards ────────────────────────────────────────── */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.metric-card {
    background: var(--bg-card);
    border: 2px solid var(--white);
    border-radius: 12px;
    padding: 24px;
    transition: box-shadow 0.2s;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.05);
}

.metric-card:hover {
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.12);
}

.metric-card .label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 10px;
    font-weight: 500;
}

.metric-card .value {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1;
}

.metric-card .sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
}

.value-green {
    color: var(--accent-green);
    text-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
}

.value-red { color: var(--accent-red); }
.value-yellow {
    color: var(--accent-yellow);
    text-shadow: 0 0 10px rgba(255, 255, 0, 0.3);
}
.value-cyan { color: var(--accent-cyan); }
.value-white { color: var(--white); }

/* ── Charts ──────────────────────────────────────────────── */
.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 32px;
}

.chart-card {
    background: var(--bg-card);
    border: 2px solid var(--white);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.05);
}

.chart-card h3 {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.chart-card canvas {
    width: 100% !important;
    max-height: 280px;
}

/* ── Section Headers ─────────────────────────────────────── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 40px 0 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-primary);
}

.section-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.section-subtitle {
    font-size: 13px;
    color: var(--text-muted);
}

/* ── Org Cards ───────────────────────────────────────────── */
.org-card {
    background: var(--bg-card);
    border: 2px solid var(--white);
    border-radius: 12px;
    margin-bottom: 16px;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.05);
    transition: box-shadow 0.2s;
}

.org-card:hover {
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}

.org-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

.org-header:hover {
    background: var(--bg-card-hover);
}

.org-header-left h3 {
    font-size: 16px;
    font-weight: 600;
}

.org-header-left .org-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 3px;
}

.org-stats {
    display: flex;
    gap: 28px;
    font-size: 13px;
}

.org-stats .stat {
    text-align: center;
}

.org-stats .stat-value {
    font-weight: 700;
    font-size: 18px;
    font-variant-numeric: tabular-nums;
}

.org-stats .stat-label {
    color: var(--text-muted);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 500;
}

.org-expand {
    color: var(--text-muted);
    font-size: 16px;
    transition: transform 0.2s;
    margin-left: 16px;
}

.org-card.open .org-expand {
    transform: rotate(180deg);
}

.org-body {
    display: none;
    border-top: 2px solid var(--border-primary);
    padding: 20px 24px;
    background: var(--bg-primary);
}

.org-card.open .org-body {
    display: block;
}

/* ── Project Table ───────────────────────────────────────── */
.project-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.project-table th {
    text-align: left;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-primary);
}

.project-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-secondary);
    color: var(--text-secondary);
}

.project-table tr:last-child td {
    border-bottom: none;
}

.project-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.project-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.project-table .project-name {
    color: var(--text-primary);
    font-weight: 500;
}

/* ── Loading / Empty / Error ─────────────────────────────── */
.loading {
    text-align: center;
    padding: 100px 0;
    color: var(--text-muted);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 2px solid var(--border-primary);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

.slide-up {
    animation: slideUp 0.3s ease-out;
}

.error-msg {
    text-align: center;
    padding: 40px;
    color: var(--accent-red);
    background: rgba(255, 0, 0, 0.05);
    border: 2px solid rgba(255, 0, 0, 0.3);
    border-radius: 12px;
    margin: 24px 0;
    font-size: 14px;
}

.empty-state {
    text-align: center;
    padding: 60px 32px;
    color: var(--text-muted);
    font-size: 14px;
}

/* ── Footer ──────────────────────────────────────────────── */
.footer {
    background: var(--bg-navbar);
    border-top: 1px solid var(--border-primary);
    padding: 20px 32px;
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 60px;
}

.footer a {
    color: var(--text-tertiary);
    text-decoration: none;
}

.footer a:hover {
    color: var(--white);
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1024px) {
    .charts-row { grid-template-columns: 1fr; }
    .header {
        flex-direction: column;
        gap: 12px;
        padding: 16px 20px;
    }
    .controls { flex-wrap: wrap; justify-content: center; }
    .container { padding: 20px; }
}

@media (max-width: 768px) {
    .org-stats { gap: 12px; flex-wrap: wrap; }
    .org-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .header-right { flex-wrap: wrap; }
}

@media (max-width: 600px) {
    .metrics-grid { grid-template-columns: repeat(2, 1fr); }
    .metric-card .value { font-size: 24px; }
}
