:root {
  /* Smartup dizayni: asosiy rang — ko'k, ikkilamchi — moviy (teal), navbar — to'q ko'k */
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #1c2431;
  --muted: #7a8699;
  --line: #e3e8ef;
  --brand: #2f6fed;        /* asosiy ko'k (Smartup СОЗДАТЬ/РЕДАКТИРОВАТЬ) */
  --brand-dark: #2559d0;
  --brand-soft: #eaf1fe;   /* ko'k fon (active, flash) */
  --teal: #17a2b8;         /* ikkilamchi tugma / teal pill */
  --teal-dark: #128496;
  --accent: #5b9bff;       /* navbar ustidagi yorug' urg'u (to'q fonda o'qiladi) */
  --brand-ink: #ffffff;
  --danger: #c0392b;
  --radius: 7px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  min-height: 100vh;
}

/* --- Yuqori menyu (Smartup uslubi) --- */
.navbar {
  display: flex; align-items: stretch; background: #0f1b2a; color: #d6e0ec;
  position: sticky; top: 0; z-index: 500; padding: 0 14px;
  overflow: visible;  /* MUHIM: overflow bo'lsa ochiluvchi menyu qirqiladi */
}
.brand {
  display: flex; align-items: center; font-size: 18px; font-weight: 700;
  color: #fff; text-decoration: none; padding: 0 18px 0 6px; letter-spacing: .3px;
}
.brand span { color: var(--accent); margin-left: 5px; }
.nav-items { display: flex; align-items: stretch; flex: 1; flex-wrap: wrap; overflow: visible; }
.nav-wrap { position: relative; display: flex; }
.nav-top {
  display: flex; align-items: center; padding: 0 14px; height: 50px;
  color: #d6e0ec; text-decoration: none; font-size: 14px; white-space: nowrap; cursor: default;
}
a.nav-top { cursor: pointer; }
.nav-wrap:hover > .nav-top, .nav-top:hover { background: #1b2d42; color: #fff; }
.nav-top.active { background: #1b2d42; color: #fff; box-shadow: inset 0 -3px 0 var(--accent); }

/* Katta ochiluvchi ro'yxat */
.mega {
  display: none; position: absolute; top: 100%; left: 0; z-index: 1000;
  background: #14212f; border-top: 2px solid var(--accent);
  box-shadow: 0 18px 40px rgba(0,0,0,.45); border-radius: 0 0 8px 8px;
}
/* Bosilganda ochiladi (hover emas) va boshqa menyu bosilguncha ochiq turadi.
   Smartup kabi o'ngga qarab ochiladi (left:0); ekrandan chiqsa JS uni joyiga suradi. */
.nav-wrap.open .mega { display: block; }
.nav-wrap.open > .nav-top { background: #1b2d42; color: #fff; box-shadow: inset 0 -3px 0 var(--accent); }
.nav-top { user-select: none; }
.mega-inner { display: flex; gap: 30px; padding: 20px 26px; max-width: 92vw; }
.mega-col { min-width: 180px; max-width: 265px; }
.mega-title {
  color: #fff; font-size: 13px; font-weight: 600; padding-bottom: 7px; margin-bottom: 7px;
  border-bottom: 1px solid #2b3d52; white-space: nowrap;
}
.mega-item { display: block; padding: 6px 0; font-size: 13px; color: #b9c6d6; text-decoration: none; }
.mega-item:hover { color: #fff; }
.mega-item.active { color: var(--accent); }
.mega-item.soon { color: #566a80; cursor: default; }
.nav-user { display: flex; align-items: center; gap: 12px; font-size: 13px; padding-left: 14px; white-space: nowrap; }
.nav-user .uname { color: #fff; font-weight: 600; }

/* Ilova / kompaniya almashtirgichi */
.switch-wrap { position: relative; display: flex; align-items: center; }
.switch-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0;
  background: none; border: 0; color: #d6e0ec; cursor: pointer;
  font: inherit; font-size: 12px; line-height: 1.3; padding: 6px 8px; border-radius: 6px;
}
.switch-btn:hover, .switch-wrap:hover .switch-btn { background: #1b2d42; }
.switch-btn .app { color: #8fa1b6; }
.switch-btn .org { color: #fff; font-weight: 600; }
.switch-btn .caret { position: absolute; right: -4px; top: 12px; color: #8fa1b6; font-size: 10px; }
.switch-menu {
  display: none; position: absolute; top: 100%; right: 0; z-index: 1000;
  background: #fff; color: var(--ink); border-radius: 8px; min-width: 380px;
  box-shadow: 0 16px 40px rgba(0,0,0,.3); padding: 12px; gap: 10px;
}
.switch-wrap.open .switch-menu { display: flex; }
.switch-col { flex: 1; min-width: 150px; max-height: 320px; overflow-y: auto; }
.switch-col.apps { flex: 0 0 140px; border-right: 1px solid var(--line); padding-right: 10px; }
.switch-title { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); padding: 4px 8px 8px; }
.switch-item {
  display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; border-radius: 6px;
  background: none; font: inherit; font-size: 13px; color: var(--ink); cursor: pointer;
}
.switch-item:hover { background: #f1f5f9; }
.switch-item.active { background: var(--brand); color: #fff; }
.switch-item.soon { color: var(--muted); cursor: default; }
.switch-item.soon:hover { background: none; }
.nav-exit { color: #8fa1b6; text-decoration: none; font-size: 13px; }
.nav-exit:hover { color: #fff; }

/* --- Asosiy qism --- */
main { display: flex; flex-direction: column; }
.topbar { background: var(--panel); border-bottom: 1px solid var(--line); padding: 14px 24px; }
.topbar h1 { margin: 0; font-size: 19px; font-weight: 600; }
.content { padding: 22px 24px 40px; }

/* --- Kartalar --- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card h2 { margin: 0 0 6px; font-size: 16px; }
.card.stat { display: block; text-decoration: none; color: inherit; margin: 0; transition: .15s; }
.card.stat:hover { border-color: var(--brand); transform: translateY(-1px); }
.stat-icon { font-size: 20px; }
.stat-value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat-label { color: var(--muted); font-size: 13px; }

/* --- Asboblar paneli --- */
.toolbar { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.search { display: flex; gap: 8px; }
.search input { min-width: 240px; }

/* --- Jadval --- */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 13px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: #fafbfc; font-weight: 500; font-size: 13px; color: var(--muted); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f2f7ff; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); padding: 40px; text-align: center; color: var(--muted); }

/* --- Forma --- */
.form { max-width: 560px; }
.form label { display: block; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
.form-actions { display: flex; gap: 10px; margin-top: 6px; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; color: var(--ink); background: #fff; margin-top: 5px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(47,111,237,.25); border-color: var(--brand); }
.req { color: var(--danger); }

/* --- Tugmalar --- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  font: inherit; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: #c9d2de; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-dark); }
.btn-teal { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-teal:hover { background: var(--teal-dark); }
.btn-ghost { background: transparent; }
.link { color: var(--brand); text-decoration: none; background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.link:hover { text-decoration: underline; }
.link.danger { color: var(--danger); margin-left: 10px; }
.inline { display: inline; }

/* --- Boshqalar --- */
.muted { color: var(--muted); font-size: 13px; margin-top: 10px; }
.flash { padding: 11px 16px; border-radius: 8px; margin: 16px 24px 0; font-size: 14px; }
.flash.ok { background: #e6f5ee; color: #14603f; }
.flash.err { background: #fdecea; color: #8f2d21; }
.checklist { list-style: none; padding: 0; margin: 10px 0 0; }
.checklist li { padding: 5px 0 5px 26px; position: relative; color: var(--muted); }
.checklist li::before { content: '○'; position: absolute; left: 4px; }
.checklist li.done { color: var(--ink); }
.checklist li.done::before { content: '✅'; left: 0; font-size: 12px; }

/* Ulush chizig'i (hisobotlarda) */
.bar { background: #eef2f7; border-radius: 4px; height: 8px; min-width: 90px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--brand); border-radius: 4px; }

/* Davr tanlash (hisobotlar) */
.toolbar.period { align-items: flex-end; gap: 12px; }
.toolbar.period label { font-size: 12px; color: var(--muted); }
.toolbar.period input { margin-top: 4px; }

/* P&L jadvali */
table.pl td:first-child { white-space: pre; }
table.pl tr.pl-sum td { background: #f8fafc; }
table.pl tr.pl-total td { background: #e6f5ee; font-size: 15px; }

/* API kalitlari */
.key-box { border-color: var(--brand); }
code.key {
  display: block; margin-top: 10px; padding: 12px 14px; background: #0f1b2a; color: var(--accent);
  border-radius: 8px; font-size: 13px; word-break: break-all; user-select: all;
}
pre.code {
  background: #0f1b2a; color: #c9d4e3; padding: 16px; border-radius: 8px;
  overflow-x: auto; font-size: 12.5px; line-height: 1.7; margin: 10px 0 0;
}
.form label.check { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.form label.check input { width: auto; margin: 0; }

/* Foydalanuvchi menyusi (avatar) */
.umenu-wrap { position: relative; display: flex; align-items: center; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; border: 2px solid #2b3d52;
  background: var(--brand); color: #fff; font: inherit; font-size: 12px; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.umenu-wrap:hover .avatar { border-color: var(--accent); }
.umenu {
  display: none; position: absolute; top: 100%; right: 0; z-index: 1000; min-width: 265px;
  background: #fff; color: var(--ink); border-radius: 8px; padding: 8px 0;
  box-shadow: 0 16px 42px rgba(0,0,0,.3);
}
.umenu-wrap.open .umenu { display: block; }
.umenu-head { padding: 10px 18px 14px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.umenu-name { font-weight: 600; font-size: 14px; }
.umenu-org { color: var(--muted); font-size: 12px; margin-top: 2px; }
.umenu-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 9px 18px; border: 0; background: none; font: inherit; font-size: 13px;
  color: var(--ink); text-decoration: none; cursor: pointer;
}
.umenu-item span { width: 18px; text-align: center; font-size: 13px; opacity: .75; }
.umenu-item:hover { background: #f1f5f9; }
.umenu-item.soon { color: var(--muted); cursor: default; }
.umenu-item.soon:hover { background: none; }
.umenu-sep { height: 1px; background: var(--line); margin: 6px 0; }

/* Til almashtirgich */
.lang-switch { display: flex; gap: 2px; background: #1b2d42; border-radius: 6px; padding: 2px; }
.lang-btn {
  background: none; border: 0; color: #8fa1b6; font: inherit; font-size: 12px; font-weight: 600;
  padding: 4px 9px; border-radius: 5px; cursor: pointer;
}
.lang-btn:hover { color: #fff; }
.lang-btn.active { background: var(--brand); color: #fff; }

/* Bo'limlar (ВЗАИМОРАСЧЕТ / ДЕБИТОРЫ / ИСТОРИЯ) */
.tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  padding: 8px 16px; border-radius: 6px; background: #fff; border: 1px solid var(--line);
  color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 700; letter-spacing: .4px;
}
.tab:hover { color: var(--ink); }
.tab.active { background: var(--teal); border-color: var(--teal); color: #fff; }

/* Pastdagi umumiy jamlar qatori */
.totals-bar {
  display: flex; gap: 26px; flex-wrap: wrap; margin-top: 16px; padding: 14px 18px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.totals-bar > div { font-size: 13px; }
.totals-bar span { color: var(--muted); }
.totals-bar b { font-size: 15px; font-variant-numeric: tabular-nums; }
.totals-bar small { display: block; color: var(--muted); font-size: 11px; }

/* --- Ro'yxat asboblari (Smartup "Заказы" uslubi) --- */
.tools-left { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.pager { display: flex; align-items: center; gap: 6px; }
.pager .btn { padding: 6px 11px; }
.chips { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.chip {
  padding: 5px 14px; border-radius: 20px; border: 1px solid var(--line); background: #fff;
  font-size: 13px; color: var(--muted); text-decoration: none;
}
.chip:hover { border-color: #c9d2de; color: var(--ink); }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* Qatorni bosganda ochiladigan amal paneli (Smartup "Заказы" uslubi) */
table.rowmenu tr.drow { cursor: pointer; }
table.rowmenu tr.drow:hover { background: #f2f7ff; }
table.rowmenu tr.rowsel > td { background: #eaf1fe; }
table.rowmenu tr.arow > td { background: #f7f9fc; padding: 8px 13px; }
.rowbar { display: flex; gap: 8px; flex-wrap: wrap; }
.rowbar .btn { padding: 6px 13px; font-size: 13px; }

/* Pastdagi jamlar */
.summary { display: flex; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.sum-tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 18px; min-width: 170px; }
.sum-label { font-size: 12px; color: var(--muted); }
.sum-value { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 3px; }

/* --- Hujjat (savdo) --- */
.doc-head { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.doc-head label { display: block; font-size: 13px; color: var(--muted); }
.doc-sub { font-size: 15px; margin: 20px 0 10px; }
#items input, #items select { margin-top: 0; }
#items .num input { text-align: right; }
#items tfoot td { background: #fafbfc; font-size: 15px; }
.doc-view { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.doc-view span { display: block; font-size: 12px; }
.total-line { text-align: right; font-size: 16px; margin-top: 14px; }
.debt { color: var(--danger); }
.paid { color: var(--brand); }
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.ok { background: #e6f5ee; color: #14603f; }
.badge.draft { background: #f0f2f5; color: #64748b; }
.badge.cancel { background: #fdecea; color: #8f2d21; }

/* --- Kirish sahifasi --- */
.login-body { display: flex; align-items: center; justify-content: center; background: #16202e; }
.login-card { background: var(--panel); padding: 32px; border-radius: 14px; width: 340px; box-shadow: 0 12px 40px rgba(0,0,0,.3); }
.login-card .brand { color: var(--ink); padding: 0 0 4px; }
.login-card .sub { color: var(--muted); font-size: 14px; margin: 0 0 20px; }
.login-card label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 4px; }
.login-card .flash { margin: 0 0 14px; }
.hint { font-size: 12px; color: var(--muted); text-align: center; margin: 14px 0 0; }

@media (max-width: 900px) {
  .navbar { flex-wrap: wrap; padding: 0 8px; }
  .nav-user { padding: 8px 6px; }
  .mega-inner { flex-direction: column; gap: 14px; max-height: 70vh; overflow-y: auto; }
  .content { padding: 16px; }
}

/* --- Akt-sverka: ekranda oddiy kartochka, chop etishда toza qog'oz --- */
.act-title { text-align: center; margin: 0 0 6px; font-size: 18px; letter-spacing: .3px; }
.act-sub { text-align: center; margin: 0 0 18px; color: #667; line-height: 1.5; }
.act-foot { margin-top: 14px; display: flex; flex-direction: column; gap: 4px; }
.act-sign { margin-top: 28px; display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; }

@media print {
  /* Chop etishда faqat hujjatning o'zi qoladi: menyu, tugmalar, filtrlar chiqmaydi */
  .navbar, .topbar, .toolbar, .chips, .form-actions, .no-print, .summary { display: none !important; }
  body { background: #fff; }
  main, .content { padding: 0; margin: 0; }
  .card, .act { box-shadow: none; border: none; padding: 0; }
  table { font-size: 12px; }
  a { color: #000; text-decoration: none; }
}
