:root {
  --navy: #0f2a4a;
  --navy-2: #163a63;
  --accent: #1f6feb;
  --accent-2: #0ea5a4;
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #16202f;
  --muted: #667085;
  --border: #e3e8ef;
  --success: #12805c;
  --warning: #b45309;
  --danger: #b42318;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 4px; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
p { margin: 0 0 12px; }
small, .muted { color: var(--muted); }
hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex: 0 0 248px; background: var(--navy); color: #dbe4f0;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { padding: 22px 20px 18px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand .name { font-size: 21px; font-weight: 700; color: #fff; letter-spacing: -.02em; }
.brand .sub { font-size: 11.5px; text-transform: uppercase; letter-spacing: .09em; color: #93a7c4; }
.nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 2px;
  color: #cfdaea; border-radius: 8px; font-weight: 500; font-size: 14.5px;
}
.nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; color: #fff; }
.nav a.active { background: var(--accent); color: #fff; }
.sidebar-foot { padding: 14px 18px 18px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12.5px; color: #93a7c4; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: #fff; border-bottom: 1px solid var(--border); padding: 12px 24px;
  position: sticky; top: 0; z-index: 20;
}
.userbox { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; background: var(--navy-2); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
}
.userbox .who { font-size: 13.5px; font-weight: 600; }
.userbox .role { font-size: 11.5px; color: var(--muted); }
.content { padding: 24px; max-width: 1280px; width: 100%; }

/* Cards */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .label { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 6px; letter-spacing: -.02em; }
.stat .hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.stat.income .value { color: var(--success); }
.stat.expense .value { color: var(--danger); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left; padding: 10px 12px; background: #f8fafc; color: #475467;
  font-size: 12px; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfe; }
td.num, th.num { text-align: right; white-space: nowrap; }

/* Badges */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px;
  font-weight: 600; white-space: nowrap;
}
.badge-info { background: #e8f1ff; color: #175cd3; }
.badge-warning { background: #fef0c7; color: var(--warning); }
.badge-success { background: #dcfae6; color: var(--success); }
.badge-danger { background: #fee4e2; color: var(--danger); }
.badge-muted { background: #eef2f6; color: #475467; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border-radius: 9px; border: 1px solid var(--border);
  background: #fff; color: var(--text); font-size: 14px; font-weight: 600; cursor: pointer;
  transition: .15s ease;
}
.btn:hover { background: #f7f9fc; text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #185ed0; color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #97190f; color: #fff; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #0e6a4c; color: #fff; }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 7px; }
.btn-ghost { background: transparent; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
label.field { display: block; font-size: 13px; font-weight: 600; color: #344054; margin-bottom: 5px; }
input[type="text"], input[type="tel"], input[type="password"], input[type="number"],
input[type="date"], input[type="search"], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #cfd6e0; border-radius: 8px;
  font: inherit; font-size: 14px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #b9d3ff; border-color: var(--accent); }
textarea { min-height: 110px; resize: vertical; }
.help { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.form-row { margin-bottom: 14px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.inline-form .field-wrap { min-width: 150px; }

/* Alerts */
.alert { padding: 12px 14px; border-radius: 10px; font-size: 14px; margin-bottom: 16px; border: 1px solid; }
.alert-error { background: #fee4e2; border-color: #fecdca; color: #912018; }
.alert-success { background: #dcfae6; border-color: #abefc6; color: #05603a; }
.alert-info { background: #e8f1ff; border-color: #c7dbff; color: #175cd3; }

/* Login */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1000px 600px at 10% 0%, #17395f 0%, #0f2a4a 45%, #0a1e36 100%); }
.auth-card { width: 100%; max-width: 420px; background: #fff; border-radius: 16px; padding: 30px;
  box-shadow: 0 20px 50px rgba(3, 12, 24, .35); }
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand .logo { font-size: 26px; font-weight: 750; color: var(--navy); letter-spacing: -.02em; }
.auth-brand .sub { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin-top: 2px; }
.auth-foot { margin-top: 18px; font-size: 12.5px; color: var(--muted); text-align: center; }

/* Detail */
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 10px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { border-left: 3px solid var(--border); padding: 0 0 16px 16px; position: relative; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before {
  content: ""; position: absolute; left: -7px; top: 4px; width: 11px; height: 11px;
  border-radius: 50%; background: var(--accent); border: 2px solid #fff;
}
.timeline .when { font-size: 12.5px; color: var(--muted); }
.bar-row { display: grid; grid-template-columns: 110px 1fr 110px; gap: 10px; align-items: center; margin-bottom: 8px; font-size: 13.5px; }
.bar { height: 9px; background: #eef2f6; border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.bar.expense > span { background: var(--danger); }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.pager { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; font-size: 13.5px; }
.pager a, .pager span { padding: 6px 11px; border: 1px solid var(--border); border-radius: 7px; background: #fff; }
.pager .current { background: var(--accent); color: #fff; border-color: var(--accent); }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.filters .field-wrap { min-width: 150px; }
.filters input, .filters select { min-width: 100%; }
.mobile-menu { display: none; }

@media (max-width: 1080px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .sidebar {
    position: fixed; left: -260px; top: 0; bottom: 0; z-index: 50; transition: left .2s ease;
  }
  .sidebar.open { left: 0; }
  .mobile-menu { display: inline-flex; }
  .content { padding: 16px; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .kv dt { font-weight: 600; color: var(--text); }
  .topbar { padding: 10px 14px; }
}
/* ===== Qo'shimcha: til, parol, mobil ===== */
.sidebar-backdrop { display: none; }
.lang-switch { display: flex; flex-wrap: wrap; gap: 6px; }
.lang-switch a {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; padding: 4px 8px; border-radius: 7px;
  background: rgba(255,255,255,.08); color: #cfdaea; font-size: 12px; font-weight: 700;
}
.lang-switch a:hover { background: rgba(255,255,255,.16); color: #fff; text-decoration: none; }
.lang-switch a.active { background: var(--accent); color: #fff; }
.auth-lang { position: absolute; top: 14px; right: 14px; }
.auth-lang a { background: #eef2f6; color: #475467; }
.auth-lang a.active { background: var(--accent); color: #fff; }

.auth-card { position: relative; }
.auth-title { font-size: 19px; margin-bottom: 8px; }
.auth-radio { position: absolute; opacity: 0; pointer-events: none; }
.auth-tabs { display: flex; gap: 4px; margin: 14px 0 16px; border-bottom: 1px solid var(--border); }
.auth-tabs label {
  flex: 1; text-align: center; padding: 9px 6px; cursor: pointer;
  font-size: 13.5px; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
#mode-phone:checked ~ .auth-tabs label[for="mode-phone"],
#mode-password:checked ~ .auth-tabs label[for="mode-password"] {
  color: var(--accent); border-bottom-color: var(--accent);
}
.auth-pane { display: none; }
#mode-phone:checked ~ .auth-pane-phone { display: block; }
#mode-password:checked ~ .auth-pane-password { display: block; }
.auth-links { margin-top: 12px; text-align: center; font-size: 13.5px; }
.auth-bot { margin-top: 16px; text-align: center; }
.auth-bot .help { margin-top: 6px; }
.code-input { letter-spacing: .35em; font-size: 20px; text-align: center; }

.password-field { position: relative; }
.password-field input { padding-right: 44px; }
.password-field .eye {
  position: absolute; top: 0; right: 0; bottom: 0; width: 42px;
  border: none; background: transparent; cursor: pointer; font-size: 18px;
  color: var(--muted); border-radius: 0 8px 8px 0;
}
.password-field .eye:hover { color: var(--text); }

.btn-block { width: 100%; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 16px; }
.small { font-size: 12.5px; }
.details-summary { cursor: pointer; font-weight: 650; padding: 2px 0; }
.section-title {
  margin: 20px 0 10px; font-size: 13px; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted);
}
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.form-grid + .form-actions { grid-column: 1 / -1; }

/* Responsive jadval: 640px dan pastda kartochka ko'rinishi */
@media (max-width: 640px) {
  .responsive-table { display: block; }
  .responsive-table thead { display: none; }
  .responsive-table tbody { display: block; }
  .responsive-table tr {
    display: block; border: 1px solid var(--border); border-radius: 10px;
    padding: 8px 12px; margin-bottom: 10px; background: #fff;
  }
  .responsive-table tr:hover { background: #fff; }
  .responsive-table td {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
    padding: 6px 0; border: none; text-align: right;
  }
  .responsive-table td::before {
    content: attr(data-label); color: var(--muted); font-weight: 600;
    text-align: left; flex: 0 0 42%; font-size: 12.5px;
  }
  .responsive-table td[data-label=""]::before { content: ""; flex: 0; }
  .responsive-table td.num { text-align: right; }
  .responsive-table td form { margin-left: auto; }
}

@media (max-width: 820px) {
  .sidebar {
    width: min(86vw, 320px); flex-basis: auto;
    left: calc(-1 * min(86vw, 320px));
    box-shadow: 0 12px 40px rgba(3, 12, 24, .35);
  }
  .sidebar.open { left: 0; }
  .sidebar-backdrop:not([hidden]) {
    display: block; position: fixed; inset: 0; z-index: 45;
    background: rgba(15, 23, 42, .45);
  }
  .mobile-menu { display: inline-flex; }
  .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  .page-head { flex: 1 1 160px; min-width: 0; }
  .page-head .who { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .userbox { gap: 8px; }
  .userbox .user-meta { display: none; }
  .content { padding: 14px; max-width: none; }
  .card { padding: 14px 15px; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .kv dt { font-weight: 600; color: var(--text); }
  .table-wrap { -webkit-overflow-scrolling: touch; }
}

@media (max-width: 600px) {
  body { font-size: 14.5px; }
  .form-actions { justify-content: stretch; }
  .form-actions .btn { width: 100%; }
  .filters { flex-direction: column; align-items: stretch; }
  .filters .field-wrap { min-width: 0; width: 100%; }
  .filters .btn { width: 100%; }
  .auth-wrap { padding: 12px; }
  .auth-card { padding: 26px 18px; }
  .auth-brand .logo { font-size: 24px; }
  .actions { flex-direction: column; }
  .actions .btn { width: 100%; }
}

