/* =====================================================================
   KPI — hamshiralarni baholash. Zamonaviy admin-panel (Shopall uslubida).
   Aksent: indigo/violet. Shrift: Inter. Guruhlangan sidebar, breadcrumb,
   metrik kartalar (±% o'zgarish), status-pill jadvallar.
   ===================================================================== */

:root {
    --accent:        #4f46e5;   /* indigo-600 */
    --accent-2:      #6366f1;   /* indigo-500 */
    --accent-dark:   #4338ca;   /* indigo-700 */
    --accent-soft:   #eef2ff;   /* indigo-50  */
    --accent-soft2:  #e0e7ff;   /* indigo-100 */

    --bg:            #f3f4f7;
    --surface:       #ffffff;
    --text:          #111827;
    --text-2:        #374151;
    --muted:         #6b7280;
    --muted-2:       #9ca3af;
    --border:        #eceef2;
    --border-2:      #e1e4ea;

    --green:   #16a34a;  --green-soft:  #ecfdf3;
    --amber:   #d97706;  --amber-soft:  #fffaeb;
    --red:     #e11d48;  --red-soft:    #fff1f2;
    --blue:    #2563eb;  --blue-soft:   #eff4ff;

    --radius:    16px;
    --radius-sm: 11px;
    --radius-xs: 8px;
    --shadow-sm: 0 1px 2px rgba(17,24,39,.05);
    --shadow:    0 1px 3px rgba(17,24,39,.05), 0 1px 2px rgba(17,24,39,.03);
    --shadow-md: 0 6px 20px rgba(17,24,39,.07);
    --shadow-lg: 0 16px 40px rgba(17,24,39,.12);
    --sb-w:      252px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1 { font-size: 21px; font-weight: 700; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 16px; font-weight: 650; margin: 0; letter-spacing: -.01em; }
a  { color: var(--accent-dark); text-decoration: none; }
.muted  { color: var(--muted); }
.strong { font-weight: 650; }
.ico { width: 20px; height: 20px; flex: none; }

/* ============ App shell ============ */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sb-w); flex: none;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    padding: 16px 14px;
    position: sticky; top: 0; height: 100vh; z-index: 40;
}

.brand {
    display: flex; align-items: center; gap: 11px;
    font-weight: 750; color: var(--text); letter-spacing: -.02em;
    padding: 6px 8px; margin-bottom: 14px; font-size: 16px;
}
.brand-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; background: var(--accent); color: #fff;
    border-radius: 10px; box-shadow: 0 4px 10px rgba(79,70,229,.30);
}
.brand-mark .ico { width: 19px; height: 19px; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-group-label {
    font-size: 10.5px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .06em; color: var(--muted-2);
    padding: 14px 12px 6px;
}
.nav-group-label:first-child { padding-top: 4px; }
.nav-link {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 12px; border-radius: var(--radius-sm);
    color: var(--text-2); font-weight: 550; font-size: 13.5px;
    transition: background .12s, color .12s;
}
.nav-link .ico { width: 19px; height: 19px; color: var(--muted-2); transition: color .12s; }
.nav-text { flex: 1; }
.nav-link:hover { background: #f5f6f8; color: var(--text); }
.nav-link:hover .ico { color: var(--text-2); }
.nav-link.is-active { background: var(--accent-soft); color: var(--accent-dark); font-weight: 650; }
.nav-link.is-active .ico { color: var(--accent); }
.nav-badge {
    min-width: 20px; height: 20px; padding: 0 6px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--accent-soft2); color: var(--accent-dark);
    border-radius: 6px; font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.nav-link.is-active .nav-badge { background: var(--accent); color: #fff; }

.sidebar-foot { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 8px; display: flex; flex-direction: column; gap: 11px; }
.lang-switch { display: inline-flex; background: #f1f2f5; border-radius: var(--radius-xs); padding: 3px; width: fit-content; }
.lang-switch a { padding: 4px 13px; font-size: 12px; font-weight: 650; color: var(--muted); border-radius: 6px; }
.lang-switch a.is-active { background: var(--surface); color: var(--accent-dark); box-shadow: var(--shadow-sm); }

.user-card { display: flex; align-items: center; gap: 10px; padding: 7px 8px; background: #f7f8fa; border-radius: var(--radius-sm); }
.user-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--accent); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px; flex: none;
}
.user-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.user-name { font-size: 13px; font-weight: 650; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-sub  { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-logout { display: inline-flex; padding: 6px; border-radius: var(--radius-xs); color: var(--muted); flex: none; }
.user-logout .ico { width: 18px; height: 18px; }
.user-logout:hover { background: var(--red-soft); color: var(--red); }

/* ============ Content + topbar ============ */
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    display: flex; align-items: center; gap: 14px;
    height: 60px; padding: 0 32px;
    background: var(--surface); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 30;
}
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.crumb-nav {
    width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border-2); background: var(--surface); border-radius: var(--radius-xs);
    color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; transition: all .12s;
}
.crumb-nav:hover { background: #f5f6f8; color: var(--text); }
.crumb-root { color: var(--muted); margin-left: 4px; }
.crumb-sep  { color: var(--muted-2); }
.crumb-cur  { color: var(--text); font-weight: 650; }

.main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 26px 32px 56px; }
.footer { text-align: center; color: var(--muted-2); font-size: 12px; padding: 16px; }
.nav-toggle { display: none; }
.backdrop { display: none; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { display: flex; align-items: center; gap: 12px; }
.period-badge {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--accent-soft); color: var(--accent-dark);
    padding: 7px 13px; border-radius: 999px; font-size: 12.5px; font-weight: 650;
    border: 1px solid var(--accent-soft2);
}

/* ============ Cards ============ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px; }
.card-narrow { max-width: 560px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head h2 { display: flex; align-items: center; gap: 8px; }
.empty { padding: 34px 0; text-align: center; color: var(--muted); }
.hint { font-size: 13px; color: var(--muted); margin: 0 0 16px; }

/* ============ Stat cards ============ */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat { padding: 18px; margin-bottom: 0; display: flex; flex-direction: column; gap: 10px; }
.stat:hover { box-shadow: var(--shadow-md); }
.stat-top { display: flex; align-items: center; gap: 10px; }
.stat-icon { width: 36px; height: 36px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); }
.stat-icon .ico { width: 19px; height: 19px; }
.stat-icon.is-amber { background: var(--amber-soft); color: var(--amber); }
.stat-icon.is-blue  { background: var(--blue-soft); color: var(--blue); }
.stat-icon.is-star  { background: #fef9c3; color: #ca8a04; }
.stat-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 26px; font-weight: 750; letter-spacing: -.03em; line-height: 1.05; }
.stat-value-sm { font-size: 16px; font-weight: 650; line-height: 1.3; }
.stat-unit { font-size: 15px; color: var(--muted-2); font-weight: 600; }
.stat-delta { display: flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 650; }
.delta-arrow { font-size: 10px; }
.delta-note { color: var(--muted); font-weight: 500; }
.stat-delta.is-up   { color: var(--green); }
.stat-delta.is-down { color: var(--red); }
.stat-delta.is-flat { color: var(--muted); font-weight: 500; }

/* ============ Tables ============ */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table thead th {
    text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .04em; color: var(--muted); padding: 11px 14px;
    border-bottom: 1px solid var(--border-2); white-space: nowrap; background: #fafbfc;
}
.table thead th:first-child { border-top-left-radius: 10px; }
.table thead th:last-child  { border-top-right-radius: 10px; }
.table tbody td { padding: 13px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: #f8f9fb; }
.row-muted { opacity: .5; }
.col-num { text-align: center; white-space: nowrap; font-variant-numeric: tabular-nums; }
.col-rank { width: 58px; text-align: center; }
.col-pct { width: 180px; }
.col-actions { text-align: right; white-space: nowrap; }
.col-score { width: 250px; }
.cell-note { font-size: 12px; margin-top: 3px; max-width: 380px; }

.rank-badge { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 8px; background: #f1f2f5; color: var(--muted); font-weight: 700; font-size: 13px; }
.rank-top { background: var(--accent); color: #fff; box-shadow: 0 3px 8px rgba(79,70,229,.3); }

/* ============ Percent bar ============ */
.pct { position: relative; height: 24px; background: #eef0f4; border-radius: 7px; overflow: hidden; min-width: 120px; }
.pct-bar { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 7px; transition: width .3s; }
.pct-text { position: relative; z-index: 1; display: block; text-align: center; line-height: 24px; font-size: 12px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.pct.pct-high .pct-bar { background: var(--green); }
.pct.pct-mid  .pct-bar { background: var(--amber); }
.pct.pct-low  .pct-bar { background: var(--red); }
.pct-strong { font-weight: 750; font-variant-numeric: tabular-nums; }
.pct-strong.pct-high { color: var(--green); }
.pct-strong.pct-mid  { color: var(--amber); }
.pct-strong.pct-low  { color: var(--red); }

/* ============ Status pills (Shopall uslubi) ============ */
.spill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px; font-size: 12px; font-weight: 650; white-space: nowrap; }
.spill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-ok   { background: var(--green-soft); color: var(--green); }
.pill-warn { background: var(--amber-soft); color: var(--amber); }
.pill-bad  { background: var(--red-soft); color: var(--red); }
.pill-info { background: var(--blue-soft); color: var(--blue); }

/* ============ Badges (active/inactive) ============ */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 650; }
.badge::before { content:""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok  { background: var(--green-soft); color: var(--green); }
.badge-off { background: #f1f2f5; color: var(--muted); }

/* ============ Forms ============ */
.field { display: block; margin-bottom: 16px; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 7px; }
input[type="text"], input[type="password"], input[type="number"], input[type="month"], select, textarea {
    width: 100%; padding: 10px 13px; border: 1px solid var(--border-2); border-radius: var(--radius-sm);
    font-size: 14px; font-family: inherit; color: var(--text); background: var(--surface);
    transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3.5px rgba(79,70,229,.13); }
textarea { resize: vertical; }
.inp-xs { width: 80px; }
.checkline { display: inline-flex; align-items: center; gap: 9px; font-size: 14px; cursor: pointer; margin-bottom: 16px; user-select: none; }
.checkline input { width: 17px; height: 17px; accent-color: var(--accent); }
.form-actions { display: flex; gap: 10px; margin-top: 8px; align-items: center; }
.selector { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
.selector .field { margin-bottom: 0; min-width: 210px; }

/* ============ Score pills (segmented) ============ */
.score-pills { display: inline-flex; gap: 6px; }
.pill { position: relative; cursor: pointer; }
.pill input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.pill span { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border: 1px solid var(--border-2); border-radius: var(--radius-sm); font-weight: 650; font-size: 14px; color: var(--muted); background: var(--surface); transition: all .1s; }
.pill:hover span { border-color: var(--accent); color: var(--accent-dark); }
.pill input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 3px 8px rgba(79,70,229,.3); }
.pill input:focus-visible + span { box-shadow: 0 0 0 3.5px rgba(79,70,229,.2); }
.table-eval td { padding-top: 11px; padding-bottom: 11px; }

/* ============ Result box ============ */
.result-box { display: flex; gap: 36px; margin-top: 20px; padding: 18px 22px; background: var(--accent-soft); border: 1px solid var(--accent-soft2); border-radius: var(--radius); }
.result-item { display: flex; flex-direction: column; gap: 3px; }
.result-item strong { font-size: 24px; font-weight: 750; }

/* ============ Buttons ============ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 10px 17px; border-radius: var(--radius-sm); border: 1px solid transparent; font-size: 14px; font-weight: 650; font-family: inherit; cursor: pointer; white-space: nowrap; transition: all .12s; line-height: 1; }
.btn .ico { width: 17px; height: 17px; }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: var(--radius-xs); }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 3px 10px rgba(79,70,229,.28); }
.btn-primary:hover { background: var(--accent-dark); box-shadow: 0 5px 14px rgba(79,70,229,.34); }
.btn-ghost { background: var(--surface); border-color: var(--border-2); color: var(--text-2); }
.btn-ghost:hover { background: #f6f7f9; border-color: var(--muted-2); color: var(--text); }
.btn-danger { background: var(--red-soft); color: var(--red); border-color: #fecdd3; }
.btn-danger:hover { background: #ffe4e6; }
.inline { display: inline; }

/* ============ Alerts ============ */
.alert { display: flex; align-items: center; gap: 9px; padding: 12px 15px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: 14px; font-weight: 500; border: 1px solid transparent; }
.alert-success { background: var(--green-soft); color: #15803d; border-color: #bbf7d0; }
.alert-error   { background: var(--red-soft); color: #be123c; border-color: #fecdd3; }
.alert-info    { background: var(--accent-soft); color: var(--accent-dark); border-color: var(--accent-soft2); }

/* ============ Login ============ */
.auth-body { background: var(--bg); }
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 400px; margin-bottom: 0; padding: 34px 32px; box-shadow: var(--shadow-lg); border-radius: 20px; }
.login-head { text-align: center; margin-bottom: 24px; }
.login-head .brand-mark { width: 54px; height: 54px; border-radius: 16px; margin: 0 auto 16px; }
.login-head .brand-mark .ico { width: 28px; height: 28px; }
.login-head h1 { font-size: 21px; margin-bottom: 5px; }
.login-hint { font-size: 12.5px; text-align: center; margin: 18px 0 0; line-height: 1.55; color: var(--muted); }
.lang-switch-login { justify-content: center; margin: 20px auto 0; }

/* ============ Criteria ============ */
.table-criteria td { padding: 9px 12px; }
.col-sort { width: 96px; }
.col-max  { width: 116px; }
.col-act  { width: 76px; text-align: center; }
.col-act input { width: 17px; height: 17px; accent-color: var(--accent); }

/* ============ Responsive ============ */
@media (max-width: 1040px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }

@media (max-width: 880px) {
    .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
    body.nav-open .sidebar { transform: translateX(0); }
    body.nav-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(17,24,39,.4); z-index: 35; }
    .nav-toggle { display: inline-flex; align-items: center; justify-content: center; background: none; border: 1px solid var(--border-2); border-radius: var(--radius-xs); padding: 7px; cursor: pointer; color: var(--text-2); }
    .topbar { padding: 0 16px; height: 56px; }
    .main { padding: 20px 18px 48px; }
}

@media (max-width: 560px) {
    .stats-grid { grid-template-columns: 1fr; }
    .selector .field { min-width: 100%; }
    .selector .btn { width: 100%; }
    h1 { font-size: 19px; }
    .crumb-root, .crumb-sep { display: none; }
    .result-box { gap: 24px; }
}
