:root {
  --forest: #006b37;
  --forest-dark: #064421;
  --leaf: #8cc63f;
  --leaf-soft: #edf8df;
  --sun: #ffc83d;
  --sunset: #f36f32;
  --ink: #14251c;
  --muted: #647466;
  --line: #d7e4d2;
  --bg: #f5f8f1;
  --card: #ffffff;
  --warn: #b45309;
  --bad: #b91c1c;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Arial, Helvetica, sans-serif; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { border: 0; background: var(--forest); color: white; border-radius: 6px; padding: 10px 14px; cursor: pointer; }
button:hover { background: var(--forest-dark); }
button.ghost { background: white; color: var(--forest); border: 1px solid var(--line); }
button.icon { padding: 7px 9px; background: var(--leaf-soft); color: var(--forest); border: 1px solid #c9deb7; }
.hidden { display: none !important; }
.login { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at 82% 18%, rgba(255, 200, 61, .32), transparent 28%), linear-gradient(135deg, #f1f8e8, #ffffff 58%, #edf7dc); }
.login-panel { width: min(430px, 92vw); background: white; border: 1px solid var(--line); border-top: 5px solid var(--leaf); border-radius: 8px; padding: 28px; box-shadow: 0 20px 60px rgba(0, 107, 55, .16); }
.login-panel h1 { margin: 14px 0 20px; font-size: 25px; color: var(--forest-dark); }
.login-logo { display: flex; align-items: center; gap: 12px; font-weight: 800; color: var(--forest); text-transform: uppercase; }
.login-logo img { width: 58px; height: 58px; object-fit: contain; }
.hint, .error { font-size: 13px; }
.error { color: var(--bad); }
label { display: grid; gap: 6px; font-weight: 700; font-size: 13px; margin: 10px 0; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 9px; background: white; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(140, 198, 63, .35); border-color: var(--leaf); }
textarea { min-height: 110px; resize: vertical; }
.app { display: grid; grid-template-columns: 270px 1fr; min-height: 100vh; }
aside { background: linear-gradient(180deg, var(--forest-dark), #082f1a); color: white; padding: 18px; display: flex; flex-direction: column; gap: 18px; }
aside .brand { display: grid; grid-template-columns: 54px 1fr; gap: 10px; align-items: center; }
aside .brand img { grid-row: span 2; width: 54px; height: 54px; object-fit: contain; background: white; border-radius: 8px; padding: 4px; }
aside .brand strong { color: white; align-self: end; }
aside .brand small { display: block; color: #d7efc0; align-self: start; }
nav { display: grid; gap: 5px; }
nav button { background: transparent; color: #ecf7e2; text-align: left; border-radius: 6px; padding: 10px; }
nav button.active, nav button:hover { background: rgba(140, 198, 63, .22); box-shadow: inset 4px 0 0 var(--leaf); }
main { padding: 24px; min-width: 0; }
header { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 18px; border-bottom: 3px solid rgba(140, 198, 63, .35); padding-bottom: 14px; }
h1, h2, h3 { margin: 0 0 10px; }
header h1 { color: var(--forest-dark); }
header p { margin: 0; color: var(--muted); }
.user { text-align: right; color: var(--muted); font-size: 13px; }
.grid { display: grid; gap: 14px; }
.stats { grid-template-columns: repeat(5, minmax(130px, 1fr)); }
.dashboard-grid { display: grid; grid-template-columns: repeat(4, minmax(180px, 1fr)); gap: 14px; margin-bottom: 14px; }
.dashboard-main { display: grid; grid-template-columns: repeat(3, minmax(240px, 1fr)); gap: 14px; margin-bottom: 14px; }
.dashboard-lower { display: grid; grid-template-columns: minmax(320px, .85fr) minmax(520px, 1.15fr); gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 15px; box-shadow: 0 8px 24px rgba(6, 68, 33, .05); }
.hero-metric { min-height: 118px; border-top: 4px solid var(--forest); display: grid; align-content: center; gap: 5px; }
.hero-metric.good { border-top-color: var(--leaf); }
.hero-metric.alert { border-top-color: var(--sunset); }
.hero-metric.sun { border-top-color: var(--sun); }
.hero-metric span { color: var(--muted); font-size: 13px; }
.hero-metric strong { color: var(--forest); font-size: 36px; line-height: 1; }
.hero-metric small { color: var(--muted); line-height: 1.35; }
.stat { border-top: 4px solid var(--leaf); }
.stat:nth-child(3n) { border-top-color: var(--sun); }
.stat:nth-child(4n) { border-top-color: var(--sunset); }
.stat b { display: block; font-size: 28px; color: var(--forest); }
.stat span { font-size: 13px; color: var(--muted); }
.chart-row { display: grid; grid-template-columns: 150px 1fr; gap: 18px; align-items: center; min-height: 178px; }
.donut { width: 150px; height: 150px; border-radius: 50%; display: grid; place-items: center; position: relative; box-shadow: inset 0 0 0 1px rgba(6, 68, 33, .08); }
.donut::after { content: ""; position: absolute; width: 84px; height: 84px; border-radius: 50%; background: white; box-shadow: 0 0 0 1px var(--line); }
.donut span { position: relative; z-index: 1; color: var(--forest-dark); font-size: 26px; font-weight: 800; }
.legend { display: grid; gap: 9px; }
.legend div { display: grid; grid-template-columns: 12px 1fr auto; gap: 8px; align-items: center; font-size: 13px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; }
.legend b { color: var(--forest-dark); }
.bar-chart { display: grid; gap: 16px; padding-top: 8px; }
.bar-line { display: grid; grid-template-columns: 66px 1fr 30px; gap: 10px; align-items: center; font-size: 13px; }
.bar-line div { height: 18px; border-radius: 999px; background: #edf3e8; overflow: hidden; border: 1px solid var(--line); }
.bar-line i { display: block; height: 100%; border-radius: 999px; }
.bar-line b { text-align: right; color: var(--forest-dark); }
.action-list { display: grid; gap: 8px; max-height: 360px; overflow: auto; padding-right: 4px; }
.action-item { display: grid; gap: 3px; width: 100%; text-align: left; background: #fbfef7; color: var(--ink); border: 1px solid var(--line); border-left: 4px solid var(--leaf); padding: 10px 12px; }
.action-item:hover { background: var(--leaf-soft); }
.action-item span { width: fit-content; border-radius: 999px; padding: 2px 8px; background: #fff3c4; color: var(--warn); font-size: 11px; font-weight: 700; }
.action-item strong { color: var(--forest-dark); }
.action-item small { color: var(--muted); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input, .toolbar select { max-width: 240px; }
.table-wrap { overflow: auto; background: white; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; min-width: 850px; }
th, td { text-align: left; border-bottom: 1px solid var(--line); padding: 10px; font-size: 13px; vertical-align: top; }
th { background: #f4faed; color: #496044; }
.column-filters th { background: #fbfef7; padding: 6px; }
.column-filters input, .column-filters select { min-width: 110px; padding: 6px; font-size: 12px; }
.column-filters button { padding: 6px 9px; }
.column-filters th:last-child { min-width: 180px; }
.column-filters th:last-child select { min-width: 145px; margin-right: 4px; }
tr:hover td { background: #fbfef7; }
.badge { display: inline-block; border-radius: 999px; padding: 3px 8px; background: var(--leaf-soft); color: var(--forest); font-size: 12px; }
.badge.bad { background: #fee2e2; color: var(--bad); }
.badge.warn { background: #fff3c4; color: var(--warn); }
.profile { display: grid; grid-template-columns: minmax(320px, 1fr) 360px; gap: 14px; }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 8px; font-size: 13px; }
.kv div:nth-child(odd) { color: var(--muted); }
.tabs { display: flex; gap: 8px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tabs button { background: transparent; color: var(--muted); border-radius: 0; }
.tabs button.active { color: var(--forest); border-bottom: 3px solid var(--leaf); }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.full { grid-column: 1 / -1; }
.modal { position: fixed; inset: 0; background: rgba(20, 37, 28, .52); display: grid; place-items: center; padding: 18px; z-index: 20; }
.modal-box { width: min(1100px, 96vw); max-height: 92vh; overflow: auto; background: white; border-radius: 8px; padding: 20px; position: relative; }
.x { position: absolute; right: 12px; top: 10px; background: #f1f5ee; color: var(--ink); padding: 6px 10px; }
.letter-preview { border: 1px solid var(--line); background: #e8eee2; padding: 18px; margin-top: 12px; min-height: 520px; overflow: auto; }
.preview-page { position: relative; width: min(100%, 794px); aspect-ratio: 210 / 297; margin: 0 auto; background: white; box-shadow: 0 14px 34px rgba(6, 68, 33, .12); overflow: hidden; }
.preview-letterhead { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; }
.preview-body { position: relative; z-index: 1; padding: 18% 11% 13% 11%; font-size: 13px; line-height: 1.55; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.report-list { grid-template-columns: repeat(3, 1fr); }
.template-layout { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 14px; align-items: start; }
.template-list { display: grid; gap: 8px; margin-top: 12px; max-height: calc(100vh - 230px); overflow: auto; padding-right: 4px; }
.template-picker { display: grid; gap: 3px; width: 100%; text-align: left; background: #fbfef7; color: var(--ink); border: 1px solid var(--line); border-left: 4px solid var(--leaf); padding: 10px 12px; }
.template-picker:hover { background: var(--leaf-soft); }
.template-picker strong { color: var(--forest-dark); }
.template-picker span { font-size: 13px; }
.template-picker small { color: var(--muted); }
.template-form .toolbar select { max-width: 260px; }
.template-editor { min-height: 680px; font-family: Consolas, "Courier New", monospace; font-size: 13px; line-height: 1.45; }
.doc-preview-number { background: var(--leaf-soft); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; color: var(--forest-dark); }
.small { font-size: 12px; color: var(--muted); }
.danger { color: var(--bad); }
.name-cell { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; min-width: 230px; }
.danger-btn { background: #fee2e2 !important; color: var(--bad) !important; border-color: #fecaca !important; }
.danger-btn:hover { background: #fecaca !important; }
a { color: var(--forest); }
@media (max-width: 950px) {
  .app { grid-template-columns: 1fr; }
  aside { position: static; }
  .stats, .report-list, .dashboard-grid, .dashboard-main, .dashboard-lower, .template-layout { grid-template-columns: 1fr; }
  .profile, .two, .form-grid { grid-template-columns: 1fr; }
  .chart-row { grid-template-columns: 120px 1fr; }
  .donut { width: 120px; height: 120px; }
  .donut::after { width: 68px; height: 68px; }
  main { padding: 14px; }
  header { display: block; }
  .user { text-align: left; margin-top: 8px; }
}
@media print {
  aside, header, .toolbar, .tabs, button { display: none !important; }
  main { padding: 0; }
  .card, .table-wrap { border: 0; box-shadow: none; }
  .app { display: block; }
}
