:root {
  --brand: #2a5ea8;
  --brand-600: #24528f;
  --brand-050: #eef4fc;
  --sidebar: #0f1b2d;
  --sidebar-2: #16243a;
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e9f0;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.app { display: flex; min-height: 100vh; }

/* ---------------- 侧边栏 ---------------- */
.sidebar {
  width: 228px;
  flex: 0 0 228px;
  background: linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px 22px; }
.brand .logo {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, #3b7ddd, var(--brand));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; box-shadow: 0 6px 14px rgba(42, 94, 168, .35);
}
.brand strong { display: block; font-size: 15px; color: #fff; letter-spacing: .5px; }
.brand small { display: block; font-size: 11px; color: #7c8ba1; margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav button {
  display: flex; align-items: center; gap: 10px;
  width: 100%; border: 0; background: transparent; color: #aebbd0;
  font: inherit; font-size: 13.5px; text-align: left; height: auto;
  padding: 10px 12px; border-radius: 10px; cursor: pointer;
  transition: .15s;
}
.nav button svg { width: 17px; height: 17px; opacity: .85; }
.nav button:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav button.active { background: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(42, 94, 168, .35); }

.sidebar-foot { border-top: 1px solid rgba(255, 255, 255, .08); padding-top: 12px; font-size: 12px; }
.sidebar-foot .who { color: #fff; font-weight: 600; margin-bottom: 8px; display: block; }
.sidebar-foot button {
  width: 100%; background: rgba(255, 255, 255, .08); border: 0; color: #cbd5e1;
  padding: 8px; border-radius: 8px; cursor: pointer; font: inherit; font-size: 12.5px; height: auto;
}
.sidebar-foot button:hover { background: rgba(255, 255, 255, .16); color: #fff; }

/* ---------------- 主区域 ---------------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 62px; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 0 24px;
  position: sticky; top: 0; z-index: 20;
}
.page-title { font-size: 17px; font-weight: 700; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.top-actions code { background: #f1f5f9; border: 1px solid var(--line); padding: 5px 9px; border-radius: 8px; font-size: 12px; color: var(--muted); }
.icon-btn { display: none; background: transparent; border: 0; font-size: 20px; cursor: pointer; color: var(--text); height: auto; padding: 4px; }

.content { padding: 22px 24px 40px; max-width: 1320px; width: 100%; margin: 0 auto; }

.view.hidden { display: none; }

/* ---------------- 通用卡片 ---------------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.card + .card { margin-top: 16px; }
.card h2 { font-size: 15px; margin: 0 0 4px; }
.hint { color: var(--muted); font-size: 12.5px; line-height: 1.7; margin: 4px 0 10px; }
code { background: #f1f5f9; padding: 1px 6px; border-radius: 5px; font-size: 12px; }

/* ---------------- 统计卡 ---------------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; display: flex; align-items: center; gap: 14px;
  cursor: pointer; transition: .15s;
}
.stat-card:hover { border-color: #c7d7ee; transform: translateY(-2px); box-shadow: 0 8px 20px rgba(16, 24, 40, .08); }
.stat-card .go { margin-left: auto; color: #b6c2d4; font-size: 16px; }
.stat-card .ico {
  width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  background: var(--brand-050); color: var(--brand); font-size: 18px;
}
.stat-card .num { font-size: 24px; font-weight: 700; line-height: 1.1; }
.stat-card .cap { color: var(--muted); font-size: 12px; margin-top: 3px; }

/* ---------------- 图表 ---------------- */
.chart-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin-top: 16px; }
.chart-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.chart-card h3 { font-size: 14px; margin: 0 0 14px; }
.bar-row { display: grid; grid-template-columns: 92px 1fr 34px; align-items: center; gap: 10px; margin-bottom: 9px; font-size: 12.5px; }
.bar-track { height: 9px; background: #eef2f7; border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #4b86d8, var(--brand)); border-radius: 6px; }
.bar-row .n { color: var(--muted); text-align: right; }

.donut-wrap { display: flex; align-items: center; gap: 22px; }
.donut {
  width: 128px; height: 128px; border-radius: 50%; flex: 0 0 128px;
  display: flex; align-items: center; justify-content: center; position: relative;
}
.donut::after { content: ""; position: absolute; inset: 14px; background: #fff; border-radius: 50%; }
.donut b { position: relative; z-index: 1; font-size: 22px; }
.donut-legend { display: flex; flex-direction: column; gap: 8px; font-size: 12.5px; color: var(--muted); }
.legend-dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; }

/* ---------------- 表格 / 列表 ---------------- */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  position: sticky; top: 0; background: #f8fafc; color: var(--muted);
  font-weight: 600; text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: #f8fbff; }
tbody tr:last-child td { border-bottom: 0; }
.cell-ellipsis { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pill { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; color: #fff; white-space: nowrap; }
.pill.green { background: var(--ok); }
.pill.orange { background: var(--warn); }
.pill.red { background: var(--danger); }
.pill.gray { background: #94a3b8; }

/* ---------------- 表单 ---------------- */
.form-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 10px 0; }
input, select {
  font: inherit; font-size: 13px; height: 36px; padding: 0 11px;
  border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--text); outline: none;
  min-width: 140px;
}
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(42, 94, 168, .12); }
input[type="file"] { padding: 6px 8px; height: auto; }

button {
  font: inherit; font-size: 13px; font-weight: 600; height: 36px; padding: 0 16px;
  border: 0; border-radius: 9px; background: var(--brand); color: #fff; cursor: pointer;
  transition: .15s; white-space: nowrap;
}
button:hover { background: var(--brand-600); }
button.ghost { background: #fff; color: var(--brand); border: 1px solid #c7d7ee; }
button.ghost:hover { background: var(--brand-050); }
button.danger { background: #fff; color: var(--danger); border: 1px solid #f1c4c0; }
button.danger:hover { background: #fdf1f0; }
button.mini { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
button:disabled { opacity: .5; cursor: default; }

.check-label { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; }

/* ---------------- 记录浏览 ---------------- */
.record-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.records { display: flex; flex-direction: column; margin-top: 12px; }
.rec-row {
  display: grid; grid-template-columns: 30px 96px 130px 1fr 88px 52px; gap: 10px;
  align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.rec-row:hover { background: #f8fbff; }
.rec-row.head { font-size: 12px; color: var(--muted); background: #f8fafc; cursor: default; font-weight: 600; }
.rec-cell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.rec-title { font-weight: 600; }
input.rec-check { width: 15px; height: 15px; min-width: 0; }

.detail { margin-top: 16px; border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; background: #fbfcfe; }
.detail.hidden { display: none; }
.detail h3 { margin: 0 0 12px; font-size: 15px; }
.detail-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.detail-table th, .detail-table td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; vertical-align: top; }
.detail-table th { width: 22%; background: #f1f5fb; font-weight: 500; color: var(--muted); }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 14px; }
.photo-grid a { display: block; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: #f1f5f9; }
.photo-grid img { display: block; width: 100%; height: 112px; object-fit: cover; }
.download-link { color: var(--brand); font-weight: 600; text-decoration: underline; }

.modal { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal.hidden { display: none; }
.modal-box { background: #fff; width: min(840px, 100%); max-height: 88vh; border-radius: 14px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 24px 60px rgba(0, 0, 0, .3); }
.modal-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-body { padding: 16px 18px; overflow: auto; }

.photo-wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-top: 12px; }
.photo-item { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
.photo-item img { display: block; width: 100%; height: 150px; object-fit: cover; background: #f1f5f9; }
.photo-meta { padding: 8px 10px; font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.photo-meta b { display: block; color: var(--text); font-size: 12.5px; margin-bottom: 2px; }

.files-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.files-head h2 { margin-bottom: 4px; }
.file-list { margin-top: 12px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.file-row {
  display: grid; grid-template-columns: 46px minmax(0, 1fr) 86px 86px 104px 190px;
  gap: 10px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line);
}
.file-row:last-child { border-bottom: 0; }
.file-row:hover { background: #f8fbff; }
.file-badge {
  width: 40px; height: 40px; border-radius: 9px; background: var(--brand-050); color: var(--brand);
  font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.file-name { min-width: 0; font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-tag {
  display: inline-block; margin-top: 3px; padding: 1px 7px; border-radius: 999px;
  background: #f1f5f9; color: var(--muted); font-size: 11px; font-weight: 400;
}
.file-meta { color: var(--muted); font-size: 12px; }
.file-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.file-download {
  display: inline-flex; align-items: center; justify-content: center; height: 28px; padding: 0 10px;
  font-size: 12px; font-weight: 600; border-radius: 7px; background: #fff;
  color: var(--brand); border: 1px solid #c7d7ee; text-decoration: none;
}
.modal-box.wide { width: min(1040px, 100%); }
.file-preview-body { padding: 0; background: #f8fafc; min-height: 300px; }
.file-preview-body iframe { display: block; width: 100%; height: 72vh; border: 0; background: #fff; }
.file-preview-body img { display: block; max-width: 100%; max-height: 72vh; margin: 0 auto; background: #fff; }
.file-preview-body pre {
  margin: 0; padding: 16px; white-space: pre-wrap; word-break: break-word;
  font: 13px/1.6 Consolas, monospace; max-height: 72vh; overflow: auto; background: #fff;
}
.file-preview-body video, .file-preview-body audio { display: block; max-width: 100%; margin: 16px auto; }
.pdf-bar { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 10px 14px; background: #fff; border-bottom: 1px solid var(--line); }
.pdf-page-wrap { padding: 14px; background: #e9edf3; min-height: 60vh; display: flex; justify-content: center; }
.pdf-page-wrap img { display: block; max-width: 100%; max-height: 72vh; box-shadow: 0 2px 10px rgba(0, 0, 0, .15); background: #fff; }

.progress-wrap { margin: 8px 0 12px; }
.progress-track { height: 8px; background: #eef2f7; border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, #4b86d8, var(--brand)); border-radius: 999px; transition: width .15s; }
.progress-wrap .hint { display: block; margin-top: 5px; }

.project-board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 8px; }
.proj-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; background: #fbfcfe; }
.proj-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.proj-name { font-weight: 700; font-size: 14.5px; cursor: pointer; }
.proj-name:hover { color: var(--brand); }
.proj-count { color: var(--muted); font-size: 12px; white-space: nowrap; }
.proj-sub { color: var(--muted); font-size: 11.5px; margin: 6px 0 10px; }
.form-links { display: flex; flex-wrap: wrap; gap: 6px; }
.form-link {
  border: 1px solid #dbe5f2; background: #fff; color: #334155; border-radius: 8px;
  padding: 5px 9px; font-size: 12px; cursor: pointer;
}
.form-link:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-050); }
.form-link b { color: var(--brand); margin-left: 4px; }
.form-link.zero { opacity: .55; }

@media (max-width: 1100px) { .project-board { grid-template-columns: 1fr 1fr; } }
@media (max-width: 700px) { .project-board { grid-template-columns: 1fr; } }

/* ---------------- 项目卡 ---------------- */
.projects { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.project { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.project-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.project-title { font-weight: 700; font-size: 14.5px; }
.project-meta { color: var(--muted); font-size: 12px; }
.members { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.member { background: var(--brand-050); color: var(--brand); border-radius: 8px; padding: 5px 9px; font-size: 12px; display: inline-flex; align-items: center; gap: 6px; }
.member button { height: auto; padding: 0 4px; background: transparent; color: var(--muted); }
.member button:hover { color: var(--danger); background: transparent; }

/* ---------------- 登录 ---------------- */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 20% 0%, #1e3a63 0%, #0f1b2d 55%, #0b1422 100%);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 400px; background: #fff; border-radius: 18px; padding: 30px 28px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
}
.login-card .logo {
  width: 46px; height: 46px; border-radius: 13px; background: linear-gradient(135deg, #3b7ddd, var(--brand));
  color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.login-card h1 { font-size: 19px; margin: 14px 0 4px; }
.login-card p { color: var(--muted); font-size: 12.5px; margin: 0 0 18px; line-height: 1.6; }
.login-card .field { margin-bottom: 12px; }
.login-card label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.login-card input { width: 100%; }
.login-card button { width: 100%; height: 42px; margin-top: 6px; }
.login-hint { color: var(--muted); font-size: 12px; margin: 10px 0 0; text-align: center; }
.pwd-wrap { position: relative; }
.pwd-wrap input { padding-right: 46px; }
.pwd-toggle {
  position: absolute; right: 4px; top: 3px; height: 30px; padding: 0 9px;
  background: transparent; border: 0; color: var(--brand); font-size: 12px; cursor: pointer;
}
.login-card .pwd-toggle { width: auto; height: 30px; margin-top: 0; }
.pwd-toggle:hover { background: var(--brand-050); }
input.input-error { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(220, 38, 38, .12); }
.error { color: var(--danger); font-size: 12.5px; min-height: 18px; margin-top: 8px; }
.hidden { display: none !important; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .sidebar {
    position: fixed; left: 0; top: 0; height: 100vh; transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: 0 0 40px rgba(0, 0, 0, .35);
  }
  .sidebar.open { transform: translateX(0); }
  .main { width: 100%; }
  .icon-btn { display: inline-flex; align-items: center; justify-content: center; }
  .top-actions code { display: none; }
  .content { padding: 16px 14px 32px; }
  .rec-row { grid-template-columns: 26px 82px 96px 1fr; }
  .rec-row .rec-cell:nth-child(5), .rec-row .rec-cell:nth-child(6) { display: none; }
  .rec-cell.rec-title {
    white-space: normal; display: -webkit-box;
    -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  }
  .file-row { grid-template-columns: 40px minmax(0, 1fr) auto; }
  .file-row .file-meta:nth-child(4), .file-row .file-meta:nth-child(5) { display: none; }
  .file-actions { grid-column: 2 / 4; justify-content: flex-start; }
  .files-head { flex-direction: column; }
  .stat-card .num { font-size: 21px; }
  .form-row input { min-width: 0; flex: 1 1 140px; }
}

/* ---------------- 图标 / 分页 / 日志覆盖 / 骨架 ---------------- */
.stat-card .ico svg { width: 21px; height: 21px; }
.chart-grid .span-2 { grid-column: 1 / -1; }

.load-more { display: flex; justify-content: center; margin-top: 14px; }

.gap-strip { display: flex; gap: 4px; flex-wrap: wrap; margin: 10px 0 12px; }
.gap-cell { width: 16px; height: 16px; border-radius: 4px; display: inline-block; }
.gap-on { background: #bfe3c9; border: 1px solid #a5d7b3; }
.gap-off { background: #fde2e0; border: 1px solid #f3c3bf; }
.gap-missing { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.gap-none { color: var(--muted); font-size: 12.5px; }
.gap-chip {
  background: #fdf1f0; color: #b42318; border: 1px solid #f3c3bf;
  border-radius: 7px; padding: 3px 8px; font-size: 12px;
}

.skeleton {
  background: linear-gradient(90deg, #eef2f7 25%, #f6f9fc 50%, #eef2f7 75%);
  background-size: 200% 100%; animation: sk 1.2s infinite;
  border-radius: 8px; height: 18px;
}
@keyframes sk { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }

/* ---------------- 补录 / 编辑表单 ---------------- */
.modal-actions { display: flex; gap: 8px; align-items: center; }

.edit-form {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin-top: 6px;
}
.efield { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.efield.wide { grid-column: 1 / -1; }
.efield label { font-size: 12px; color: var(--muted); }
.efield input, .efield select, .efield textarea {
  font: inherit; font-size: 13px; width: 100%; min-width: 0;
  border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px;
  background: #fff; color: var(--text); outline: none;
}
.efield input, .efield select { height: 36px; }
.efield textarea { resize: vertical; min-height: 68px; line-height: 1.5; }
.efield input:focus, .efield select:focus, .efield textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(42, 94, 168, .12);
}
@media (max-width: 700px) { .edit-form { grid-template-columns: 1fr; } }

/* ---------------- 资料类型卡片 ---------------- */
.type-chips { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
.tchip {
  display: inline-flex; align-items: center; gap: 8px;
  height: auto; padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; color: var(--text);
  font-size: 13px; font-weight: 500; cursor: pointer; transition: .15s;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.tchip:hover { border-color: #c7d7ee; background: var(--brand-050); color: var(--brand); }
.tchip.active {
  background: var(--brand); border-color: var(--brand); color: #fff;
  box-shadow: 0 6px 14px rgba(42, 94, 168, .28);
}
.tchip-label { white-space: nowrap; }
.tchip-count {
  min-width: 22px; text-align: center; font-size: 11.5px; font-weight: 700;
  background: #eef2f7; color: var(--muted); border-radius: 999px; padding: 1px 6px;
}
.tchip:hover .tchip-count { background: #fff; color: var(--brand); }
.tchip.active .tchip-count { background: rgba(255, 255, 255, .22); color: #fff; }
.tchip.empty { opacity: .62; }
.tchip.empty:hover { opacity: 1; }

/* ---------------- 监理月报 ---------------- */
.monthly-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.monthly-bar input[type="month"] { width: 158px; min-width: 0; }
.monthly-bar .hint { margin: 0; }

.monthly-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 16px; align-items: start; margin-top: 16px;
}
.monthly-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.monthly-side .card + .card { margin-top: 0; }

.monthly-kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 10px; margin: 12px 0 14px;
}
.kpi-box {
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fbfcfe;
}
.kpi-box b { display: block; font-size: 21px; line-height: 1.25; color: var(--brand); }
.kpi-box span { display: block; font-size: 11.5px; color: var(--muted); }
.kpi-box small { display: block; font-size: 11px; color: var(--ok); margin-top: 2px; }

.monthly-preview {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; flex-direction: column; overflow: hidden;
  position: sticky; top: 78px;
}
.monthly-preview iframe { display: block; border: 0; background: #eceef1; margin: 0 auto; }
.monthly-preview-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 13px 18px 11px; border-bottom: 1px solid var(--line);
}
.monthly-preview-head h2 { font-size: 15px; margin: 0; }
.monthly-preview-head .hint { margin: 0; font-size: 11.5px; }
.monthly-preview iframe {
  width: 100%; height: calc(100vh - 196px); min-height: 620px;
  border: 0; background: #eceef1;
}

.notes-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; margin: 12px 0 4px; }
.notes-grid label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 12.5px; color: var(--muted); min-width: 0;
}
.notes-grid label:nth-child(n+4) { grid-column: 1 / -1; }
.notes-grid textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px;
  font: inherit; font-size: 13px; line-height: 1.6; color: var(--text); background: #fff;
  resize: vertical; outline: none;
}
.notes-grid textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(42, 94, 168, .12); }

@media (max-width: 1180px) {
  .monthly-layout { grid-template-columns: minmax(0, 1fr); }
  .monthly-preview { position: static; }
  .monthly-preview iframe { height: 880px; }
}
@media (max-width: 640px) {
  .notes-grid { grid-template-columns: 1fr; }
  .notes-grid label:nth-child(n+4) { grid-column: auto; }
}
