/* ==========================================================================
   碳排放核算与报告系统 —— 界面样式
   ========================================================================== */

:root {
  --c-primary: #0e7c66;
  --c-primary-dark: #0a5f4e;
  --c-primary-light: #e6f4f1;
  --c-accent: #1f6feb;
  --c-bg: #f4f6f8;
  --c-panel: #ffffff;
  --c-side: #142a33;
  --c-side-hover: #1d3b47;
  --c-text: #1f2d33;
  --c-text-2: #5b6b73;
  --c-text-3: #8b9aa1;
  --c-border: #e2e8ec;
  --c-danger: #c0392b;
  --c-warn: #b7791f;
  --c-ok: #1c7c4a;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 40, 48, .06), 0 4px 16px rgba(16, 40, 48, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---------- 布局 ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 226px;
  flex: 0 0 226px;
  background: var(--c-side);
  color: #cfe0e5;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand .logo {
  display: flex; align-items: center; gap: 10px;
  font-size: 16px; font-weight: 700; color: #fff; letter-spacing: .5px;
}
.brand .logo-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, #17b890, #0e7c66);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: #fff; font-weight: 700;
}
.brand .sub { font-size: 11px; color: #7d98a1; margin-top: 6px; letter-spacing: 1px; }

.nav { padding: 10px 8px; flex: 1; overflow-y: auto; }
.nav-group { font-size: 11px; color: #6d8892; padding: 14px 12px 6px; letter-spacing: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 6px; color: #c3d5db;
  cursor: pointer; margin-bottom: 2px; font-size: 13.5px;
}
.nav-item:hover { background: var(--c-side-hover); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--c-primary); color: #fff; font-weight: 600; }
.nav-item .ico { width: 16px; text-align: center; opacity: .9; }

.side-foot {
  padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.08);
  font-size: 11.5px; color: #6d8892;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 56px; background: #fff; border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; padding: 0 22px; gap: 14px;
  position: sticky; top: 0; z-index: 20;
}
.topbar .crumbs { font-size: 13px; color: var(--c-text-2); flex: 1; }
.topbar .crumbs b { color: var(--c-text); }
.topbar .who { font-size: 13px; color: var(--c-text-2); display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--c-primary-light);
  color: var(--c-primary-dark); display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}

.content { padding: 20px 22px 40px; flex: 1; }

/* ---------- 通用组件 ---------- */
.page-head { display: flex; align-items: flex-end; gap: 14px; margin-bottom: 16px; }
.page-head h1 { font-size: 19px; margin: 0; font-weight: 700; }
.page-head .desc { color: var(--c-text-2); font-size: 12.5px; }
.page-head .spacer { flex: 1; }

.panel {
  background: var(--c-panel); border: 1px solid var(--c-border);
  border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px;
}
.panel-head {
  padding: 13px 16px; border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; gap: 10px;
}
.panel-head h3 { margin: 0; font-size: 14.5px; font-weight: 700; }
.panel-head .sub { font-size: 12px; color: var(--c-text-3); }
.panel-head .spacer { flex: 1; }
.panel-body { padding: 16px; }
.panel-body.tight { padding: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 14px; border-radius: 6px; border: 1px solid var(--c-border);
  background: #fff; color: var(--c-text); cursor: pointer; font-size: 13px;
  transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: #c7d3d9; background: #fafcfc; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-dark); border-color: var(--c-primary-dark); }
.btn-accent { background: var(--c-accent); border-color: var(--c-accent); color: #fff; }
.btn-danger { color: var(--c-danger); border-color: #f0c9c4; background: #fdf5f4; }
.btn-danger:hover { background: #fbeae7; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--c-text-2); }
.btn-ghost:hover { background: #f1f5f6; color: var(--c-text); }
.btn-sm { height: 26px; padding: 0 10px; font-size: 12px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.badge {
  display: inline-block; padding: 1px 8px; border-radius: 20px;
  font-size: 11.5px; line-height: 18px; background: #eef2f4; color: var(--c-text-2);
}
.badge.green { background: #e7f5ee; color: var(--c-ok); }
.badge.blue { background: #e9f1fd; color: var(--c-accent); }
.badge.orange { background: #fdf3e3; color: var(--c-warn); }
.badge.gray { background: #eff3f5; color: var(--c-text-2); }
.badge.teal { background: var(--c-primary-light); color: var(--c-primary-dark); }

/* 表格 */
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; }
table.grid th, table.grid td {
  padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--c-border);
  font-size: 13px; vertical-align: middle;
}
table.grid th {
  background: #f8fafb; color: var(--c-text-2); font-weight: 600;
  font-size: 12.5px; white-space: nowrap;
}
table.grid tbody tr:hover { background: #fbfdfd; }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid tr.total td { background: var(--c-primary-light); font-weight: 700; color: var(--c-primary-dark); }
table.grid td .muted { color: var(--c-text-3); font-size: 12px; }

.empty {
  padding: 44px 20px; text-align: center; color: var(--c-text-3); font-size: 13px;
}
.empty .big { font-size: 30px; opacity: .35; margin-bottom: 8px; }

/* 表单 */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid.one { grid-template-columns: 1fr; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.span2 { grid-column: span 2; }
.field.span3 { grid-column: span 3; }
.field label { font-size: 12.5px; color: var(--c-text-2); font-weight: 600; }
.field label .req { color: var(--c-danger); margin-left: 2px; }
.field .unit { color: var(--c-text-3); font-weight: 400; }
.field input[type=text], .field input[type=number], .field input[type=password],
.field input[type=email], .field select, .field textarea {
  width: 100%; height: 34px; padding: 0 10px; border: 1px solid #d7e0e5;
  border-radius: 6px; background: #fff; color: var(--c-text); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { height: auto; min-height: 78px; padding: 8px 10px; resize: vertical; line-height: 1.6; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(14,124,102,.12);
}
.field .help { font-size: 11.5px; color: var(--c-text-3); line-height: 1.5; }
.field .err { font-size: 11.5px; color: var(--c-danger); }

.formula-box {
  background: #f6faf9; border: 1px dashed #bfded7; border-radius: 6px;
  padding: 10px 12px; font-size: 12.5px; color: #23594d; margin-bottom: 14px; line-height: 1.7;
}
.formula-box b { color: var(--c-primary-dark); }

/* 统计卡片 */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat {
  background: #fff; border: 1px solid var(--c-border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat .label { font-size: 12.5px; color: var(--c-text-2); }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.stat .value small { font-size: 13px; font-weight: 500; color: var(--c-text-3); margin-left: 4px; }
.stat .foot { font-size: 11.5px; color: var(--c-text-3); margin-top: 4px; }
.stat.primary { background: linear-gradient(135deg, #0e7c66, #0a5c4b); color: #fff; border: none; }
.stat.primary .label, .stat.primary .foot { color: rgba(255,255,255,.82); }
.stat.primary .value small { color: rgba(255,255,255,.75); }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--c-border); margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  padding: 9px 16px; font-size: 13.5px; color: var(--c-text-2); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--c-text); }
.tab.active { color: var(--c-primary-dark); border-bottom-color: var(--c-primary); font-weight: 600; }

/* 两栏（填报） */
.split { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 16px; align-items: start; }
.module-list { background: #fff; border: 1px solid var(--c-border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); position: sticky; top: 76px; }
.module-list .grp { padding: 10px 14px 4px; font-size: 11.5px; color: var(--c-text-3); letter-spacing: .5px; background: #fbfcfc; }
.module-item {
  padding: 8px 14px; font-size: 13px; cursor: pointer; display: flex; align-items: center; gap: 8px;
  border-left: 3px solid transparent;
}
.module-item:hover { background: #f7fafb; }
.module-item.active { background: var(--c-primary-light); border-left-color: var(--c-primary); color: var(--c-primary-dark); font-weight: 600; }
.module-item .cnt { margin-left: auto; font-size: 11px; color: var(--c-text-3); }
.module-item .dot { width: 6px; height: 6px; border-radius: 50%; background: #cfd9de; }
.module-item .dot.has { background: var(--c-primary); }

/* 模态框 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15,32,38,.45); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto;
}
.modal {
  background: #fff; border-radius: 10px; width: 100%; max-width: 720px;
  box-shadow: 0 20px 60px rgba(9,30,38,.28); animation: pop .16s ease-out;
}
.modal.wide { max-width: 940px; }
.modal.narrow { max-width: 460px; }
@keyframes pop { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--c-border); display: flex; align-items: center; }
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-head .x { margin-left: auto; cursor: pointer; color: var(--c-text-3); font-size: 20px; line-height: 1; padding: 0 4px; }
.modal-body { padding: 20px; max-height: calc(100vh - 210px); overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--c-border); display: flex; gap: 10px; justify-content: flex-end; }

/* 提示 */
.toast-host { position: fixed; top: 18px; right: 18px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #17323c; color: #eaf3f5; padding: 10px 16px; border-radius: 6px;
  font-size: 13px; box-shadow: 0 8px 24px rgba(10,30,38,.25); animation: slide .2s ease-out;
  max-width: 380px;
}
.toast.ok { background: #12745c; }
.toast.err { background: #a3352a; }
@keyframes slide { from { transform: translateX(12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* 登录页 */
.login-host { flex: 1; display: flex; min-width: 0; }
.login-page { width: 100%; min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #0f2530; position: relative; overflow: hidden; }
.login-page::before, .login-page::after {
  content: ""; position: absolute; border-radius: 50%; filter: blur(2px);
}
.login-page::before { width: 560px; height: 560px; background: radial-gradient(circle, rgba(23,184,144,.22), transparent 65%); top: -160px; right: -100px; }
.login-page::after { width: 480px; height: 480px; background: radial-gradient(circle, rgba(31,111,235,.18), transparent 65%); bottom: -180px; left: -120px; }
.login-card {
  position: relative; width: 380px; max-width: calc(100vw - 32px); background: #fff;
  border-radius: 12px; padding: 28px 32px 24px;
  box-shadow: 0 24px 70px rgba(0,0,0,.35);
}
.brand-lockup {
  display: flex; flex-direction: column; align-items: center; gap: 0;
  padding-bottom: 16px; margin-bottom: 20px; border-bottom: 1px solid var(--c-border);
}
.brand-logo { width: 150px; max-width: 100%; height: auto; display: block; }
.brand-seal { width: 54px; height: 54px; display: block; }
.brand-org { font-size: 12.5px; color: #4a5a62; letter-spacing: .6px; }
.login-title {
  font-size: 18px; font-weight: 700; margin: 0 0 20px; text-align: center; letter-spacing: 2px;
  color: var(--c-text);
}
.login-card .field { margin-bottom: 14px; }
.login-card .btn { width: 100%; height: 38px; margin-top: 6px; }
.login-card .err { color: var(--c-danger); font-size: 12.5px; min-height: 18px; margin-top: 8px; text-align: center; }
.side-foot .org { display: block; color: #587681; font-size: 11px; line-height: 1.5; }

/* 详情页信息组 */
.kv { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px 24px; }
.kv.three { grid-template-columns: repeat(3, minmax(0,1fr)); }
.kv .item { display: flex; gap: 8px; font-size: 13px; padding: 5px 0; border-bottom: 1px dashed #eef2f4; }
.kv .item .k { color: var(--c-text-3); min-width: 96px; flex: 0 0 96px; }
.kv .item .v { color: var(--c-text); word-break: break-all; }

.source-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--c-border); font-size: 13px; }
.source-row:last-child { border-bottom: none; }
.source-row .name { flex: 1; }
.source-row .basis { color: var(--c-text-3); font-size: 11.5px; }

.switch { position: relative; width: 36px; height: 20px; background: #cfd9de; border-radius: 20px; cursor: pointer; transition: background .18s; flex: 0 0 36px; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: transform .18s; }
.switch.on { background: var(--c-primary); }
.switch.on::after { transform: translateX(16px); }
.switch.disabled { opacity: .5; cursor: not-allowed; }

.steps { font-size: 12.5px; color: var(--c-text-2); line-height: 1.9; }
.steps div { padding-left: 14px; position: relative; }
.steps div::before { content: "›"; position: absolute; left: 2px; color: var(--c-primary); }

.calc-row { cursor: pointer; }
.calc-row .expand-row td { background: #fafcfc; padding: 0; }
.calc-detail { padding: 12px 18px 16px; }

.report-doc { background: #fff; padding: 30px 36px; border: 1px solid var(--c-border); border-radius: var(--radius); box-shadow: var(--shadow); }
.report-doc h2 { font-size: 15px; border-left: 3px solid var(--c-primary); padding-left: 10px; margin: 24px 0 12px; }
.report-doc h3 { font-size: 13.5px; margin: 18px 0 8px; color: var(--c-text-2); }
.report-doc table { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
.report-doc th, .report-doc td { border: 1px solid #d7e0e5; padding: 6px 8px; font-size: 12.5px; vertical-align: top; }
.report-doc th { background: #f5f8f9; font-weight: 600; text-align: center; }
.report-doc td.num { text-align: right; font-variant-numeric: tabular-nums; }
.report-doc .note { font-size: 11.5px; color: var(--c-text-3); margin: 2px 0 12px; }
.report-doc .cover-title { text-align: center; font-size: 20px; font-weight: 700; margin: 8px 0 4px; }
.report-doc .cover-sub { text-align: center; color: var(--c-text-2); font-size: 12.5px; margin-bottom: 22px; }
.report-doc .info-table td:nth-child(odd) { background: #f8fafb; width: 18%; color: var(--c-text-2); }

.hint-line { font-size: 12px; color: var(--c-text-3); margin-top: 6px; }

.loading { padding: 40px; text-align: center; color: var(--c-text-3); font-size: 13px; }

/* 组织树与多级汇总 */
.head-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.head-tools select {
  height: 32px; padding: 0 8px; border: 1px solid #d7e0e5; border-radius: 6px;
  background: #fff; color: var(--c-text); font-size: 12.5px; outline: none;
}
.head-tools select:focus { border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(14,124,102,.12); }

.org-split { grid-template-columns: 300px minmax(0, 1fr); }
.org-tree { padding: 6px 4px; max-height: calc(100vh - 210px); overflow: auto; }
.org-node {
  display: flex; align-items: center; gap: 6px; padding: 6px 8px;
  border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--c-text); user-select: none;
}
.org-node:hover { background: #f2f7f6; }
.org-node.active { background: var(--c-primary-light); color: var(--c-primary-dark); font-weight: 600; }
.org-node .tw { flex: 0 0 14px; width: 14px; text-align: center; color: var(--c-text-3); font-size: 11px; }
.org-node .nm { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.org-node .badge { flex: 0 0 auto; font-size: 10.5px; padding: 1px 5px; }
.org-split .module-list .grp { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.org-node .cnt { margin-left: auto; flex: 0 0 auto; font-size: 11px; color: var(--c-text-3); font-variant-numeric: tabular-nums; }

@media (max-width: 1100px) {
  .split { grid-template-columns: 1fr; }
  .module-list { position: static; }
  .form-grid, .form-grid.three { grid-template-columns: 1fr; }
  .field.span2, .field.span3 { grid-column: span 1; }
}

@media print {
  .sidebar, .topbar, .page-head, .tabs, .no-print, .toast-host { display: none !important; }
  .content { padding: 0; }
  .report-doc { border: none; box-shadow: none; padding: 0; }
  body { background: #fff; }
  .app-shell { display: block; }
  @page { size: A4 landscape; margin: 12mm; }
}
