:root {
  --paper: #f8f5ee;
  --paper-2: #efe9dc;
  --panel: #ffffff;
  --panel-soft: #fbf8f1;
  --navy: #12283f;
  --ink: #1a2f45;
  --muted: #5f7185;
  --muted-2: #8493a3;
  --gold: #b48a2b;
  --gold-strong: #8d6a19;
  --gold-soft: #d9bd7a;
  --gold-wash: #f7eed9;
  --line: #e6dfd1;
  --line-strong: #d3c6a9;
  --good: #1c7a51;
  --good-bg: #e2f2e8;
  --warn: #8a6414;
  --warn-bg: #faf0d6;
  --bad: #a13b46;
  --bad-bg: #fbe6e8;
  --shadow: 0 10px 24px rgba(31, 45, 61, 0.08);
  --sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  overflow-x: hidden;
  background:
    radial-gradient(900px 460px at 88% -6%, rgba(217, 189, 122, 0.28), transparent 62%),
    radial-gradient(760px 420px at -8% 8%, rgba(145, 172, 201, 0.2), transparent 60%),
    linear-gradient(180deg, #fbf8f1 0%, var(--paper) 46%, #f3eee4 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

/* ---------- header ---------- */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding: 20px clamp(18px, 4vw, 46px) 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 253, 247, 0.96), rgba(250, 246, 237, 0.9));
}

.brand { display: flex; align-items: center; gap: 15px; min-width: 0; }

.mark {
  width: 54px;
  height: 54px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(145deg, #eed9a6, #cba95b);
  color: #3a2a08;
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 6px 14px rgba(140, 110, 40, 0.18);
}

.brand-text h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 29px;
  line-height: 1.1;
  color: var(--navy);
  letter-spacing: 0.01em;
}

.meta-line { margin: 7px 0 0; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }

.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.03em;
}

.pill.gold {
  background: var(--gold-wash);
  border-color: var(--gold-soft);
  color: var(--gold-strong);
  font-weight: 600;
}

.actions { margin-left: auto; display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--navy);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.btn:hover { box-shadow: 0 6px 16px rgba(31, 45, 61, 0.12); }
.btn:active { transform: translateY(1px); }

.btn.gold {
  background: linear-gradient(180deg, #e8d19a, #cba95b);
  border-color: #b8974c;
  color: #2f2407;
}

.btn.ghost { background: #fff; }

/* ---------- tabs ---------- */

.tabs {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  gap: 6px;
  padding: 9px clamp(18px, 4vw, 46px);
  background: rgba(250, 247, 240, 0.93);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.tabs a {
  padding: 7px 15px;
  border-radius: 999px;
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.tabs a:hover { color: var(--navy); background: #fff; border-color: var(--line); }

.tabs a.active {
  background: #fff;
  color: var(--navy);
  border-color: var(--gold-soft);
  box-shadow: inset 0 -2px 0 var(--gold);
}

/* ---------- layout ---------- */

main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px clamp(18px, 4vw, 46px) 44px;
}

.section { margin-top: 26px; scroll-margin-top: 62px; }

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.section-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 26px;
  color: var(--navy);
  letter-spacing: 0.01em;
}

.section-head p { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }

.stamp {
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--gold-soft);
  background: var(--gold-wash);
  color: var(--gold-strong);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ---------- tiles ---------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
  gap: 12px;
}

.tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 3px solid var(--gold);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.tile-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.tile-value {
  display: block;
  margin: 4px 0 2px;
  font-family: var(--serif);
  font-size: 30px;
  line-height: 1.05;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}

.tile-value i { font-style: normal; font-size: 15px; color: var(--muted); margin-left: 2px; }

.tile-sub { display: block; font-size: 11.5px; color: var(--muted); line-height: 1.35; }

/* ---------- warnings ---------- */

.notice {
  margin-top: 14px;
  padding: 10px 14px;
  border: 1px solid #ead8a5;
  border-radius: 10px;
  background: #fff8e6;
  color: #6b5518;
  font-size: 12.5px;
}

.notice strong { color: #4f3e0f; }
.notice p { margin: 4px 0 0; }
.notice ul { margin: 6px 0 0 18px; padding: 0; }

/* ---------- KPI table ---------- */

.table-wrap {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 11.5px;
}

thead th {
  padding: 8px 8px;
  border-bottom: 1px solid var(--line-strong);
  background: #f3eee3;
  color: var(--navy);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  text-align: right;
  vertical-align: bottom;
}

thead th.l { text-align: left; }

.th-sub {
  display: block;
  margin-top: 2px;
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: none;
  color: var(--muted-2);
}

tbody td {
  padding: 7px 8px;
  border-bottom: 1px solid #f0ebdf;
  text-align: right;
  vertical-align: middle;
  overflow-wrap: anywhere;
}

tbody td.l { text-align: left; }

tbody tr.branch:hover td { background: #fdfaf3; }

.b-name {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: 0.01em;
}

.g-name {
  display: block;
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
}

.mini {
  display: block;
  margin-top: 1px;
  font-size: 9.5px;
  line-height: 1.25;
  color: var(--muted);
  font-weight: 500;
  white-space: normal;
  letter-spacing: 0;
}

.v {
  font-size: 12px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.v.strong { font-weight: 700; color: var(--navy); }

.cer {
  font-size: 10.5px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cer i { font-style: normal; }
.cer .sep { color: var(--muted-2); padding: 0 2px; }

.att.good { color: var(--good); font-weight: 700; }
.att.warn { color: var(--warn); font-weight: 700; }
.att.bad { color: var(--bad); font-weight: 700; }

.lvl {
  display: inline-block;
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.03em;
  vertical-align: 1px;
}

.mini .lvl { margin-left: 0; vertical-align: 0; }

.lvl-4 { background: #f3e2b2; color: #6d4d10; }
.lvl-3 { background: #f7edd8; color: #7a5c1c; }
.lvl-2 { background: #e3ebf5; color: #3d5a7d; }
.lvl-1 { background: #edf0f4; color: #55657a; }

.fom-row td {
  background: var(--gold-wash);
  border-top: 2px solid var(--gold-soft);
  border-bottom: 1px solid var(--line-strong);
  padding: 9px 8px;
}

.fom-row .mini { color: #6b5a2e; }
.fom-row .v, .fom-row .cer { font-weight: 700; color: var(--navy); }
.fom-row .att.good { color: var(--good); }
.fom-row .att.warn { color: var(--warn); }
.fom-row .att.bad { color: var(--bad); }

tfoot td {
  padding: 8px;
  border-top: 2px solid var(--line-strong);
  background: #f3eee3;
  font-weight: 700;
  font-size: 11.5px;
  text-align: right;
  color: var(--navy);
}

tfoot td.l { text-align: left; }
tfoot .mini { font-weight: 600; color: var(--muted); }

.table-note {
  margin: 8px 2px 0;
  font-size: 11px;
  color: var(--muted);
}

/* ---------- footer ---------- */

.page-foot {
  margin-top: 34px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.defs p { margin: 0 0 5px; font-size: 11.5px; color: var(--muted); }
.defs strong { color: var(--ink); }

.fineprint {
  margin: 12px 0 0;
  font-size: 10.5px;
  line-height: 1.55;
  color: var(--muted-2);
}

/* ---------- upload overlay ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(18, 40, 63, 0.26);
  backdrop-filter: blur(2px);
}

.overlay[hidden] { display: none; }

.overlay-card {
  width: min(420px, 92vw);
  padding: 22px 24px 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(18, 40, 63, 0.24);
  text-align: center;
}

.overlay-card h3 {
  margin: 0 0 5px;
  font-family: var(--serif);
  font-size: 20px;
  color: var(--navy);
}

.overlay-card p { margin: 0 0 13px; font-size: 12.5px; color: var(--muted); }

.progress {
  height: 6px;
  border-radius: 999px;
  background: var(--paper-2);
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #cba95b, #b48a2b);
  transition: width 0.2s ease;
}

.progress.indeterminate span {
  width: 35% !important;
  animation: slide 1.1s ease-in-out infinite;
}

.spinner {
  width: 24px;
  height: 24px;
  margin: 15px auto 2px;
  border-radius: 50%;
  border: 3px solid var(--gold-wash);
  border-top-color: var(--gold);
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slide { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 110;
  max-width: min(560px, 92vw);
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid rgba(217, 189, 122, 0.5);
  background: var(--navy);
  color: #f7f2e6;
  font-size: 12.5px;
  box-shadow: 0 14px 34px rgba(18, 40, 63, 0.28);
}

.toast[hidden] { display: none; }
.toast.error { background: #7d2b35; border-color: #c98b93; color: #ffe9e9; }

/* ---------- responsive ---------- */

@media (max-width: 980px) {
  .brand-text h1 { font-size: 25px; }
}

@media (max-width: 720px) {
  .top { padding: 16px 16px 12px; }
  .tabs { padding: 8px 16px; }
  main { padding: 14px 16px 34px; }
  .tile { padding: 12px 13px; }
  .tile-value { font-size: 26px; }
  thead th { font-size: 9px; padding: 7px 5px; }
  .th-sub { font-size: 7.5px; }
  tbody td { padding: 6px 5px; }
  .b-name { font-size: 11px; }
  .g-name { font-size: 14px; }
  .mini { font-size: 8.5px; }
  .v { font-size: 10.5px; }
  .cer { font-size: 9px; }
  .fom-row td { padding: 8px 5px; }
  tfoot td { padding: 7px 5px; font-size: 10px; }
}

@media (max-width: 560px) {
  .v { font-size: 10px; white-space: normal; }
  .cer { font-size: 8.6px; white-space: normal; }
  .mini { font-size: 8px; }
}

/* ---------- print ---------- */

@media print {
  @page { size: A4 landscape; margin: 10mm; }

  html, body {
    background: #fff !important;
    color: var(--ink) !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .actions, .tabs, .overlay, .toast, .table-note { display: none !important; }

  .top { padding: 0 0 8px; border-bottom: 1px solid var(--line); }
  .brand-text h1 { font-size: 22px; }
  .mark { width: 38px; height: 38px; font-size: 14px; border-radius: 10px; }

  main { max-width: none; padding: 0; }
  .section { margin-top: 14px; }

  thead { display: table-header-group; }
  tbody tr { page-break-inside: avoid; }

  .table-wrap { box-shadow: none; }
  table { font-size: 8.4px; }
  thead th { font-size: 7.4px; padding: 4px 4px; }
  .th-sub { font-size: 6.6px; }
  tbody td { padding: 3.2px 4px; font-size: 8.2px; }
  .b-name { font-size: 8.6px; }
  .g-name { font-size: 11px; }
  .mini { font-size: 7px; }
  .v { font-size: 8.2px; }
  .cer { font-size: 7.8px; }
  .lvl { font-size: 6.4px; padding: 0 4px; }
  .fom-row td { padding: 4px; }
  tfoot td { font-size: 8.2px; padding: 4px; }

  .tiles { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .tile { padding: 9px 11px; box-shadow: none; }
  .tile-value { font-size: 21px; }
  .tile-label { font-size: 8px; }
  .tile-sub { font-size: 8.5px; }
  .page-foot { margin-top: 16px; padding-top: 10px; }
  .defs { font-size: 8.4px; }
  .fineprint { font-size: 7.5px; }
}
