/* === GridPact Design System === */
:root {
    --bg:        #0D1117;
    --bg-card:   #161B22;
    --bg-raised: #1C2330;
    --border:    #21262D;
    --text:      #E6EDF3;
    --muted:     #8B949E;
    --yellow:    #FFD700;
    --yellow-dim:#B8A000;
    --green:     #3FB950;
    --red:       #F85149;
    --blue:      #58A6FF;
    --orange:    #FF6B35;
    --radius:    10px;
    --shadow:    0 4px 24px rgba(0,0,0,0.4);
}

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

html, body {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 14px;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}

/* === HEADER === */
.header {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 0 24px;
    height: 60px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand { font-size: 18px; font-weight: 700; color: var(--yellow); letter-spacing: -0.3px; }
.header-nav { display: flex; gap: 4px; flex: 1; }
.nav-link {
    padding: 6px 14px;
    border-radius: 6px;
    color: var(--muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: color .15s, background .15s;
}
.nav-link:hover { color: var(--text); background: var(--bg-raised); }
.nav-link.active { color: var(--yellow); background: rgba(255,215,0,0.08); }
.nav-admin { color: var(--orange) !important; }
.header-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }

.company-switcher select {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-family: inherit;
}

.user-badge { display: flex; align-items: center; gap: 8px; }
.user-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: linear-gradient(135deg, var(--yellow-dim), var(--yellow));
    color: #000; font-weight: 700; font-size: 13px;
    display: flex; align-items: center; justify-content: center;
}
.user-info { display: flex; flex-direction: column; line-height: 1.2; }
.user-name { font-size: 13px; font-weight: 600; }
.user-company { font-size: 11px; color: var(--muted); }
.btn-logout {
    color: var(--muted); display: flex; align-items: center;
    padding: 6px; border-radius: 6px; transition: color .15s, background .15s;
    text-decoration: none;
}
.btn-logout:hover { color: var(--red); background: rgba(248,81,73,0.08); }

/* === MAIN / LAYOUT === */
.main { padding: 20px 24px; display: flex; flex-direction: column; gap: 20px; }

.grid-row { display: grid; gap: 16px; }
.grid-3col { grid-template-columns: 180px 280px 1fr; }
.grid-2col { grid-template-columns: 1fr 1fr; }
.card-span2 { grid-column: span 2; }

/* === CARDS === */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}
.card-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--muted);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* === SCORE CARD === */
.card-score { display: flex; flex-direction: column; align-items: center; }
.score-ring-wrap { position: relative; width: 100px; height: 100px; margin: 4px auto 8px; }
.score-ring { transform: rotate(-90deg); width: 100%; height: 100%; }
.ring-bg { fill: none; stroke: var(--bg-raised); stroke-width: 10; }
.ring-fill {
    fill: none;
    stroke: var(--yellow);
    stroke-width: 10;
    stroke-linecap: round;
    stroke-dasharray: 314.159;
    transition: stroke-dasharray 1s ease;
    filter: drop-shadow(0 0 6px rgba(255,215,0,0.5));
}
.score-label {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}
.score-number { font-size: 20px; font-weight: 700; color: var(--yellow); display: block; }
.score-sub { font-size: 10px; color: var(--muted); }
.score-verdict { font-size: 12px; font-weight: 600; margin-top: 4px; }
.score-verdict.good { color: var(--green); }
.score-verdict.warn { color: var(--orange); }

/* === COST CARD === */
.card-cost { display: flex; flex-direction: column; }
.cost-wrap { position: relative; display: flex; align-items: center; justify-content: center; margin: 0 auto 12px; }
.cost-wrap canvas { display: block; }
.cost-center {
    position: absolute; text-align: center;
    display: flex; flex-direction: column;
    pointer-events: none;
}
.cost-amount { font-size: 20px; font-weight: 700; color: var(--text); }
.cost-label { font-size: 10px; color: var(--muted); margin: 1px 0; }
.cost-diff { font-size: 11px; font-weight: 600; }
.cost-diff.up { color: var(--red); }
.cost-diff.down { color: var(--green); }
.budget-bar-wrap { margin-top: auto; }
.budget-bar-label { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-bottom: 5px; }
.budget-bar { height: 6px; background: var(--bg-raised); border-radius: 3px; overflow: hidden; }
.budget-bar-fill { height: 100%; background: var(--yellow); border-radius: 3px; transition: width 1s ease; }
.budget-bar-fill.warn { background: var(--orange); }
.budget-bar-fill.danger { background: var(--red); }

/* === CHART CARD === */
.card-chart { display: flex; flex-direction: column; }
.card-header-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-header-row .card-title { margin-bottom: 0; }
.chart-legend { display: flex; gap: 16px; font-size: 11px; color: var(--muted); align-items: center; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.legend-dot.yellow { background: var(--yellow); }
.legend-dot.grey { background: var(--muted); }

/* === INSIGHTS === */
.card-insights { display: flex; flex-direction: column; }
.insights-list { display: flex; flex-direction: column; gap: 10px; }
.insight-card {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 12px 14px;
    border-radius: 8px;
    border-left: 3px solid transparent;
    background: var(--bg-raised);
}
.card-high { border-left-color: var(--yellow); }
.card-medium { border-left-color: var(--green); }
.card-low { border-left-color: #4B5563; }
.insight-icon { flex-shrink: 0; width: 28px; height: 28px; }
.insight-icon svg { width: 22px; height: 22px; }
.card-high .insight-icon { color: var(--yellow); }
.card-medium .insight-icon { color: var(--green); }
.card-low .insight-icon { color: var(--muted); }
.insight-body strong { display: block; font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.insight-body p { font-size: 12px; color: var(--muted); line-height: 1.5; }
.insight-body .btn { margin-top: 8px; }

/* === DEVICES === */
.card-devices { display: flex; flex-direction: column; }
.devices-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.device-row { display: flex; align-items: center; gap: 10px; }
.device-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.device-info { min-width: 130px; }
.device-name { font-size: 13px; font-weight: 500; display: block; }
.device-cat { font-size: 11px; color: var(--muted); }
.device-bar-wrap { flex: 1; display: flex; align-items: center; gap: 8px; }
.device-bar { flex: 1; height: 6px; background: var(--bg-raised); border-radius: 3px; overflow: hidden; }
.device-bar-fill { height: 100%; border-radius: 3px; transition: width 1s ease; }
.device-pct { font-size: 12px; font-weight: 600; color: var(--muted); min-width: 32px; text-align: right; }
.device-donut-chart { margin-top: 8px; max-height: 160px; }

/* === BUTTONS === */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 7px 14px; border-radius: 6px; font-size: 12px; font-weight: 600;
    cursor: pointer; border: none; font-family: inherit;
    transition: background .15s, transform .1s;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--yellow); color: #000; }
.btn-primary:hover { background: #FFC200; }
.btn-sm { padding: 4px 10px; font-size: 11px; background: var(--bg); border: 1px solid var(--border); color: var(--text); }
.btn-sm:hover { background: var(--bg-raised); }
.btn-danger { background: rgba(248,81,73,0.15); color: var(--red); border: 1px solid rgba(248,81,73,0.3); }
.btn-danger:hover { background: rgba(248,81,73,0.25); }
.btn-full { width: 100%; padding: 10px; font-size: 14px; }

/* === ALERTS === */
.alert {
    padding: 10px 14px; border-radius: 6px; font-size: 13px;
    margin-bottom: 16px; font-weight: 500;
}
.alert-error { background: rgba(248,81,73,0.12); color: var(--red); border: 1px solid rgba(248,81,73,0.3); }
.alert-success { background: rgba(63,185,80,0.12); color: var(--green); border: 1px solid rgba(63,185,80,0.3); }

/* === LOGIN === */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-wrap { width: 100%; max-width: 400px; padding: 24px; }
.login-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 32px; }
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.login-brand { font-size: 24px; font-weight: 700; color: var(--yellow); }
.login-sub { font-size: 13px; color: var(--muted); margin-bottom: 24px; }
.login-demo-hint {
    margin-top: 20px; padding: 12px; border-radius: 6px;
    background: var(--bg-raised); font-size: 11px; color: var(--muted); line-height: 1.8;
}

/* === FORMS === */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--muted); }
.form-group input, .form-group select, .form-group textarea {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 9px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    transition: border-color .15s;
}
.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--yellow);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* === ADMIN TABLE === */
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 20px; }
.admin-table th { text-align: left; padding: 8px 10px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); border-bottom: 1px solid var(--border); }
.admin-table td { padding: 10px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--bg-raised); }
.section-sub { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin: 16px 0 12px; }
.admin-form { margin-top: 4px; }

/* === BADGES === */
.badge { display: inline-flex; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.badge-superadmin { background: rgba(255,215,0,0.15); color: var(--yellow); }
.badge-admin { background: rgba(88,166,255,0.15); color: var(--blue); }
.badge-user { background: rgba(139,148,158,0.15); color: var(--muted); }

/* === RESPONSIVE === */
@media (max-width: 1100px) {
    .grid-3col { grid-template-columns: 1fr 1fr; }
    .card-span2 { grid-column: span 2; }
}
@media (max-width: 800px) {
    .header-nav { display: none; }
    .grid-3col, .grid-2col { grid-template-columns: 1fr; }
    .card-span2 { grid-column: 1; }
    .form-row { grid-template-columns: 1fr; }
}
