/* ==========================================================================
   KAFIL-SUG'URTA — Layout va komponentlar
   ========================================================================== */

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  transition: background .25s, color .25s;
}
a { color: inherit; text-decoration: none; }

.wrap { max-width: 1440px; margin: 0 auto; padding: 20px 24px 60px; }

/* --- Loader --- */
#loader {
  position: fixed; inset: 0; z-index: 999;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); transition: opacity .3s;
}
#loader.hide { opacity: 0; pointer-events: none; }
.spinner {
  width: 42px; height: 42px; border: 4px solid var(--border);
  border-top-color: var(--brand); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Header --- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 6px 4px 22px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 52px; height: 52px; border-radius: 14px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 19px; letter-spacing: .5px;
  box-shadow: 0 6px 16px rgba(193, 39, 45, .35); flex-shrink: 0;
}
.brand h1 { font-size: 20px; font-weight: 800; color: var(--navy); letter-spacing: -.3px; }
.brand p  { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.controls { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 15px; transition: .15s;
}
.icon-btn:hover { border-color: var(--brand); color: var(--brand); }
.langs { display: flex; background: var(--card); border: 1px solid var(--border); border-radius: 11px; overflow: hidden; }
.langs button {
  border: 0; background: transparent; color: var(--muted);
  padding: 9px 13px; font-weight: 600; font-size: 12.5px; cursor: pointer; transition: .15s;
}
.langs button.active { background: var(--brand); color: #fff; }

/* --- Layout --- */
.grid { display: grid; grid-template-columns: 290px 1fr; gap: 22px; align-items: start; }
.side { display: flex; flex-direction: column; gap: 18px; position: sticky; top: 16px; }
.main { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px;
}
.card h3 {
  font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px;
  margin-bottom: 16px; color: var(--navy);
}
.card h3 i { color: var(--brand); }

/* --- Filter --- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card); color: var(--text); font-size: 13.5px; font-family: inherit; cursor: pointer; outline: none;
}
select:focus { border-color: var(--brand); }
.btn {
  width: 100%; padding: 11px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text); font-weight: 600; font-size: 13px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px; transition: .15s; font-family: inherit;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-dark); color: #fff; }

/* --- Analysis --- */
.analysis .row { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 5px; }
.analysis .row .v { font-weight: 700; }
.bar { height: 8px; border-radius: 6px; background: var(--bg); overflow: hidden; margin-bottom: 15px; }
.bar span { display: block; height: 100%; border-radius: 6px; transition: width .6s; }
.analysis .total {
  margin-top: 6px; padding-top: 14px; border-top: 1px dashed var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.analysis .total b { font-size: 20px; color: var(--brand); }
.scope-name { font-weight: 700; color: var(--brand); margin-bottom: 14px; }

/* --- Brand banner --- */
.banner { background: linear-gradient(135deg, var(--brand), var(--brand-dark)); color: #fff; border: 0; }
.banner .blogo { font-size: 26px; font-weight: 800; letter-spacing: 1px; margin-bottom: 8px; }
.banner p { font-size: 13px; opacity: .95; margin-bottom: 14px; font-style: italic; }
.banner .links { display: flex; gap: 8px; }
.banner .links a {
  flex: 1; background: rgba(255, 255, 255, .18); border-radius: 9px;
  padding: 9px; text-align: center; font-size: 12px; font-weight: 600; transition: .15s;
}
.banner .links a:hover { background: rgba(255, 255, 255, .32); }

/* --- Scale --- */
.scale table { width: 100%; border-collapse: collapse; font-size: 12px; }
.scale th { text-align: left; color: var(--muted); font-weight: 600; padding: 5px 4px; border-bottom: 1px solid var(--border); }
.scale td { padding: 6px 4px; border-bottom: 1px solid var(--border); }
.tag {
  display: inline-block; padding: 2px 9px; border-radius: 20px;
  color: #fff; font-weight: 700; font-size: 11px; white-space: nowrap;
}

/* --- Stat cards --- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; position: relative; overflow: hidden;
}
.stat .lbl { font-size: 12.5px; color: var(--muted); font-weight: 600; margin-bottom: 10px; }
.stat .big { font-size: 30px; font-weight: 800; line-height: 1; color: var(--navy); }
.stat .sub { font-size: 12px; color: var(--muted); margin-top: 8px; font-weight: 500; }
.stat .ic {
  position: absolute; top: 16px; right: 16px; width: 42px; height: 42px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; font-size: 17px;
}
.ic-green { background: rgba(21, 128, 61, .12); color: var(--green); }
.ic-blue  { background: rgba(37, 99, 235, .12); color: var(--blue); }
.ic-amber { background: rgba(245, 158, 11, .14); color: var(--amber); }

/* --- Charts --- */
.charts { display: grid; grid-template-columns: 1.55fr 1fr; gap: 20px; }
.chart-box { position: relative; height: 330px; }
.chart-note { font-size: 11px; color: var(--muted); font-weight: 500; margin-top: 2px; margin-bottom: 8px; }

/* --- Table --- */
.thead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 720px; }
table.data th {
  text-align: left; padding: 12px 14px; color: var(--muted); font-weight: 600; font-size: 12px;
  border-bottom: 2px solid var(--border); cursor: pointer; white-space: nowrap; user-select: none;
}
table.data th:hover { color: var(--brand); }
table.data th i { margin-left: 5px; opacity: .5; font-size: 10px; }
table.data td { padding: 13px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data tbody tr:hover { background: var(--bg); }
table.data td.name { font-weight: 700; color: var(--navy); }
.num { font-variant-numeric: tabular-nums; }
.pos { color: var(--green); font-weight: 600; }
.neg { color: var(--red); font-weight: 600; }
.rowhi { background: var(--brand-soft) !important; }
.tfoot {
  font-size: 11px; color: var(--muted); margin-top: 12px; padding-top: 10px;
  border-top: 1px dashed var(--border); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
}

/* --- Responsive --- */
@media (max-width: 1050px) {
  .grid { grid-template-columns: 1fr; }
  .side { position: static; }
  .charts { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .stats { grid-template-columns: 1fr; }
  .wrap { padding: 14px; }
}
