:root {
      --ink: #183149;
      --brand: #095338;
      --brand-deep: #06412c;
      --muted: #708090;
      --line: #e3e9ee;
      --bg: #f4f7f9;
      --card: #ffffff;
      --accent: #095338;
      --accent-soft: #e5f1ed;
      --warn: #a96023;
      --warn-soft: #fff1df;
      --shadow: 0 10px 28px rgba(9, 83, 56, .09);
      --radius: 16px;
    }

    * { box-sizing: border-box; }
    body {
      margin: 0;
      background: var(--bg);
      color: var(--ink);
      font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    }

    button, input, select { font: inherit; }
    button { cursor: pointer; }

    .app { min-height: 100vh; display: grid; grid-template-columns: 330px 1fr; }

    .sidebar {
      background: var(--brand);
      color: white;
      padding: 24px 18px;
      min-height: 100vh;
      position: sticky;
      top: 0;
      height: 100vh;
      overflow: auto;
    }

    .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
    .brand-mark {
      width: 42px; height: 42px; border-radius: 12px;
      display: grid; place-items: center; overflow: hidden;
      background: white;
      box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
    }
    .brand-mark img { width: 36px; height: 36px; object-fit: contain; display: block; }
    .brand h1 { font-size: 18px; margin: 0; letter-spacing: .03em; }
    .brand small { display: block; margin-top: 2px; color: #d7ebe3; }

    .readonly {
      display: inline-flex; align-items: center; gap: 7px;
      padding: 7px 10px; margin-bottom: 18px;
      background: rgba(255,255,255,.09); color: #dce8ee;
      border-radius: 999px; font-size: 12px; font-weight: 700;
    }

    .search {
      width: 100%; border: 1px solid rgba(255,255,255,.16);
      background: rgba(255,255,255,.10); color: white;
      border-radius: 12px; padding: 11px 12px; outline: none;
    }
    .search::placeholder { color: #c4d0d8; }
    .search:focus { border-color: rgba(255,255,255,.5); background: rgba(255,255,255,.12); }

    .client-count { font-size: 12px; color: #bdd8cd; margin: 10px 2px 8px; }
    .client-list { display: grid; gap: 7px; }
    .client-btn {
      width: 100%; text-align: left; border: 0; color: #eaf1f5;
      background: transparent; border-radius: 11px; padding: 11px 12px;
      transition: .16s ease;
    }
    .client-btn:hover { background: rgba(255,255,255,.08); }
    .client-btn.active { background: white; color: var(--brand); }
    .client-btn strong { display: block; font-size: 13px; line-height: 1.25; }
    .client-btn span { display: block; font-size: 11px; opacity: .68; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

    .main { padding: 28px; min-width: 0; }
    .topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
    .topbar h2 { margin: 0; font-size: 26px; }
    .topbar p { margin: 6px 0 0; color: var(--muted); }

    .year-select {
      border: 1px solid var(--line); background: white; border-radius: 11px;
      padding: 10px 12px; color: var(--ink); outline: none;
    }

    .cards { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; margin-bottom: 18px; }
    .stat {
      background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
      padding: 18px; box-shadow: var(--shadow);
    }
    .stat span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 8px; }
    .stat strong { font-size: 26px; }

    .panel {
      background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
      box-shadow: var(--shadow); overflow: hidden;
    }
    .panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
    .panel-head strong { font-size: 15px; }
    .table-wrap { overflow: auto; }
    table { width: 100%; border-collapse: collapse; min-width: 790px; }
    th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: #f8fafb; padding: 12px 14px; border-bottom: 1px solid var(--line); }
    td { padding: 13px 14px; border-bottom: 1px solid #edf1f4; font-size: 13px; vertical-align: middle; }
    tr.data-row { cursor: pointer; }
    tr.data-row:hover td { background: #f8fbfc; }
    .sample { font-weight: 700; }
    .subtle { color: var(--muted); font-size: 12px; }

    .badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 9px; font-size: 11px; font-weight: 800; white-space: nowrap; }
    .badge.ok { background: var(--accent-soft); color: var(--accent); }
    .badge.warn { background: var(--warn-soft); color: var(--warn); }
    .badge.neutral { background: #edf1f4; color: #607282; }

    .empty, .loading { padding: 46px 20px; text-align: center; color: var(--muted); }
    .spinner { width: 27px; height: 27px; border: 3px solid #dfe8ed; border-top-color: var(--accent); border-radius: 50%; animation: spin .75s linear infinite; margin: 0 auto 12px; }
    @keyframes spin { to { transform: rotate(360deg); } }

    .welcome {
      min-height: calc(100vh - 56px); display: grid; place-items: center; text-align: center;
    }
    .welcome-inner { max-width: 510px; }
    .welcome-icon { width: 86px; height: 86px; border-radius: 22px; margin: 0 auto 18px; display: grid; place-items: center; background: white; box-shadow: var(--shadow); overflow: hidden; }
    .welcome-icon img { width: 74px; height: 74px; object-fit: contain; display: block; }
    .welcome h2 { margin: 0 0 10px; font-size: 30px; }
    .welcome p { color: var(--muted); line-height: 1.6; }

    .modal-backdrop {
      position: fixed; inset: 0; background: rgba(12,26,38,.48); display: none; align-items: center; justify-content: center; padding: 20px; z-index: 50;
    }
    .modal-backdrop.open { display: flex; }
    .modal { width: min(760px, 100%); max-height: 90vh; overflow: auto; background: white; border-radius: 20px; box-shadow: 0 28px 80px rgba(0,0,0,.25); }
    .modal-head { padding: 20px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; position: sticky; top: 0; background: white; z-index: 2; }
    .modal-head h3 { margin: 0; font-size: 20px; }
    .modal-head p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
    .close { width: 36px; height: 36px; border: 0; background: #eef3f5; color: var(--ink); border-radius: 10px; font-size: 20px; }
    .modal-body { padding: 22px; }
    .detail-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; margin-bottom: 18px; }
    .detail-item { padding: 13px; background: #f7f9fa; border-radius: 12px; }
    .detail-item span { display: block; color: var(--muted); font-size: 11px; margin-bottom: 5px; }
    .detail-item strong { display: block; font-size: 14px; }
    .section-title { margin: 20px 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
    .params { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); border: 1px solid var(--line); border-radius: 13px; overflow: hidden; }
    .param { display: flex; justify-content: space-between; gap: 12px; padding: 11px 13px; border-bottom: 1px solid var(--line); }
    .param:nth-last-child(-n+2) { border-bottom: 0; }
    .param:nth-child(odd) { border-right: 1px solid var(--line); }
    .param span { color: var(--muted); font-size: 12px; }
    .param strong { font-size: 12px; text-align: right; }
    .pdf-actions { display: flex; flex-wrap: wrap; gap: 10px; }
    .pdf-btn { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; padding: 10px 13px; border-radius: 11px; background: var(--ink); color: white; font-size: 13px; font-weight: 700; }
    .pdf-btn.secondary { background: #e8eef2; color: var(--ink); }
    .note { background: #fff8eb; color: #775321; padding: 12px 14px; border-radius: 12px; font-size: 13px; line-height: 1.5; }
    .error { padding: 16px; background: #fff0ef; color: #8b312a; border-radius: 12px; }

    .mobile-header { display: none; }

    @media (max-width: 820px) {
      .app { display: block; }
      .sidebar { position: fixed; inset: 0 16% 0 0; z-index: 60; transform: translateX(-105%); transition: .2s ease; box-shadow: 20px 0 50px rgba(0,0,0,.22); }
      .sidebar.open { transform: translateX(0); }
      .main { padding: 16px; }
      .mobile-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
      .menu-btn { border: 0; background: white; border-radius: 11px; width: 42px; height: 42px; box-shadow: var(--shadow); }
      .mobile-brand { font-weight: 900; letter-spacing: .03em; }
      .topbar { align-items: flex-end; }
      .topbar h2 { font-size: 21px; }
      .cards { grid-template-columns: 1fr 1fr; }
      .cards .stat:last-child { grid-column: 1 / -1; }
      .detail-grid, .params { grid-template-columns: 1fr; }
      .param:nth-child(odd) { border-right: 0; }
      .param:nth-last-child(-n+2) { border-bottom: 1px solid var(--line); }
      .param:last-child { border-bottom: 0; }
    }

/* PWA 0.2 */
.net-status {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 10px; margin: 0 0 10px;
  border-radius: 999px; font-size: 12px; font-weight: 700;
  background: rgba(255,255,255,.10); color: #fff;
}
.net-status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #9ee6c6; }
.net-status.offline::before { background: #ffc66d; }
.net-status.offline { color: #fff4df; }
.install-btn {
  display: none; width: 100%; margin: 0 0 14px; padding: 10px 12px;
  border: 1px solid rgba(255,255,255,.22); border-radius: 12px;
  background: rgba(255,255,255,.13); color: #fff; font-weight: 750;
}
.install-btn.show { display:block; }
.offline-note {
  display:none; margin: 0 0 14px; padding: 10px 12px; border-radius: 12px;
  background: rgba(255,196,98,.12); color: #fff1d7; font-size: 12px; line-height:1.35;
}
.offline-note.show { display:block; }
.sync-line { margin-top: 10px; color: #d7ebe3; font-size: 11px; }
.cached-hint { color: var(--muted); font-size: 12px; margin-top: 8px; }
@media (display-mode: standalone) {
  body { padding-top: env(safe-area-inset-top); }
}
