:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #eef0fe;
  --accent: #06b6d4;
  --sidebar-w: 258px;
  --bg-soft: #f4f5fb;
  --danger: #dc3545;
  --success: #198754;
  --warning: #fd7e14;
  --click-color: #00aaff;
  --click-dark: #0087cc;
  --radius-lg: 1.1rem;
  --radius-md: .75rem;
  --shadow-soft: 0 2px 10px rgba(30, 27, 58, .05);
  --shadow-hover: 0 12px 28px rgba(30, 27, 58, .12);
}

* { box-sizing: border-box; }

body {
  background: var(--bg-soft);
  background-image: radial-gradient(circle at 100% 0%, rgba(79, 70, 229, .05), transparent 40%);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #1f2430;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d5d7ea; border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

.app-wrapper { display: flex; min-height: 100vh; }

/* ---------- SIDEBAR ---------- */
.app-sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(190deg, #201c42 0%, #171335 100%);
  color: #cfd0f5;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1030;
  overflow-y: auto;
  transition: transform .25s ease;
  box-shadow: 4px 0 24px rgba(15, 12, 40, .12);
}
.sidebar-brand {
  font-size: 1.22rem;
  font-weight: 800;
  letter-spacing: .01em;
  color: #fff;
  padding: 1.4rem 1.25rem 1.1rem;
  display: flex;
  align-items: center;
  gap: .6rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: .5rem;
}
.sidebar-brand i { color: var(--accent); font-size: 1.4rem; }
.sidebar-nav { display: flex; flex-direction: column; padding: .5rem .65rem; gap: 3px; }
.sidebar-nav a {
  color: #b7b9e6;
  text-decoration: none;
  padding: .68rem 1rem;
  border-radius: .65rem;
  display: flex;
  align-items: center;
  gap: .7rem;
  font-size: .93rem;
  font-weight: 500;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
.sidebar-nav a i { font-size: 1.05rem; width: 1.2rem; text-align: center; opacity: .9; }
.sidebar-nav a:hover { background: rgba(255,255,255,.08); color: #fff; transform: translateX(2px); }
.sidebar-nav a.active {
  background: linear-gradient(135deg, var(--primary), #6d28d9);
  color: #fff;
  box-shadow: 0 6px 16px rgba(79, 70, 229, .35);
}
.sidebar-nav a.text-danger { color: #ff8686 !important; margin-top: .5rem; }
.sidebar-nav a.text-danger:hover { background: rgba(220, 53, 69, .12); color: #ff8686 !important; }

.app-main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar {
  height: 66px; background: rgba(255,255,255,.9); backdrop-filter: blur(8px);
  border-bottom: 1px solid #e7e8f0; position: sticky; top: 0; z-index: 1020;
  box-shadow: 0 1px 0 rgba(30,27,58,.02);
}
.app-content { flex: 1; }

.avatar-circle {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; text-transform: uppercase;
  box-shadow: 0 4px 10px rgba(79, 70, 229, .25);
}

@media (max-width: 991px) {
  .app-sidebar { transform: translateX(-100%); }
  .app-sidebar.show { transform: translateX(0); }
  .app-main { margin-left: 0; }
}

/* ---------- CARDS ---------- */
.stat-card {
  background: #fff; border-radius: var(--radius-lg); padding: 1.35rem;
  border: 1px solid #eceefa;
  height: 100%;
  box-shadow: var(--shadow-soft);
  transition: box-shadow .2s ease, transform .2s ease;
}
.stat-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.stat-card .label { color: #8b8fa3; font-size: .85rem; font-weight: 500; }
.stat-card .value { font-size: 1.55rem; font-weight: 800; margin-top: .3rem; letter-spacing: -.01em; }
.stat-icon {
  width: 46px; height: 46px; border-radius: .8rem;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; color: #fff;
  box-shadow: 0 6px 14px rgba(0,0,0,.12);
}

.card-soft {
  background: #fff; border-radius: var(--radius-lg); border: 1px solid #eceefa;
  box-shadow: var(--shadow-soft);
}

/* ---------- BUTTONS ---------- */
.btn { border-radius: .65rem; font-weight: 600; }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border: none;
  box-shadow: 0 6px 16px rgba(79, 70, 229, .28);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--primary-dark), #362f9c); box-shadow: 0 8px 20px rgba(79, 70, 229, .35); }
.btn-outline-primary { border-width: 1.5px; }

/* Click.uz to'lov tugmasi (avtomatik hisob to'ldirish) */
.btn-click {
  background: linear-gradient(135deg, var(--click-color), var(--click-dark));
  border: none; color: #fff;
  box-shadow: 0 6px 16px rgba(0, 170, 255, .3);
}
.btn-click:hover { color: #fff; background: linear-gradient(135deg, var(--click-dark), #006699); box-shadow: 0 8px 20px rgba(0, 170, 255, .38); }

/* SMS shablon o'zgaruvchi belgilari (settings sahifalarida) */
.tpl-var-badge {
  background: var(--primary-light); color: var(--primary-dark);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-weight: 600; font-size: .8rem;
  padding: .4rem .65rem; border-radius: .5rem;
  border: 1px solid #dfe0fb;
}

/* ---------- TABLES ---------- */
.table-soft thead { background: #f8f9fd; }
.table-soft th { font-weight: 700; color: #6b6f85; font-size: .78rem; letter-spacing: .03em; text-transform: uppercase; border-bottom: none; }
.table-soft td { vertical-align: middle; }
.table-soft tbody tr { border-bottom: 1px solid #f0f1f8; }
.table-soft tbody tr:hover { background: #fafbff; }

.badge-status-open { background:#e7f1ff; color:#0d6efd; font-weight: 600; }
.badge-status-partial { background:#fff4e5; color:#fd7e14; font-weight: 600; }
.badge-status-paid { background:#e7f7ee; color:#198754; font-weight: 600; }
.badge-status-overdue { background:#fdecec; color:#dc3545; font-weight: 600; }

.clickable-row { cursor: pointer; }

/* ---------- AUTH PAGES ---------- */
.auth-wrapper {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #4f46e5, #7c3aed 55%, #06b6d4);
  padding: 1rem;
}
.auth-card {
  background: #fff; border-radius: 1.5rem; padding: 2.25rem;
  width: 100%; max-width: 420px; box-shadow: 0 30px 70px rgba(20, 15, 60, .28);
}

.phone-input-group { display: flex; }
.phone-prefix {
  background: #f1f2f7; border: 1px solid #dfe1ea; border-right: none;
  padding: .5rem .9rem; border-radius: .5rem 0 0 .5rem; display: flex; align-items: center; font-weight: 600; color: #555;
}
.phone-input-group input { border-radius: 0 .5rem .5rem 0 !important; }

.step { display: none; }
.step.active { display: block; }

.due-quick-btns .btn { border-radius: 2rem; }

/* ---------- ADMIN PANEL ACCENT ---------- */
.app-sidebar .admin-badge {
  display: inline-block; font-size: .65rem; font-weight: 700; letter-spacing: .06em;
  background: var(--warning); color: #fff; padding: .15rem .5rem; border-radius: .4rem;
  margin-left: .4rem; text-transform: uppercase; vertical-align: middle;
}
