@charset "utf-8";

/* ========================================
   全局变量（参考站 teal 主题）
   ======================================== */
:root {
    --bg: #f4f7fb;
    --panel: #ffffff;
    --ink: #1c2733;
    --muted: #64748b;
    --line: #e2e8f0;
    --brand: #0f766e;
    --brand-dark: #115e59;
    --brand-soft: #14b8a6;
    --accent: #f59e0b;
    --danger: #dc2626;
    --ok: #16a34a;
    --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 8px 24px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
    line-height: 1.55;
}

.container { flex: 1; }

/* ========================================
   Topbar（teal 渐变）
   ======================================== */
.topbar {
    background: linear-gradient(120deg, #0f766e 0%, #0d9488 60%, #14b8a6 100%);
    color: #ffffff;
    width: 100%;
    padding: 22px 28px 18px;
    position: relative;
}

.brand { display: flex; flex-direction: row; align-items: center; gap: 14px; }
.brand-logo {
    width: 44px; height: 44px; flex: 0 0 auto;
    border-radius: 10px; overflow: hidden;
    background: rgba(255, 255, 255, 0.18);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
}
.brand-logo img { width: 100%; height: 100%; display: block; }

.org { font-size: 12px; letter-spacing: 0.04em; opacity: 0.82; margin-bottom: 3px; }
.tool-name { margin: 0; font-size: 21px; font-weight: 700; line-height: 1.2; letter-spacing: 0.01em; }
.tagline { margin: 10px 0 0; max-width: 780px; font-size: 13px; line-height: 1.6; opacity: 0.9; }

/* user menu in topbar */
.user-menu { position: absolute; top: 18px; right: 20px; }
.user-trigger {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 6px 12px; border: 1px solid rgba(255,255,255,.35);
    border-radius: 999px; background: rgba(255,255,255,.12);
    color: #fff; cursor: pointer; font-size: 13px; line-height: 1;
    transition: background .15s;
}
.user-trigger:hover { background: rgba(255,255,255,.22); }
.user-avatar {
    width: 26px; height: 26px; border-radius: 50%;
    background: #fff; color: var(--brand-dark); font-weight: 700; font-size: 13px;
    display: inline-flex; align-items: center; justify-content: center;
}
.user-dropdown {
    position: absolute; top: calc(100% + 8px); right: 0; min-width: 220px;
    background: #fff; color: var(--ink); border: 1px solid var(--line);
    border-radius: 12px; box-shadow: var(--shadow); padding: 6px; z-index: 50;
}
.user-dropdown-head { padding: 10px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.user-dropdown-name { font-weight: 600; font-size: 14px; }
.user-dropdown-email { font-size: 12px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-dropdown-item {
    display: block; width: 100%; text-align: left; padding: 9px 12px;
    background: transparent; color: var(--ink); font-size: 14px;
    border-radius: 8px; cursor: pointer; text-decoration: none; border: none;
}
.user-dropdown-item:hover { background: #f1f5f9; }
.user-dropdown-item.danger { color: var(--danger); }

/* ========================================
   Site nav（sticky 白底）
   ======================================== */
.site-nav {
    background: #ffffff;
    border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 20;
}
.nav-inner {
    width: 100%; padding: 0 28px;
    display: flex; align-items: center; gap: 6px; height: 46px;
}
.nav-link {
    display: inline-flex; align-items: center; height: 32px;
    padding: 0 14px; border-radius: 8px; font-size: 14px;
    color: var(--muted); text-decoration: none; transition: .15s;
}
.nav-link:hover { background: #f0fdfa; color: var(--brand-dark); }
.nav-link.active { background: var(--brand); color: #fff; font-weight: 600; }

/* ========================================
   Footer
   ======================================== */
.footer {
    padding: 1rem 0;
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}

/* ========================================
   Home: section head
   ======================================== */
.home-main { width: 100%; padding: 22px 28px 8px; }
.home-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.home-head h2 { margin: 0; font-size: 17px; border-bottom: 2px solid var(--brand); display: inline-block; padding-bottom: 4px; }
.home-count { font-size: 13px; color: var(--muted); }

/* ========================================
   Home: proj cards grid
   ======================================== */
/* 1366px+ 5 列、1100px+ 4 列、800px+ 3 列、600px+ 2 列、<600px 1 列 */
.project-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }

.proj-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 16px 18px;
    display: flex; flex-direction: column; gap: 10px;
    transition: transform .15s, box-shadow .15s;
}
.proj-card:hover { transform: translateY(-1px); box-shadow: 0 4px 8px rgba(15,23,42,.08), 0 16px 32px rgba(15,23,42,.08); }

.proj-card-head { display: flex; align-items: center; gap: 8px; }
.proj-name { margin: 0; font-size: 15px; font-weight: 700; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-meta { font-size: 12px; color: var(--muted); }

.proj-cells {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px;
    padding: 10px 12px; background: #f8fafc;
    border-radius: 10px; border: 1px solid var(--line);
}
.proj-cell { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.cell-label { font-size: 11px; color: var(--muted); }
.cell-value { font-size: 14px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.proj-actions { display: flex; gap: 8px; margin-top: 2px; }
.proj-actions .act {
    flex: 1 1 0; font-size: 13px; padding: 7px 0;
    border-radius: 8px; border: 1px solid #cbd5e1;
    background: #fff; color: var(--muted); cursor: pointer; transition: .15s;
    text-decoration: none; text-align: center;
}
.proj-actions .act.view { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 600; }
.proj-actions .act.view:hover { background: var(--brand-dark); color: #fff; border-color: var(--brand-dark); }
.proj-actions .act.ghost:hover { border-color: #185ebd; color: #185ebd; background: #eff6ff; }

/* ========================================
   Detail page: 通用卡面板
   ======================================== */
.detail-wrap { max-width: 1440px; margin: 0 auto; padding: 22px 20px 8px; }
.detail-back { margin-bottom: 14px; font-size: 13px; }
.detail-back a { color: var(--brand); text-decoration: none; }
.detail-back a:hover { text-decoration: underline; }

.detail-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; }
.detail-title { margin: 0; font-size: 22px; font-weight: 700; }
.detail-sub { font-size: 13px; color: var(--muted); margin-top: 4px; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.success { background: #dcfce7; color: #166534; }
.badge.warning { background: #fef3c7; color: #92400e; }
.badge.danger { background: #fee2e2; color: #991b1b; }
.badge.secondary { background: #e2e8f0; color: #475569; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 18px; align-items: start; }
.detail-grid-left, .detail-grid-right { display: flex; flex-direction: column; gap: 16px; }
.detail-grid-right { position: relative; }

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 18px 20px;
}
.panel h3 { margin: 0 0 14px; font-size: 16px; border-bottom: 2px solid var(--brand); display: inline-block; padding-bottom: 4px; }

.kv-table { width: 100%; font-size: 13px; }
.kv-table th { text-align: left; width: 130px; padding: 7px 10px; color: var(--muted); font-weight: 500; border-bottom: 1px dashed var(--line); }
.kv-table td { padding: 7px 10px; border-bottom: 1px dashed var(--line); }
.kv-table tr:last-child th, .kv-table tr:last-child td { border-bottom: none; }

/* ========================================
   Hero metrics（右侧粘性卡）
   ======================================== */
.metrics-hero {
    background: linear-gradient(120deg, #f0fdfa 0%, #ecfeff 100%);
    border: 1px solid #99f6e4;
    border-radius: 12px;
    padding: 18px 20px;
    box-shadow: var(--shadow);
}
.metrics-hero h3 { margin: 0 0 4px; font-size: 16px; color: var(--brand-dark); font-weight: 700; border-bottom: none; padding-bottom: 0; display: block; }
.metrics-hero .timestamp { font-size: 12px; color: var(--muted); margin-bottom: 14px; }

.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.metric-cell {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px 14px;
    text-align: center;
}
.metric-cell .m-label { font-size: 12px; color: var(--muted); }
.metric-cell .m-value { font-size: 22px; font-weight: 700; margin-top: 4px; color: var(--ink); font-variant-numeric: tabular-nums; }
.metric-cell .m-unit { font-size: 12px; color: var(--muted); margin-left: 2px; }

.metric-cell.big { grid-column: 1 / -1; background: var(--brand); border-color: var(--brand); color: #fff; }
.metric-cell.big .m-label { color: rgba(255,255,255,.85); }
.metric-cell.big .m-value { color: #fff; font-size: 28px; }
.metric-cell.big .m-unit { color: rgba(255,255,255,.8); }

/* ========================================
   Inverter table
   ======================================== */
.data-table { width: 100%; font-size: 13px; border-collapse: collapse; }
.data-table th { text-align: left; padding: 8px 12px; background: #f1f5f9; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); font-size: 12px; }
.data-table td { padding: 8px 12px; border-bottom: 1px solid var(--line); }
.data-table tbody tr:hover { background: #f8fafc; }
.data-table code { background: #f1f5f9; padding: 1px 6px; border-radius: 4px; font-size: 12px; color: var(--brand-dark); }
.data-table a { color: var(--brand); text-decoration: none; font-weight: 600; }
.data-table a:hover { text-decoration: underline; }

.panel-head-count { display: flex; justify-content: space-between; align-items: center; }
.panel-head-count h3 { margin-bottom: 0; }
.panel-head-count .badge { background: var(--brand); color: #fff; padding: 2px 10px; }

/* empty state */
.empty-block { text-align: center; padding: 40px 20px; color: var(--muted); border: 1px dashed var(--line); border-radius: 12px; background: #fafbfc; }

/* sticky 右侧栏 */
.sticky-right { position: sticky; top: 16px; }

/* ========================================
   Alerts（messages）
   ======================================== */
.alert { border-radius: 10px; font-size: 13px; padding: 10px 14px; }
.alert-info { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }
.alert-success { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; }
.alert-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert-danger { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 980px) {
    .detail-grid { grid-template-columns: 1fr; }
    .sticky-right { position: static; }
}

@media (max-width: 600px) {
    .project-grid { grid-template-columns: 1fr; }
    .metric-grid { grid-template-columns: 1fr 1fr; }
    .topbar { padding: 18px 14px 14px; }
    .tool-name { font-size: 18px; }
    .user-menu { top: 14px; right: 14px; }
    .user-name { display: none; }
}

/* 焦点可访问性 */
a:focus-visible, button:focus-visible, .nav-link:focus-visible, .act:focus-visible {
    outline: 2px solid var(--brand); outline-offset: 2px;
}

/* ========================================
   登录 / 注册 表单
   ======================================== */
.form-container {
    max-width: 420px;
    margin: 2.5rem auto;
    padding: 2rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    box-shadow: var(--shadow);
}
.form-title {
    text-align: center;
    margin: 0 0 1.5rem;
    font-size: 18px;
    font-weight: 700;
    color: var(--ink);
}

.form-label { font-size: 13px; color: var(--muted); margin-bottom: 4px; display: block; }
.form-control {
    width: 100%; padding: 8px 12px;
    border: 1px solid var(--line); border-radius: 8px;
    font-size: 14px; line-height: 1.5;
    transition: border-color .15s, box-shadow .15s;
}
.form-control:focus {
    outline: none; border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, .15);
}
.form-check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }

/* teal 主色按钮，替代 Bootstrap 默认蓝色 */
.btn-primary {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--brand-dark);
    --bs-btn-hover-border-color: var(--brand-dark);
    --bs-btn-focus-shadow-rgb: 15, 118, 110;
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--brand-dark);
    --bs-btn-active-border-color: var(--brand-dark);
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: var(--brand);
    --bs-btn-disabled-border-color: var(--brand);
}
.btn-outline-primary {
    --bs-btn-color: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--brand);
    --bs-btn-hover-border-color: var(--brand);
    --bs-btn-focus-shadow-rgb: 15, 118, 110;
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--brand-dark);
    --bs-btn-active-border-color: var(--brand-dark);
}

/* ========================================
   仪表盘（纯 CSS，无 JS 依赖）
   ======================================== */
.dash-wrap { width: 100%; padding: 22px 28px 28px; }

/* KPI Hero Bar */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 18px;
}
.kpi-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 18px 20px;
    box-shadow: var(--shadow);
    display: flex; flex-direction: column; gap: 4px;
}
.kpi-card.highlight {
    background: linear-gradient(120deg, #f0fdfa 0%, #ecfeff 100%);
    border-color: #99f6e4;
}
.kpi-card.alert {
    background: linear-gradient(120deg, #fef2f2 0%, #fff7ed 100%);
    border-color: #fecaca;
}
.kpi-label { font-size: 13px; color: var(--muted); }
.kpi-value {
    font-size: 28px; font-weight: 700; color: var(--ink);
    font-variant-numeric: tabular-nums; line-height: 1.2;
}
.kpi-card.highlight .kpi-value { color: var(--brand); }
.kpi-card.alert .kpi-value { color: var(--danger); }
.kpi-value .sep { color: var(--muted); font-size: 20px; margin: 0 4px; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* 两栏面板行 */
.dash-grid-2 {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 16px; margin-bottom: 16px;
}
.dash-grid-2 .panel { margin-bottom: 0; }

/* 小状态点 */
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.dot-运行中 { background: var(--ok); }
.dot-维护中 { background: var(--accent); }
.dot-停运 { background: var(--danger); }
.dot-待机 { background: #6366f1; }
.dot-未知, .dot-无设备 { background: var(--muted); }

.status-legend {
    display: flex; flex-wrap: wrap; gap: 14px 22px;
    padding: 12px 0 4px; font-size: 13px;
}
.status-legend .lbl { color: var(--muted); margin-right: 4px; }
.status-legend .cnt { font-weight: 600; color: var(--ink); }

/* 活动列表（维护/告警） */
.activity-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.panel-sub { font-size: 13px; font-weight: 600; color: var(--brand-dark); margin-bottom: 8px; }
.activity-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.activity-list li {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 10px; background: #f8fafc; border-radius: 8px;
    font-size: 13px;
}
.activity-list .act-title { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.activity-list .act-date { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* 纵向条形图（日发电） */
.bar-chart {
    display: flex; align-items: flex-end; gap: 3px;
    height: 220px; padding: 20px 0 0;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
}
.bar-col {
    flex: 1 1 0; min-width: 14px; max-width: 28px;
    height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
    position: relative; cursor: default;
}
.bar-fill {
    width: 100%; background: linear-gradient(180deg, #14b8a6 0%, #0f766e 100%);
    border-radius: 4px 4px 0 0;
    transition: background .15s;
}
.bar-col:hover .bar-fill { background: linear-gradient(180deg, #0d9488 0%, #115e59 100%); }
.bar-label {
    font-size: 10px; color: var(--muted); margin-top: 6px; transform: rotate(-45deg);
    white-space: nowrap;
}
.chart-foot { margin-top: 10px; text-align: right; }

/* 横向条形图（月发电 / Top10） */
.h-bar-list { display: flex; flex-direction: column; gap: 10px; padding: 4px 0; }
.h-bar-row {
    display: grid;
    grid-template-columns: 140px minmax(80px, 1fr) 140px;
    gap: 12px;
    align-items: center;
}
.h-bar-label {
    font-size: 13px; color: var(--muted); overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap;
}
.h-bar-track {
    height: 22px; background: #f1f5f9; border-radius: 6px; overflow: hidden;
}
.h-bar-fill {
    height: 100%; background: linear-gradient(90deg, #14b8a6, #0f766e);
    border-radius: 6px;
    transition: width .3s ease;
}
.h-bar-fill.accent {
    background: linear-gradient(90deg, #0ea5e9, #1e40af);
}
.h-bar-value { font-size: 13px; font-weight: 600; color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; }

/* 逆变器概览 */
.inv-status-dist { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 6px; }
.inv-status-item {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 6px 12px; background: #f8fafc; border-radius: 8px; font-size: 13px;
}
.inv-cnt { font-weight: 700; color: var(--ink); font-size: 15px; }
.inv-problem-block { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.inv-problem { display: flex; flex-direction: column; gap: 6px; }

/* 仪表盘响应式 */
@media (max-width: 1100px) {
    .kpi-row { grid-template-columns: repeat(2, 1fr); }
    .activity-grid { grid-template-columns: 1fr; }
    .dash-grid-2 { grid-template-columns: 1fr; }
    .inv-problem-block { grid-template-columns: 1fr; }
    .h-bar-row { grid-template-columns: 100px minmax(60px, 1fr) 100px; }
}
@media (max-width: 600px) {
    .kpi-row { grid-template-columns: 1fr; }
    .bar-chart { gap: 2px; }
}

/* Badge 统一对比度 + padding，覆盖 Bootstrap 原生（注意：HTML 用 class="badge info" 空格分隔） */
.badge, .badge.success, .badge.info, .badge.warning, .badge.danger,
.badge.secondary, .badge.dark {
    padding: 4px 10px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    border-radius: 999px !important;
    letter-spacing: 0.2px !important;
    border: none !important;
}
.badge.success { background: #ccfbf1 !important; color: #134e4a !important; }
.badge.info    { background: #5b21b6 !important; color: #faf5ff !important; }
.badge.warning { background: #fef3c7 !important; color: #92400e !important; }
.badge.danger  { background: #fee2e2 !important; color: #991b1b !important; }
.badge.secondary { background: #1f2937 !important; color: #f9fafb !important; }
.badge.dark    { background: #cbd5e1 !important; color: #0f172a !important; }