/* ============================================================
   KUTUBXONA ARM — "Kitob tokchasi" dizayn tizimi
   Palitra:  tun #131C36 · siyoh #1C2440 · fon #F4F6FB
             kobalt #3B54D6 · mis #B45309
   Shrift:   Bricolage Grotesque (sarlavha) · Schibsted Grotesk (matn)
             JetBrains Mono (raqam/sana/inventar)
   Imzo:     statistika qatori — tokchadagi kitoblar (rangli muqova
             tirqishlari + tokcha chizig'i); faol nav — sug'urilgan kitob
   ============================================================ */

:root {
  --tun: #131c36;
  --tun-soft: #1d2a4e;
  --siyoh: #1c2440;
  --fon: #f4f6fb;
  --karta: #ffffff;
  --karta-soft: #fafbfe;
  --hover: #f8f9fd;
  --chiziq: #e3e8f2;
  --chiziq-soft: #eef1f8;
  --muted: #5b6478;
  --kobalt: #3b54d6;
  --kobalt-quyuq: #2e44b8;
  --kobalt-yengil: #eef1fd;
  --mis: #b45309;
  --mis-yengil: #fdf1e0;
  --ok: #15803d;
  --ok-yengil: #e7f4ec;
  --err: #c22b2b;
  --err-yengil: #fbeaea;
  --warn: #c2410c;
  --warn-yengil: #fdeee5;
  --spine-1: #3b54d6;
  --spine-2: #0d8a72;
  --spine-3: #d97706;
  --spine-4: #7c4dbe;
  --spine-5: #c23e64;
  --soya: 0 18px 44px -26px rgba(19, 28, 54, 0.35);
  --soya-past: 0 8px 22px -16px rgba(19, 28, 54, 0.28);
  --r-lg: 16px;
  --r-md: 12px;
  --r-sm: 9px;
  --display: "Bricolage Grotesque", "Schibsted Grotesk", system-ui, sans-serif;
  --body: "Schibsted Grotesk", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

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

/* hidden atributi har doim yashirsin */
[hidden] { display: none !important; }

body {
  font-family: var(--body);
  background: var(--fon);
  color: var(--siyoh);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Ikonkalar */
.ico {
  width: 18px; height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
  vertical-align: -3px;
}

/* Klaviatura fokusi */
:focus-visible { outline: 2px solid var(--kobalt); outline-offset: 2px; border-radius: 4px; }

button { font-family: inherit; }

/* ============ LOGIN (vitrina) ============ */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: stretch;
  background: var(--fon);
}
.login-hero {
  flex: 1.15;
  background:
    radial-gradient(700px 500px at 20% -10%, rgba(59, 84, 214, 0.35) 0%, transparent 60%),
    var(--tun);
  display: grid;
  place-items: center;
  padding: 48px 40px;
}
.login-hero-inner { max-width: 440px; }
.login-shelf { width: 100%; height: auto; margin-bottom: 34px; }
.login-hero-title {
  font-family: var(--display);
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
  line-height: 1.2;
}
.login-hero-sub { color: rgba(255, 255, 255, 0.55); font-size: 14.5px; line-height: 1.55; margin-top: 12px; }
.login-side {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 48px 24px;
  background: radial-gradient(700px 460px at 50% -12%, rgba(59, 84, 214, 0.08) 0%, transparent 62%), var(--fon);
}
@media (max-width: 860px) {
  .login-hero { display: none; }
}
.login-card {
  background: var(--karta);
  border-radius: 20px;
  padding: 44px 40px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: var(--soya);
  border: 1px solid var(--chiziq);
}
.login-mark {
  width: 60px; height: 60px;
  margin: 0 auto 18px;
  display: grid; place-items: center;
  color: #fff;
  background: linear-gradient(150deg, var(--kobalt), var(--tun-soft));
  border-radius: 16px;
}
.login-mark .ico { width: 28px; height: 28px; }
.login-title { font-family: var(--display); font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.login-sub { color: var(--muted); font-size: 13px; font-weight: 500; margin-top: 4px; margin-bottom: 26px; }
.login-input {
  width: 100%;
  border: 1px solid var(--chiziq);
  border-radius: var(--r-md);
  padding: 13px 16px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  margin-bottom: 12px;
  background: var(--fon);
  transition: border-color 0.2s, background 0.2s;
}
.login-input:focus { border-color: var(--kobalt); background: var(--karta); }
.login-btn {
  width: 100%;
  border: none;
  background: var(--kobalt);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  padding: 13px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background 0.2s;
}
.login-btn:hover { background: var(--kobalt-quyuq); }
.login-error { color: var(--err); font-size: 13px; font-weight: 600; margin-top: 14px; }
.login-foot { color: var(--muted); font-size: 13px; font-weight: 500; }

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

.sidebar {
  width: 264px;
  flex-shrink: 0;
  background: var(--tun);
  color: #fff;
  padding: 24px 16px 20px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 24px; }
.brand-mark {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  color: #fff;
  background: linear-gradient(150deg, var(--kobalt), var(--tun-soft));
  border-radius: 11px;
}
.brand-mark .ico { width: 20px; height: 20px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-title { font-family: var(--display); font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 10px; color: rgba(255,255,255,0.45); font-weight: 700; letter-spacing: 0.14em; }

.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.66);
  font-weight: 500;
  font-size: 13.5px;
  padding: 11px 13px;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  position: relative;
  transition: background 0.18s, color 0.18s, transform 0.18s;
}
.nav-item .ico { width: 17px; height: 17px; opacity: 0.85; }
.nav-item:hover { background: rgba(255,255,255,0.07); color: #fff; }
/* Faol band — tokchadan sug'urilgan kitob */
.nav-item.active {
  background: var(--karta);
  color: var(--siyoh);
  font-weight: 600;
  transform: translateX(5px);
  box-shadow: inset 3px 0 0 var(--kobalt), 0 6px 18px -8px rgba(0,0,0,0.5);
}
.nav-item.active .ico { color: var(--kobalt); opacity: 1; }
.nav-badge {
  margin-left: auto;
  background: var(--err);
  color: #fff;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 20px;
  display: grid;
  place-items: center;
}
.nav-item.active .nav-badge { background: var(--err); }
.logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid rgba(255,255,255,0.14);
  background: transparent;
  color: rgba(255,255,255,0.66);
  font-weight: 500;
  font-size: 13px;
  padding: 11px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.logout-btn .ico { width: 16px; height: 16px; }
.logout-btn:hover { background: rgba(255,255,255,0.07); color: #fff; }

.content { flex: 1; padding: 38px 44px 64px; max-width: 1500px; width: 100%; min-width: 0; }
.view-title { font-family: var(--display); font-size: 27px; font-weight: 800; letter-spacing: -0.02em; }
.view-lead { color: var(--muted); font-size: 14px; margin-top: 6px; font-weight: 400; }
.view-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.head-actions .ghost-btn { text-decoration: none; }

/* ============ IMZO: STAT-TOKCHA ============ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-top: 28px;
  position: relative;
  padding-bottom: 16px;
}
/* Tokcha chizig'i — kartalar "kitobdek" ustida turadi */
.stat-grid::after {
  content: "";
  position: absolute;
  left: -4px; right: -4px; bottom: 0;
  height: 6px;
  border-radius: 6px;
  background: linear-gradient(180deg, #dfe4f0, #cdd4e6);
}
.stat {
  background: var(--karta);
  border: 1px solid var(--chiziq);
  border-radius: 12px 12px 4px 4px;
  padding: 20px 20px 20px 24px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--soya-past);
}
/* Muqova tirqishi (spine) */
.stat::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 6px;
  background: var(--spine-1);
}
.stat:nth-child(2)::before { background: var(--spine-2); }
.stat:nth-child(3)::before { background: var(--spine-4); }
.stat:nth-child(4)::before { background: var(--spine-3); }
.stat:nth-child(5)::before { background: var(--spine-5); }
.stat-num { display: block; font-family: var(--display); font-size: 36px; font-weight: 800; line-height: 1; color: var(--siyoh); letter-spacing: -0.02em; }
.stat-label { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin-top: 10px; }
.stat-warn .stat-num { color: var(--warn); }

/* Bo'lim sarlavhasi */
.section-heading {
  font-family: var(--display);
  font-size: 18px;
  font-weight: 700;
  margin: 40px 0 16px;
  padding-top: 24px;
  border-top: 1px solid var(--chiziq);
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-heading::before {
  content: "";
  width: 5px; height: 20px;
  border-radius: 4px;
  background: var(--kobalt);
}
.section-heading.first { margin-top: 26px; padding-top: 0; border-top: none; }

/* Davriy statistika kartalari — sana shtampi */
.period-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.period {
  background: var(--karta);
  color: var(--siyoh);
  border: 1px solid var(--chiziq);
  border-radius: var(--r-md);
  padding: 20px;
  position: relative;
  cursor: pointer;
  text-align: left;
  box-shadow: var(--soya-past);
  transition: transform 0.15s, box-shadow 0.2s, border-color 0.2s, background 0.2s;
}
.period:hover { transform: translateY(-3px); border-color: var(--kobalt); box-shadow: 0 16px 32px -18px rgba(59, 84, 214, 0.45); }
.period.active { background: var(--kobalt); border-color: var(--kobalt); color: #fff; }
.period.active::before { content: "▾"; position: absolute; top: 10px; right: 13px; color: rgba(255,255,255,0.75); font-size: 13px; }
.period-num { display: block; font-family: var(--mono); font-size: 30px; font-weight: 700; line-height: 1; }
.period-label { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin-top: 9px; }
.period.active .period-label { color: rgba(255,255,255,0.72); }

/* ============ DASHBOARD VIZUAL QATOR: 30 kunlik dinamika + fond donut ============ */
.dash-viz { display: grid; grid-template-columns: 1.7fr 1fr; gap: 16px; margin-top: 24px; }
.viz-card {
  background: var(--karta);
  border: 1px solid var(--chiziq);
  border-radius: var(--r-lg);
  padding: 20px 22px;
  box-shadow: var(--soya-past);
  min-width: 0;
}
.viz-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.viz-title { font-family: var(--display); font-size: 14px; font-weight: 700; }
.viz-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.viz-sub b { font-family: var(--mono); color: var(--kobalt); font-size: 14px; }
.viz-area { display: block; width: 100%; height: 150px; }
.viz-axis { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 10.5px; color: var(--muted); margin-top: 6px; }

/* Trend belgisi */
.trend { font-family: var(--mono); font-size: 11.5px; font-weight: 700; padding: 5px 10px; border-radius: 20px; white-space: nowrap; }
.trend.up { background: var(--ok-yengil); color: var(--ok); }
.trend.down { background: var(--err-yengil); color: var(--err); }
.trend.flat { background: var(--fon); color: var(--muted); }

/* Fond donut */
.fund-wrap { display: flex; align-items: center; gap: 20px; }
.fund-donut-box { position: relative; width: 130px; height: 130px; flex-shrink: 0; }
.fund-donut { width: 100%; height: 100%; }
.fund-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none;
}
.fund-center b { font-family: var(--display); font-size: 24px; font-weight: 800; line-height: 1; }
.fund-center span { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin-top: 3px; }
.fund-legend { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.fund-leg-row { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.fund-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.fund-leg-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--siyoh); font-weight: 500; }
.fund-leg-num { font-family: var(--mono); font-size: 12px; font-weight: 700; color: var(--muted); }

@media (max-width: 1100px) { .dash-viz { grid-template-columns: 1fr; } }
@media (max-width: 480px) { .fund-wrap { flex-direction: column; } .fund-legend { width: 100%; } }

/* Kesim bar-chartlar */
.breakdown-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 24px; }
.breakdown-grid .breakdown-card:first-child { grid-column: 1 / -1; }
.breakdown-card {
  background: var(--karta);
  border: 1px solid var(--chiziq);
  border-radius: var(--r-lg);
  padding: 22px 24px;
  box-shadow: var(--soya-past);
}
.breakdown-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.breakdown-title { font-family: var(--display); font-size: 14px; font-weight: 700; }
.breakdown-total { font-family: var(--mono); font-size: 11px; font-weight: 700; color: var(--muted); background: var(--fon); border: 1px solid var(--chiziq); padding: 2px 9px; border-radius: 20px; }
.bars { display: flex; flex-direction: column; gap: 5px; }
/* Analitika uslubi: chiziq yorliq orqasida yumshoq fon bo'lib yotadi */
.pl-row {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  overflow: hidden;
  min-height: 36px;
}
.pl-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: var(--kobalt-yengil);
  border-radius: 8px;
  animation: plGrow 0.5s ease;
  transition: background 0.15s;
}
.pl-row:hover .pl-fill { background: color-mix(in srgb, var(--kobalt) 22%, transparent); }
@keyframes plGrow { from { width: 0; } }
.pl-label { position: relative; flex: 1; min-width: 0; font-size: 13px; font-weight: 500; color: var(--siyoh); line-height: 1.35; overflow-wrap: break-word; }
.pl-pct { position: relative; font-family: var(--mono); font-size: 11px; font-weight: 500; color: var(--muted); flex-shrink: 0; }
.pl-count { position: relative; font-family: var(--mono); font-size: 13px; font-weight: 700; color: var(--kobalt); flex-shrink: 0; min-width: 26px; text-align: right; }
.bars-empty { font-size: 13px; color: var(--muted); padding: 6px 0; }

/* Davr batafsil paneli */
.period-detail { margin-top: 18px; animation: rise 0.3s ease; }
.period-detail-head {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
  background: var(--kobalt-yengil); border: 1px solid #d5dcf8; border-radius: var(--r-md);
  padding: 16px 20px; margin-bottom: 4px;
}
.period-detail-head h3 { font-family: var(--display); font-size: 17px; font-weight: 700; }
.period-detail-sum { display: flex; gap: 20px; font-size: 14px; color: var(--siyoh); font-weight: 500; }
.period-detail-sum b { font-family: var(--mono); color: var(--kobalt); font-size: 16px; }
.period-detail .breakdown-grid .breakdown-card:first-child { grid-column: auto; }

/* ============ QIDIRUV ============ */
.search-box {
  margin: 26px 0 0;
  max-width: 560px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--karta);
  border: 1px solid var(--chiziq);
  border-radius: 14px;
  padding: 7px 7px 7px 18px;
  box-shadow: var(--soya-past);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-box:focus-within { border-color: var(--kobalt); box-shadow: 0 0 0 3px rgba(59, 84, 214, 0.14); }
.search-prefix { font-family: var(--mono); font-size: 18px; color: var(--kobalt); font-weight: 700; display: inline-flex; }
.search-prefix .ico { width: 19px; height: 19px; }
.search-input { flex: 1; min-width: 0; border: none; outline: none; font-family: var(--mono); font-size: 16px; letter-spacing: 0.03em; color: var(--siyoh); background: transparent; }
.search-input::placeholder { color: #a3adc4; letter-spacing: normal; font-family: var(--body); }
.search-btn { border: none; background: var(--kobalt); color: #fff; font-weight: 700; font-size: 14px; padding: 12px 24px; border-radius: 10px; cursor: pointer; transition: background 0.2s, transform 0.1s; }
.search-btn:hover { background: var(--kobalt-quyuq); }
.search-btn:active { transform: scale(0.97); }
.search-btn:disabled { opacity: 0.6; cursor: wait; }

.status-msg { margin-top: 18px; max-width: 560px; font-size: 14px; font-weight: 500; padding: 12px 16px; border-radius: var(--r-md); }
.status-msg.err { background: var(--err-yengil); color: var(--err); }
.status-msg.info { background: var(--kobalt-yengil); color: var(--tun-soft); }

/* ============ O'QUVCHI KARTASI (katalog kartochkasi) ============ */
.cat-card {
  position: relative;
  margin-top: 26px;
  background: var(--karta);
  border: 1px solid var(--chiziq);
  border-radius: var(--r-lg);
  box-shadow: var(--soya);
  overflow: hidden;
  animation: rise 0.35s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
.cat-card-rail { position: absolute; top: 0; left: 0; right: 0; height: 5px; background: linear-gradient(90deg, var(--kobalt), #6478e8); }
.cat-card-body { display: flex; gap: 28px; padding: 38px 34px 26px; }
.cat-photo { flex-shrink: 0; width: 124px; height: 158px; border-radius: var(--r-md); overflow: hidden; background: var(--fon); border: 1px solid var(--chiziq); display: grid; place-items: center; }
.cat-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cat-photo-fallback { color: #b9c1d6; }
.cat-photo-fallback .ico { width: 48px; height: 48px; stroke-width: 1.5; }
.cat-main { flex: 1; min-width: 0; }
.cat-id-row { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; flex-wrap: wrap; }
.cat-id { font-family: var(--mono); font-size: 13px; font-weight: 700; color: var(--kobalt); letter-spacing: 0.05em; }
.cat-badge { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--tun-soft); background: var(--kobalt-yengil); padding: 4px 10px; border-radius: 20px; }
.cat-name { font-family: var(--display); font-weight: 700; font-size: 24px; line-height: 1.15; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--chiziq); letter-spacing: -0.01em; }
.cat-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 28px; margin-bottom: 22px; }
.cat-field dt { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin-bottom: 4px; }
.cat-field dd { font-size: 14.5px; font-weight: 600; color: var(--siyoh); line-height: 1.3; }
.phone-block { background: var(--fon); border: 1px solid var(--chiziq); border-radius: var(--r-md); padding: 16px 18px; }
.phone-label { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin-bottom: 8px; }
.phone-row { display: flex; gap: 10px; }
.phone-input { flex: 1; min-width: 0; border: 1px solid var(--chiziq); border-radius: var(--r-sm); padding: 10px 14px; font-family: var(--mono); font-size: 14px; color: var(--siyoh); outline: none; background: var(--karta); transition: border-color 0.2s; }
.phone-input:focus { border-color: var(--kobalt); }
.phone-save { border: none; background: var(--kobalt); color: #fff; font-weight: 700; font-size: 14px; padding: 0 22px; border-radius: var(--r-sm); cursor: pointer; transition: background 0.2s, transform 0.1s; }
.phone-save:hover { background: var(--kobalt-quyuq); }
.phone-save:active { transform: scale(0.97); }
.phone-hint { display: block; font-size: 12px; color: var(--muted); margin-top: 8px; }

/* Kitob berish zonasi */
.issue-zone { border-top: 1px solid var(--chiziq); padding: 22px 34px 28px; background: var(--karta-soft); }
.issue-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; flex-wrap: wrap; }
.issue-head h3 { font-family: var(--display); font-size: 16px; font-weight: 700; }
.issue-open-btn { display: inline-flex; align-items: center; gap: 7px; border: none; background: var(--kobalt); color: #fff; font-weight: 700; font-size: 13px; padding: 9px 16px; border-radius: var(--r-sm); cursor: pointer; transition: background 0.2s; }
.issue-open-btn .ico { width: 15px; height: 15px; }
.issue-open-btn:hover { background: var(--kobalt-quyuq); }
.loan-mini-list { display: flex; flex-direction: column; gap: 8px; }
.loan-mini {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--karta); border: 1px solid var(--chiziq); border-radius: var(--r-sm); padding: 11px 14px;
}
.loan-mini.overdue { border-color: #f2cebc; background: var(--warn-yengil); }
.loan-mini-title { font-weight: 600; font-size: 14px; flex: 1; min-width: 140px; }
.loan-mini-due { font-family: var(--mono); font-size: 12px; color: var(--muted); font-weight: 500; }
.loan-mini.overdue .loan-mini-due { color: var(--warn); font-weight: 700; }
.loan-mini-return { border: 1px solid var(--chiziq); background: var(--karta); color: var(--siyoh); font-weight: 600; font-size: 12px; padding: 7px 13px; border-radius: 8px; cursor: pointer; transition: background 0.15s, border-color 0.15s; }
.loan-mini-return:hover { background: var(--kobalt-yengil); border-color: var(--kobalt); color: var(--kobalt); }
.loan-empty { font-size: 13px; color: var(--muted); padding: 6px 2px; }

/* ============ TUGMALAR ============ */
.primary-btn { display: inline-flex; align-items: center; gap: 7px; border: none; background: var(--kobalt); color: #fff; font-weight: 700; font-size: 14px; padding: 11px 20px; border-radius: 10px; cursor: pointer; transition: background 0.2s, transform 0.1s; white-space: nowrap; }
.primary-btn .ico { width: 15px; height: 15px; }
.primary-btn:hover { background: var(--kobalt-quyuq); }
.primary-btn:active { transform: scale(0.97); }
.primary-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.ghost-btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--chiziq); background: var(--karta); color: var(--siyoh); font-weight: 600; font-size: 14px; padding: 10px 18px; border-radius: 10px; cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.ghost-btn .ico { width: 15px; height: 15px; color: var(--muted); }
.ghost-btn:hover { border-color: var(--kobalt); background: var(--kobalt-yengil); }

/* ============ JADVALLAR ============ */
.table-search {
  width: 100%;
  margin: 22px 0 14px;
  border: 1px solid var(--chiziq);
  border-radius: var(--r-md);
  padding: 12px 16px;
  font-size: 14px;
  font-family: inherit;
  background: var(--karta);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.table-search:focus { border-color: var(--kobalt); box-shadow: 0 0 0 3px rgba(59, 84, 214, 0.12); }

/* Filtrlar */
.filter-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.filter-select {
  border: 1px solid var(--chiziq);
  border-radius: var(--r-sm);
  padding: 9px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--siyoh);
  background: var(--karta);
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}
.filter-select:focus { border-color: var(--kobalt); }
.filter-check { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 500; color: var(--siyoh); cursor: pointer; }
.filter-check input { width: 16px; height: 16px; accent-color: var(--kobalt); cursor: pointer; }
.filter-clear { border: none; background: transparent; color: var(--err); font-weight: 600; font-size: 13px; cursor: pointer; padding: 8px 10px; }
.filter-clear:hover { text-decoration: underline; }
.table-wrap { margin-top: 20px; background: var(--karta); border: 1px solid var(--chiziq); border-radius: var(--r-lg); overflow-x: auto; box-shadow: var(--soya-past); }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { white-space: nowrap; }
.data-table td { overflow-wrap: break-word; }
.data-table td.nowrap, .data-table th.nowrap { white-space: nowrap; }
.data-table th { text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); padding: 13px 18px; border-bottom: 1px solid var(--chiziq); background: var(--hover); }
.data-table th.num, .data-table td.num { text-align: center; }
.data-table td { padding: 13px 18px; font-size: 14px; border-bottom: 1px solid var(--chiziq-soft); vertical-align: middle; }
.data-table tbody tr:last-child td, .data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--hover); }
.td-title { font-weight: 600; }
.td-sub { font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 1px; }
.chip { display: inline-block; font-family: var(--mono); font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; }
.chip-ok { background: var(--ok-yengil); color: var(--ok); }
.chip-warn { background: var(--warn-yengil); color: var(--warn); }
.chip-zero { background: var(--err-yengil); color: var(--err); }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--chiziq); background: var(--karta); color: var(--siyoh); border-radius: 8px; min-width: 34px; min-height: 34px; padding: 6px 10px; font-size: 13px; font-weight: 600; cursor: pointer; transition: background 0.15s, border-color 0.15s, color 0.15s; }
.icon-btn .ico { width: 15px; height: 15px; }
.icon-btn:hover { background: var(--kobalt-yengil); border-color: var(--kobalt); }
.icon-btn.danger:hover { background: var(--err-yengil); border-color: #eec4c4; color: var(--err); }
.icon-btn.accent { background: var(--kobalt); color: #fff; border-color: var(--kobalt); }
.icon-btn.accent:hover { background: var(--kobalt-quyuq); }
.empty-state { padding: 40px; text-align: center; color: var(--muted); font-size: 14px; }
.overdue-days { color: var(--warn); font-weight: 700; font-family: var(--mono); }

/* ============ MODAL ============ */
.modal { position: fixed; inset: 0; background: rgba(19, 28, 54, 0.5); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 100; padding: 20px; animation: fade 0.2s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-box { background: var(--karta); border-radius: var(--r-lg); width: 100%; max-width: 480px; box-shadow: var(--soya); animation: rise 0.25s ease; max-height: 90vh; overflow-y: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 22px 24px 0; }
.modal-head h3 { font-family: var(--display); font-size: 19px; font-weight: 700; }
.modal-x { display: grid; place-items: center; width: 34px; height: 34px; border: none; background: transparent; color: var(--muted); cursor: pointer; border-radius: 8px; transition: background 0.15s, color 0.15s; }
.modal-x .ico { width: 18px; height: 18px; }
.modal-x:hover { color: var(--siyoh); background: var(--fon); }
.modal-form { padding: 18px 24px 24px; display: flex; flex-direction: column; gap: 14px; }
.modal-form label { display: flex; flex-direction: column; gap: 6px; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.modal-form input, .modal-form select { border: 1px solid var(--chiziq); border-radius: var(--r-sm); padding: 11px 14px; font-size: 14px; font-family: var(--body); color: var(--siyoh); outline: none; transition: border-color 0.2s; background: var(--karta); }
.modal-form input:focus, .modal-form select:focus { border-color: var(--kobalt); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.issue-student { font-family: var(--display); font-size: 16px; font-weight: 700; padding: 10px 14px; background: var(--kobalt-yengil); border-radius: var(--r-sm); text-transform: none; letter-spacing: normal; color: var(--siyoh); }

/* Nusxalar muharriri */
.copies-block { display: flex; flex-direction: column; gap: 8px; }
.copies-head { display: flex; align-items: center; justify-content: space-between; }
.copies-title { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.mini-btn { border: 1px solid var(--kobalt); background: var(--karta); color: var(--kobalt); font-weight: 700; font-size: 12px; padding: 6px 12px; border-radius: 7px; cursor: pointer; transition: background 0.15s; }
.mini-btn:hover { background: var(--kobalt-yengil); }
.copies-list { display: flex; flex-direction: column; gap: 8px; max-height: 220px; overflow-y: auto; }
.copy-row { display: flex; align-items: center; gap: 8px; }
.copy-row .copy-inv { flex: 1; min-width: 0; border: 1px solid var(--chiziq); border-radius: 8px; padding: 9px 12px; font-family: var(--mono); font-size: 13px; outline: none; transition: border-color 0.2s; }
.copy-row .copy-inv:focus { border-color: var(--kobalt); }
.copy-row .copy-inv:disabled { background: var(--fon); color: var(--muted); }
.copy-num { font-size: 12px; font-weight: 700; color: var(--muted); font-family: var(--mono); min-width: 22px; }
.copy-del { border: 1px solid var(--chiziq); background: var(--karta); color: var(--muted); width: 34px; height: 34px; border-radius: 8px; cursor: pointer; font-size: 16px; line-height: 1; flex-shrink: 0; transition: background 0.15s, color 0.15s, border-color 0.15s; }
.copy-del:hover { background: var(--err-yengil); border-color: #eec4c4; color: var(--err); }
.copy-del:disabled { opacity: 0.4; cursor: not-allowed; }
.copy-issued-tag { font-size: 10px; font-weight: 700; color: var(--warn); background: var(--warn-yengil); padding: 3px 7px; border-radius: 6px; white-space: nowrap; }
.copies-hint { font-size: 11px; color: var(--muted); }

/* Nusxa tanlash (kitob berish) */
.issue-copy-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.copy-pick { border: 1.5px solid var(--chiziq); background: var(--karta); font-family: var(--mono); font-size: 13px; font-weight: 700; color: var(--siyoh); padding: 8px 14px; border-radius: 8px; cursor: pointer; transition: border-color 0.15s, background 0.15s, color 0.15s; }
.copy-pick:hover { border-color: var(--kobalt); color: var(--kobalt); }
.copy-pick.selected { border-color: var(--kobalt); background: var(--kobalt); color: #fff; }
.copy-pick-empty { font-size: 13px; color: var(--muted); }

.issue-book-list { max-height: 200px; overflow-y: auto; border: 1px solid var(--chiziq); border-radius: var(--r-sm); display: flex; flex-direction: column; }
.issue-book-item { text-align: left; border: none; background: var(--karta); border-bottom: 1px solid var(--chiziq-soft); padding: 11px 14px; cursor: pointer; font-family: inherit; transition: background 0.12s; }
.issue-book-item:last-child { border-bottom: none; }
.issue-book-item:hover { background: var(--fon); }
.issue-book-item.selected { background: var(--kobalt-yengil); box-shadow: inset 3px 0 0 var(--kobalt); }
.issue-book-item.disabled { opacity: 0.45; cursor: not-allowed; }
.ibi-title { font-weight: 600; font-size: 14px; }
.ibi-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ============ TOAST ============ */
.toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); background: var(--tun); color: #fff; font-weight: 600; font-size: 14px; padding: 13px 22px; border-radius: var(--r-md); box-shadow: var(--soya); z-index: 200; animation: toastIn 0.25s ease; display: flex; align-items: center; gap: 14px; }
.toast-act {
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-weight: 700;
  font-size: 12.5px;
  padding: 6px 13px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.toast-act:hover { background: rgba(255, 255, 255, 0.24); }
.toast.ok { background: var(--ok); }
.toast.err { background: var(--err); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ============ O'QITUVCHI QIDIRUV NATIJALARI ============ */
.teacher-results { margin-top: 10px; max-width: 640px; display: flex; flex-direction: column; gap: 6px; }
.teacher-result { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "name id" "meta id"; gap: 0 12px; text-align: left; background: var(--karta); border: 1px solid var(--chiziq); border-radius: var(--r-md); padding: 11px 15px; cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s; }
.teacher-result:hover { border-color: var(--kobalt); box-shadow: 0 2px 10px rgba(19, 28, 54, 0.08); }
.tr-name { grid-area: name; font-weight: 600; font-size: 14px; color: var(--siyoh); }
.tr-meta { grid-area: meta; font-size: 12px; color: var(--muted); margin-top: 2px; }
.tr-id { grid-area: id; align-self: center; font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
.teacher-result-empty { padding: 14px; color: var(--muted); font-size: 14px; background: var(--karta); border: 1px dashed var(--chiziq); border-radius: var(--r-md); }
.borrower-tag { display: inline-flex; color: var(--kobalt); }
.borrower-tag .ico { width: 14px; height: 14px; }

/* ============ TALABA / XODIM TOGGLE ============ */
.stat-toggle { display: inline-flex; gap: 4px; background: var(--karta); border: 1px solid var(--chiziq); border-radius: var(--r-md); padding: 4px; margin: 6px 0 20px; }
.stat-toggle-btn { display: inline-flex; align-items: center; gap: 8px; border: none; background: transparent; color: var(--muted); font-weight: 600; font-size: 13.5px; padding: 9px 18px; border-radius: 9px; cursor: pointer; transition: background 0.15s, color 0.15s; }
.stat-toggle-btn .ico { width: 15px; height: 15px; }
.stat-toggle-btn:hover { color: var(--siyoh); }
.stat-toggle-btn.active { background: var(--tun); color: #fff; }
@media (max-width: 560px) { .stat-toggle { width: 100%; } .stat-toggle-btn { flex: 1; justify-content: center; padding: 9px 8px; } }

.loan-toggle { display: inline-flex; gap: 4px; background: var(--karta); border: 1px solid var(--chiziq); border-radius: var(--r-md); padding: 4px; margin: 0 0 14px; }
.loan-toggle-btn { display: inline-flex; align-items: center; gap: 7px; border: none; background: transparent; color: var(--muted); font-weight: 600; font-size: 13px; padding: 8px 15px; border-radius: 9px; cursor: pointer; transition: background 0.15s, color 0.15s; }
.loan-toggle-btn .ico { width: 14px; height: 14px; }
.loan-toggle-btn:hover { color: var(--siyoh); }
.loan-toggle-btn.active { background: var(--tun); color: #fff; }
@media (max-width: 560px) { .loan-toggle { width: 100%; } .loan-toggle-btn { flex: 1; justify-content: center; padding: 8px 6px; } }

/* ---- Kartoteka ---- */
.data-table tr.clickable { cursor: pointer; }
.data-table tr.clickable:hover td { background: var(--kobalt-yengil); }
#kartotekaBack { margin-bottom: 16px; }
.reader-head { margin-bottom: 18px; padding: 16px 18px; background: var(--karta); border: 1px solid var(--chiziq); border-radius: var(--r-md); }
.reader-head h2 { margin: 0 0 8px; font-family: var(--display); font-size: 19px; font-weight: 700; display: flex; align-items: center; gap: 9px; }
.reader-head h2 .ico { width: 18px; height: 18px; color: var(--kobalt); }
.reader-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 13px; color: var(--muted); }
.reader-meta b { color: var(--siyoh); }

/* ============ RESPONSIVE ============ */
@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 10px; padding: 14px 16px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav-item.active { transform: none; }
  .brand { padding: 0 4px; }
  .logout-btn { margin-left: auto; }
  .content { padding: 28px 20px 50px; }
  .cat-card-body { flex-direction: column; align-items: center; text-align: center; padding: 32px 22px 22px; }
  .cat-fields { grid-template-columns: 1fr; text-align: left; }
  .issue-zone { padding: 20px 22px 26px; }
  .breakdown-grid { grid-template-columns: 1fr; }
}

/* Responsiv jadval — tor ekranda kartochka ko'rinishi */
@media (max-width: 1024px) {
  .table-wrap { border: none; background: transparent; box-shadow: none; border-radius: 0; margin-top: 14px; }
  .data-table thead { display: none; }
  .data-table, .data-table tbody { display: block; width: 100%; }
  .data-table tr { display: block; background: var(--karta); border: 1px solid var(--chiziq); border-radius: 14px; margin-bottom: 12px; box-shadow: var(--soya-past); overflow: hidden; }
  .data-table tr:hover td { background: transparent; }
  .data-table td { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 10px 16px; border: none; border-bottom: 1px solid var(--chiziq-soft); font-size: 14px; text-align: right; }
  .data-table tr td:last-child { border-bottom: none; }
  .data-table td::before { content: attr(data-label); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); text-align: left; flex-shrink: 0; white-space: nowrap; }
  .data-table td[data-label=""]::before { content: none; }
  .data-table td[data-label=""] { justify-content: flex-end; padding-top: 12px; padding-bottom: 12px; }
  .data-table td.num { text-align: right; }
  .data-table .row-actions { width: auto; }
  .data-table .td-sub { text-align: right; }
}

/* ============ BERILGAN KITOBLAR — JURNAL KO'RINISHI ============
   Qidiruv + yig'ma faset-filtr paneli + ochiladigan qatorlar */
.llog-toolbar { display: flex; gap: 10px; margin: 20px 0 14px; }
.llog-search {
  flex: 1; display: flex; align-items: center; gap: 10px;
  background: var(--karta); border: 1px solid var(--chiziq); border-radius: var(--r-md);
  padding: 0 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.llog-search:focus-within { border-color: var(--kobalt); box-shadow: 0 0 0 3px rgba(59, 84, 214, 0.12); }
.llog-search .ico { width: 16px; height: 16px; color: var(--muted); }
.llog-search input { flex: 1; min-width: 0; border: none; outline: none; background: transparent; font: inherit; font-size: 14px; padding: 12px 0; color: var(--siyoh); }
.llog-filter-btn { position: relative; }
.llog-filter-btn.active { border-color: var(--kobalt); background: var(--kobalt); color: #fff; }
.llog-filter-btn.active .ico { color: #fff; }
.llog-fcount {
  position: absolute; top: -7px; right: -7px;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 18px; background: var(--err); color: #fff;
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  display: grid; place-items: center;
}

.llog-shell {
  display: flex; align-items: stretch;
  background: var(--karta); border: 1px solid var(--chiziq);
  border-radius: var(--r-lg); box-shadow: var(--soya-past);
  overflow: hidden;
}
.llog-main { flex: 1; min-width: 0; }
.llog-meta { padding: 10px 16px; font-family: var(--mono); font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--chiziq); background: var(--hover); }

/* Filtr paneli */
.llog-filter {
  width: 252px; flex-shrink: 0;
  border-right: 1px solid var(--chiziq);
  background: var(--karta-soft);
  padding: 16px;
  overflow-y: auto;
  max-height: 70vh;
  animation: fade 0.2s ease;
}
.llog-fhead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; font-size: 13px; font-weight: 700; }
.llog-fclear { border: none; background: transparent; color: var(--err); font-size: 12px; font-weight: 600; cursor: pointer; padding: 4px 6px; }
.llog-fclear:hover { text-decoration: underline; }
.llog-fgroup { margin-bottom: 18px; }
.llog-ftitle { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin-bottom: 8px; }
.llog-fbtn {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%;
  border: 1px solid var(--chiziq); background: var(--karta);
  border-radius: var(--r-sm);
  padding: 8px 11px;
  margin-bottom: 6px;
  font-size: 13px; color: var(--siyoh);
  cursor: pointer; text-align: left;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.llog-fbtn:hover { border-color: rgba(59, 84, 214, 0.45); background: var(--kobalt-yengil); }
.llog-fbtn.selected { border-color: var(--kobalt); background: var(--kobalt-yengil); color: var(--kobalt); font-weight: 600; }
.llog-fbtn-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.llog-fbtn-n { font-family: var(--mono); font-size: 11px; color: var(--muted); flex-shrink: 0; display: inline-flex; }
.llog-fbtn.selected .llog-fbtn-n { color: var(--kobalt); }
.llog-fbtn-n .ico { width: 13px; height: 13px; }

/* Qatorlar */
.llog-item + .llog-item { border-top: 1px solid var(--chiziq-soft); }
.llog-row {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 11px 16px;
  cursor: pointer;
  transition: background 0.15s;
}
.llog-row:hover { background: var(--hover); }
.llog-item.open .llog-row { background: var(--kobalt-yengil); }
.llog-chev { width: 15px; height: 15px; color: var(--muted); transition: transform 0.2s; }
.llog-item.open .llog-chev { transform: rotate(180deg); }
.llog-chip { flex-shrink: 0; }
.llog-time { font-family: var(--mono); font-size: 12px; color: var(--muted); flex-shrink: 0; width: 84px; }
.llog-name { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; flex-shrink: 0; max-width: 28%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.llog-msg { flex: 1; min-width: 0; font-size: 13.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.llog-days { font-family: var(--mono); font-size: 12px; font-weight: 700; color: var(--muted); flex-shrink: 0; }
.llog-days.warn { color: var(--warn); }
.llog-return { flex-shrink: 0; }

/* Ochilgan qator tafsiloti */
.llog-detail { border-top: 1px solid var(--chiziq); background: var(--karta-soft); padding: 16px 20px 18px 43px; animation: rise 0.2s ease; }
.llog-dgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px 24px; }
.llog-dgrid dt { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin-bottom: 3px; }
.llog-dgrid dd { font-size: 14px; font-weight: 500; color: var(--siyoh); line-height: 1.35; }
.llog-dgrid dd.mono { font-family: var(--mono); font-size: 13px; }

@media (max-width: 900px) {
  .llog-shell { flex-direction: column; }
  .llog-filter { width: 100%; max-height: none; border-right: none; border-bottom: 1px solid var(--chiziq); }
  .llog-row { flex-wrap: wrap; row-gap: 6px; }
  .llog-name { max-width: none; flex: 1; }
  .llog-msg { flex-basis: 100%; order: 8; white-space: normal; padding-left: 27px; }
  .llog-time { width: auto; }
  .llog-detail { padding-left: 20px; }
}

/* ============ KARTOTEKA: PROFIL SARLAVHASI + TIMELINE ============ */
.rp-mono-ava {
  width: 30px; height: 30px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--kobalt-yengil); color: var(--kobalt);
  font-family: var(--display); font-size: 11px; font-weight: 800;
  border-radius: 50%;
  letter-spacing: 0.02em;
}
.rp-head {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  background: var(--karta);
  border: 1px solid var(--chiziq);
  border-radius: var(--r-lg);
  padding: 20px 24px;
  box-shadow: var(--soya-past);
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}
.rp-head::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: linear-gradient(90deg, var(--kobalt), #6478e8); }
.rp-ava {
  width: 58px; height: 58px; flex-shrink: 0;
  display: grid; place-items: center;
  background: linear-gradient(150deg, var(--kobalt), var(--tun-soft));
  color: #fff;
  font-family: var(--display); font-size: 20px; font-weight: 800;
  border-radius: 16px;
}
.rp-main { flex: 1; min-width: 220px; }
.rp-name { font-family: var(--display); font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rp-meta { display: flex; flex-wrap: wrap; gap: 5px 16px; margin-top: 7px; font-size: 13px; color: var(--muted); }
.rp-meta .mono { font-family: var(--mono); font-size: 12px; }
.rp-stats { display: flex; gap: 10px; }
.rp-stat {
  min-width: 86px;
  background: var(--fon);
  border: 1px solid var(--chiziq);
  border-radius: var(--r-md);
  padding: 10px 14px;
  text-align: center;
}
.rp-stat b { display: block; font-family: var(--display); font-size: 22px; font-weight: 800; line-height: 1; }
.rp-stat span { display: block; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-top: 5px; }
.rp-stat.accent b { color: var(--kobalt); }
.rp-stat.warn b { color: var(--warn); }

/* Timeline kartasi */
.tl-card {
  background: var(--karta);
  border: 1px solid var(--chiziq);
  border-radius: var(--r-lg);
  padding: 22px 24px;
  box-shadow: var(--soya-past);
}
.tl-heading { font-family: var(--display); font-size: 15px; font-weight: 700; margin-bottom: 18px; }
.timeline { position: relative; display: flex; flex-direction: column; gap: 18px; padding-left: 4px; }
.timeline::before {
  content: "";
  position: absolute;
  left: 17px; top: 10px; bottom: 10px;
  width: 2px;
  background: var(--chiziq);
}
.tl-item { position: relative; display: flex; gap: 14px; }
.tl-dot {
  position: relative; z-index: 1;
  width: 28px; height: 28px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--kobalt-yengil); color: var(--kobalt);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1.5px var(--chiziq);
}
.tl-dot .ico { width: 13px; height: 13px; }
.tl-item.returned .tl-dot { background: var(--ok-yengil); color: var(--ok); }
.tl-item.late .tl-dot { background: var(--warn-yengil); color: var(--warn); }
.tl-item.overdue .tl-dot { background: var(--err-yengil); color: var(--err); }
.tl-item.active .tl-dot { background: var(--kobalt-yengil); color: var(--kobalt); }
.tl-body { flex: 1; min-width: 0; padding-top: 3px; }
.tl-row1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tl-book { font-size: 14px; font-weight: 600; color: var(--siyoh); }
.tl-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 5px; font-family: var(--mono); font-size: 11.5px; color: var(--muted); }

@media (max-width: 700px) {
  .rp-stats { width: 100%; }
  .rp-stat { flex: 1; min-width: 0; }
}

/* ============ KATALOG: MUQOVA-KARTOCHKA GRID ============ */
.view-toggle { display: inline-flex; gap: 3px; background: var(--karta); border: 1px solid var(--chiziq); border-radius: var(--r-sm); padding: 3px; margin-left: auto; }
.view-toggle-btn {
  display: grid; place-items: center;
  width: 34px; height: 30px;
  border: none; background: transparent;
  color: var(--muted);
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.view-toggle-btn .ico { width: 15px; height: 15px; }
.view-toggle-btn:hover { color: var(--siyoh); }
.view-toggle-btn.active { background: var(--kobalt); color: #fff; }

.bk-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 20px;
}
.bk-card {
  background: var(--karta);
  border: 1px solid var(--chiziq);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--soya-past);
  display: flex;
  flex-direction: column;
  transition: transform 0.15s, box-shadow 0.2s;
}
.bk-card:hover { transform: translateY(-3px); box-shadow: 0 16px 34px -18px rgba(19, 28, 54, 0.4); }
/* Generatsiya qilingan muqova: chap tomonda quyuq "spine" tirqishi */
.bk-cover {
  position: relative;
  min-height: 118px;
  padding: 14px 16px 14px 22px;
  color: #fff;
  background: linear-gradient(140deg, var(--cover), color-mix(in srgb, var(--cover) 55%, #10162e));
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 4px;
}
.bk-cover::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 9px;
  background: rgba(0, 0, 0, 0.28);
  border-right: 1px solid rgba(255, 255, 255, 0.14);
}
.bk-cover-type {
  position: absolute; top: 10px; right: 12px;
  font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em;
  background: rgba(255, 255, 255, 0.16);
  padding: 3px 8px;
  border-radius: 20px;
}
.bk-cover-title {
  font-family: var(--display);
  font-size: 15px; font-weight: 700; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.bk-cover-author { font-size: 11px; opacity: 0.75; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bk-body { padding: 12px 14px 13px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.bk-meta { font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.bk-avail { display: flex; align-items: center; gap: 10px; margin-top: auto; }
.bk-avail-bar { flex: 1; height: 6px; background: var(--chiziq-soft); border-radius: 6px; overflow: hidden; }
.bk-avail-bar span { display: block; height: 100%; background: var(--ok); border-radius: 6px; transition: width 0.4s ease; }
.bk-avail-bar.part span { background: var(--warn); }
.bk-avail-bar.zero span { background: var(--err); }
.bk-avail-num { font-family: var(--mono); font-size: 11.5px; font-weight: 700; color: var(--muted); }
.bk-actions { display: flex; gap: 8px; justify-content: flex-end; }

@media (max-width: 560px) { .bk-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; } }

/* ============ CTRL+K BUYRUQ PANELI ============ */
.sidebar-search {
  display: flex; align-items: center; gap: 9px;
  margin: 0 0 16px;
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.55);
  font-size: 12.5px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.sidebar-search:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.sidebar-search .ico { width: 14px; height: 14px; }
.sidebar-search span { flex: 1; text-align: left; }
.sidebar-search kbd, .cmdk-input-row kbd {
  font-family: var(--mono); font-size: 9.5px; font-weight: 700;
  padding: 3px 6px; border-radius: 5px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
}
.cmdk-input-row kbd { background: var(--fon); border-color: var(--chiziq); color: var(--muted); }

.cmdk {
  position: fixed; inset: 0;
  background: rgba(19, 28, 54, 0.5);
  backdrop-filter: blur(4px);
  z-index: 300;
  padding: 12vh 20px 20px;
  display: flex; justify-content: center; align-items: flex-start;
  animation: fade 0.15s ease;
}
.cmdk-box {
  width: 100%; max-width: 560px;
  background: var(--karta);
  border: 1px solid var(--chiziq);
  border-radius: var(--r-lg);
  box-shadow: var(--soya);
  overflow: hidden;
  animation: rise 0.18s ease;
}
.cmdk-input-row {
  display: flex; align-items: center; gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--chiziq);
}
.cmdk-input-row .ico { color: var(--muted); }
.cmdk-input-row input {
  flex: 1; min-width: 0;
  border: none; outline: none; background: transparent;
  font: inherit; font-size: 15px; color: var(--siyoh);
}
.cmdk-results { max-height: 46vh; overflow-y: auto; padding: 8px; }
.cmdk-group {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted);
  padding: 10px 12px 5px;
}
.cmdk-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  border: none; background: transparent;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  text-align: left;
  color: var(--siyoh);
}
.cmdk-item .ico { width: 16px; height: 16px; color: var(--muted); }
.cmdk-item:hover { background: var(--hover); }
.cmdk-item.sel { background: var(--kobalt-yengil); box-shadow: inset 3px 0 0 var(--kobalt); }
.cmdk-item.sel .ico { color: var(--kobalt); }
.cmdk-item-main { display: flex; flex-direction: column; min-width: 0; }
.cmdk-item-label { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-item-sub { font-size: 12px; color: var(--muted); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-empty { padding: 26px; text-align: center; color: var(--muted); font-size: 14px; }
:root[data-theme="dark"] .cmdk { background: rgba(4, 8, 18, 0.65); }

@media (max-width: 860px) { .sidebar-search { display: none; } }

/* ============ SKELETON YUKLANISH HOLATLARI ============ */
.skel {
  position: relative;
  overflow: hidden;
  background: var(--chiziq-soft);
  border-radius: 7px;
}
.skel::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  animation: shimmer 1.3s infinite;
}
:root[data-theme="dark"] .skel::after { background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent); }
@keyframes shimmer { 100% { transform: translateX(100%); } }
.skel-num { display: inline-block; width: 58px; height: 30px; }
.skel-row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--chiziq-soft);
}
.skel-row:last-child { border-bottom: none; }

/* ============ TUNGI REJIM ============ */
:root[data-theme="dark"] {
  --tun: #0b1122;
  --tun-soft: #182342;
  --siyoh: #e7ebf7;
  --fon: #0e1526;
  --karta: #161f38;
  --karta-soft: #121a30;
  --hover: #1c2745;
  --chiziq: #283454;
  --chiziq-soft: #202b48;
  --muted: #949db8;
  --kobalt: #8fa0f5;
  --kobalt-quyuq: #a5b3f8;
  --kobalt-yengil: rgba(100, 120, 232, 0.16);
  --mis: #e8963a;
  --mis-yengil: rgba(217, 119, 6, 0.16);
  --ok: #3fca82;
  --ok-yengil: rgba(21, 128, 61, 0.2);
  --err: #f07f7f;
  --err-yengil: rgba(194, 43, 43, 0.2);
  --warn: #f0925d;
  --warn-yengil: rgba(194, 65, 12, 0.18);
  --soya: 0 18px 44px -26px rgba(0, 0, 0, 0.7);
  --soya-past: 0 8px 22px -16px rgba(0, 0, 0, 0.55);
}
/* Tungi rejimda tugma fonlari — yorqin kobalt matn rangi sifatida qoladi,
   tugmalar esa o'qiladigan to'q kobaltda */
:root[data-theme="dark"] .primary-btn,
:root[data-theme="dark"] .login-btn,
:root[data-theme="dark"] .search-btn,
:root[data-theme="dark"] .phone-save,
:root[data-theme="dark"] .issue-open-btn,
:root[data-theme="dark"] .icon-btn.accent,
:root[data-theme="dark"] .copy-pick.selected,
:root[data-theme="dark"] .period.active,
:root[data-theme="dark"] .llog-filter-btn.active { background: #4c66e0; border-color: #4c66e0; color: #fff; }
:root[data-theme="dark"] .primary-btn:hover,
:root[data-theme="dark"] .login-btn:hover,
:root[data-theme="dark"] .search-btn:hover,
:root[data-theme="dark"] .phone-save:hover,
:root[data-theme="dark"] .issue-open-btn:hover,
:root[data-theme="dark"] .icon-btn.accent:hover { background: #5d74e6; }
:root[data-theme="dark"] .stat-toggle-btn.active,
:root[data-theme="dark"] .loan-toggle-btn.active { background: #4c66e0; color: #fff; }
:root[data-theme="dark"] .login-screen { background: radial-gradient(900px 520px at 50% -12%, #16204080 0%, transparent 62%), var(--fon); }
:root[data-theme="dark"] .stat-grid::after { background: linear-gradient(180deg, #223055, #1a2542); }
:root[data-theme="dark"] .search-input::placeholder { color: #5b6785; }
:root[data-theme="dark"] .cat-photo-fallback { color: #3a4666; }
:root[data-theme="dark"] .nav-item.active { box-shadow: inset 3px 0 0 var(--kobalt), 0 6px 18px -8px rgba(0, 0, 0, 0.8); }
:root[data-theme="dark"] .toast { background: #223055; }
:root[data-theme="dark"] .modal { background: rgba(4, 8, 18, 0.65); }

/* Tema almashtirgich (sidebar) */
.theme-btn { margin-bottom: 8px; }

/* ============ MAYDA SAYQALLAR ============ */
/* Sahifalar orasida silliq o'tish */
.view { animation: viewIn 0.18s ease; }
@keyframes viewIn { from { opacity: 0; transform: translateY(5px); } }

/* Bo'sh holat illyustratsiyasi — kitob tokchasi silueti */
.empty-state::before {
  content: "";
  display: block;
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  background: currentColor;
  opacity: 0.28;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'><path d='m16 6 4 14'/><path d='M12 6v14'/><path d='M8 8v12'/><path d='M4 4v16'/></svg>") center/contain no-repeat;
  mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'><path d='m16 6 4 14'/><path d='M12 6v14'/><path d='M8 8v12'/><path d='M4 4v16'/></svg>") center/contain no-repeat;
}

/* Kartoteka tarix tugmalari qatori */
.kd-actions { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
#kartotekaBack { margin-bottom: 0; }

/* ============ FORMULYAR CHOP ETISH ============ */
@media print {
  body * { visibility: hidden; }
  #kartotekaDetail, #kartotekaDetail * { visibility: visible; }
  #kartotekaDetail { position: absolute; left: 0; top: 0; width: 100%; }
  .kd-actions { display: none !important; }
  #kartotekaDetail::before {
    content: "Guliston davlat pedagogika instituti kutubxonasi — o'quvchi formulyari";
    visibility: visible;
    display: block;
    font-family: var(--display);
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 2px solid #000;
  }
  .rp-head, .tl-card { box-shadow: none; border: 1px solid #999; break-inside: avoid; }
  .rp-head::before { display: none; }
  .rp-ava { background: #1c2440 !important; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .timeline::before { background: #bbb; }
  .tl-item { break-inside: avoid; }
  .chip { border: 1px solid #999; }
}

/* Harakat kamaytirilgan rejim */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .period:hover, .nav-item.active { transform: none; }
}
