/* Ofisbop — Jadval muharriri uslublari. Copyright (c) 2026 "VIJDON" MChJ. Barcha huquqlar himoyalangan. */
.fbar { display: flex; align-items: center; gap: 4px; padding: 4px 6px; background: #fff; border-bottom: 1px solid var(--border); flex: none; }
.namebox { width: 90px; height: 26px; border: 1px solid var(--border); border-radius: 3px; padding: 0 6px; font-size: 13px; }
.fx-sep { width: 1px; height: 18px; background: var(--border); }
.fxinput { flex: 1; height: 26px; border: 1px solid var(--border); border-radius: 3px; padding: 0 8px; font-family: Consolas, "Segoe UI", monospace; font-size: 13px; }
.fxinput:focus, .namebox:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.grid-wrap { flex: 1; overflow: auto; position: relative; background: #fff; outline: none; }
.grid { border-collapse: separate; border-spacing: 0; table-layout: fixed; font-family: Calibri, "Segoe UI", Arial, sans-serif; font-size: 11pt; background: #fff; user-select: none; }
.grid th {
  background: #f3f4f6; color: #555b63; font-weight: 400; font-size: 12px; border-right: 1px solid #d4d8de; border-bottom: 1px solid #d4d8de;
  position: sticky; z-index: 4; padding: 0; overflow: hidden; white-space: nowrap; text-align: center;
}
.grid thead th { top: 0; height: 22px; }
.grid tbody th { left: 0; }
.grid thead th.corner { left: 0; z-index: 6; background: #eceef1; cursor: pointer; }
.grid th.hsel { background: #dfe7e2; color: var(--accent-dark); font-weight: 600; border-bottom-color: var(--accent); }
.grid tbody th.hsel { border-right-color: var(--accent); }
.grid th .rz-c { position: absolute; right: -3px; top: 0; bottom: 0; width: 7px; cursor: col-resize; z-index: 2; }
.grid th .rz-r { position: absolute; left: 0; right: 0; bottom: -3px; height: 7px; cursor: row-resize; z-index: 2; }
.grid td {
  border-right: 1px solid #e2e4e8; border-bottom: 1px solid #e2e4e8; padding: 0 3px; height: 21px;
  overflow: hidden; white-space: nowrap; vertical-align: bottom; line-height: 1.2; position: relative;
}
.grid.nogrid td { border-right-color: transparent; border-bottom-color: transparent; }
.grid tr.sm td, .grid tr.sm th { height: auto; line-height: 1; }
.grid tr.xs td, .grid tr.xs th { font-size: 0; line-height: 0; }
/* Chizilmagan qatorlar oʻrnidagi boʻsh joy (faqat koʻrinadigan qatorlar chiziladi) */
.grid tr.vsp td { height: 0; padding: 0; border: 0; background: transparent; }
.grid td.num { text-align: right; }
.grid td.bool, .grid td.err { text-align: center; }
.grid td.wrap { white-space: pre-wrap; word-break: break-word; }
.grid td.spill { overflow: visible; }
.grid td.spill > .cv { position: relative; z-index: 1; overflow: hidden; }
.grid td .cv { display: block; overflow: hidden; text-overflow: clip; }
.grid td.frz { position: sticky; z-index: 3; background: #fff; }
.grid tr.frz-last td { box-shadow: inset 0 -2px 0 #9aa3ad; }
.grid td.frz-lastc { box-shadow: inset -2px 0 0 #9aa3ad; }
.grid td .fbtn {
  position: absolute; right: 1px; bottom: 1px; width: 17px; height: 17px; border: 1px solid #b9c0ca; background: #fff; border-radius: 2px;
  font-size: 9px; line-height: 15px; text-align: center; cursor: pointer; z-index: 2; color: #444;
}
.grid td .fbtn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-dark); }

.sel-box { position: absolute; pointer-events: none; border: 1px solid var(--accent); background: rgba(15, 118, 110, .08); z-index: 3; display: none; }
.act-box { position: absolute; pointer-events: none; border: 2px solid var(--accent); z-index: 3; display: none; }
.fill-handle { position: absolute; right: -4px; bottom: -4px; width: 7px; height: 7px; background: var(--accent); border: 1px solid #fff; pointer-events: auto; cursor: crosshair; }
.copy-box { position: absolute; pointer-events: none; border: 2px dashed var(--accent); z-index: 3; animation: ants 1s linear infinite; }
@keyframes ants { 50% { border-color: #9fd3b6; } }
.ref-box { position: absolute; pointer-events: none; border: 2px solid; z-index: 3; }
.cell-editor {
  position: absolute; z-index: 10; border: 2px solid var(--accent); padding: 1px 2px; margin: 0; resize: none; overflow: hidden;
  font-family: Calibri, "Segoe UI", Arial, sans-serif; font-size: 11pt; line-height: 1.2; background: #fff; outline: none; box-shadow: 0 2px 6px rgba(0, 0, 0, .2);
  white-space: pre; min-height: 21px;
}
.cell-editor.sink { opacity: 0; pointer-events: none; width: 2px; height: 2px; min-height: 0; padding: 0; border: 0; box-shadow: none; z-index: -1; }

.sheetbar { display: flex; align-items: center; gap: 4px; height: 30px; background: var(--ribbon); border-top: 1px solid var(--border); padding: 0 6px; flex: none; }
.sheet-tabs { display: flex; gap: 2px; overflow-x: auto; height: 100%; align-items: stretch; }
.sheet-tab {
  padding: 0 16px; display: flex; align-items: center; cursor: pointer; color: #444; border-bottom: 3px solid transparent; white-space: nowrap; font-size: 13px;
}
.sheet-tab:hover { background: var(--hover); }
.sheet-tab.active { background: #fff; color: var(--accent-dark); font-weight: 600; border-bottom-color: var(--accent); }
.sheet-tab input { width: 110px; font: inherit; border: 1px solid var(--accent); padding: 1px 4px; }

.chart-box { position: absolute; background: #fff; border: 1px solid #c9ced6; box-shadow: 0 1px 4px rgba(0, 0, 0, .12); z-index: 5; }
.chart-box.active { outline: 2px solid var(--accent); }
.chart-box canvas { display: block; width: 100%; height: 100%; }
.chart-box .ch-bar { position: absolute; top: 4px; right: 4px; display: none; gap: 2px; }
.chart-box.active .ch-bar, .chart-box:hover .ch-bar { display: flex; }
.chart-box .ch-bar button { background: #fff; border: 1px solid var(--border); border-radius: 3px; cursor: pointer; font-size: 11px; padding: 2px 6px; }
.chart-box .ch-rz { position: absolute; right: -5px; bottom: -5px; width: 10px; height: 10px; background: var(--accent); cursor: nwse-resize; display: none; }
.chart-box.active .ch-rz { display: block; }

.findbar {
  position: fixed; top: 180px; right: 24px; z-index: 800; background: #fff; border: 1px solid var(--border);
  border-radius: 8px; box-shadow: var(--shadow); padding: 10px; display: flex; flex-direction: column; gap: 6px; width: 380px;
}
.findbar .grow { display: flex; gap: 4px; align-items: center; }
.findbar .inp { flex: 1; height: 28px; }
.findbar .fcount { color: var(--muted); font-size: 12px; min-width: 50px; text-align: right; }
.findbar .pbtn { padding: 4px 10px; }

.fn-list { max-height: 300px; overflow: auto; border: 1px solid var(--border); border-radius: 4px; margin-top: 6px; }
.fn-list div { padding: 5px 8px; cursor: pointer; font-family: Consolas, monospace; }
.fn-list div:hover, .fn-list div.on { background: var(--accent-soft); }
.fn-desc { min-height: 40px; margin-top: 8px; color: var(--muted); font-size: 12px; max-width: 420px; }
.flt-list { max-height: 240px; overflow: auto; padding: 4px 8px; min-width: 200px; }
.flt-list label { display: flex; gap: 6px; align-items: center; padding: 2px 0; cursor: pointer; }

#printArea { display: none; }
@media print {
  body > *:not(#printArea) { display: none !important; }
  #printArea { display: block; }
  #printArea table { border-collapse: collapse; font-family: Calibri, Arial, sans-serif; font-size: 10pt; }
  #printArea td { padding: 1px 4px; white-space: nowrap; overflow: hidden; }
  #printArea tr { break-inside: avoid; } /* koʻp qatorli (matnni oʻrash) katak ikki sahifaga boʻlinmasin */
  #printArea td.pg { border: 1px solid #d0d0d0; }
  #printArea .pr-chart { margin-top: 12px; break-inside: avoid; }
  #printArea, #printArea * { -webkit-print-color-adjust: exact; print-color-adjust: exact; } /* katak ranglari telefonda ham chiqsin */
}
/* Maʼlumotlarni tekshirish: roʻyxatdan tanlash tugmasi va yoʻriqnoma */
.dv-btn { position: absolute; z-index: 6; width: 18px; height: 18px; display: none; background: #fff; border: 1px solid #9aa3ad; border-radius: 2px; font-size: 9px; line-height: 16px; text-align: center; cursor: pointer; color: #333; box-shadow: 0 1px 2px rgba(0, 0, 0, .15); }
.dv-btn:hover { background: var(--accent-soft); border-color: var(--accent); }
.dv-tip { position: absolute; z-index: 7; display: none; max-width: 260px; padding: 6px 8px; background: #fffde8; border: 1px solid #d8cf8a; border-radius: 4px; font-size: 12px; line-height: 1.4; color: #333; box-shadow: 0 2px 6px rgba(0, 0, 0, .12); pointer-events: none; white-space: pre-wrap; }
/* Izoh belgisi */
.grid td .cmt-ind { position: absolute; top: 0; right: 0; width: 0; height: 0; border-top: 6px solid #d64545; border-left: 6px solid transparent; pointer-events: none; }
/* Oynalardagi shakllar (sahifa sozlamalari, shartli formatlash, tekshirish...) */
.sx-form { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; width: 560px; max-width: 100%; }
.sx-form .wide { grid-column: 1 / -1; }
.sx-row { display: flex; gap: 6px; align-items: center; }
.sx-row .inp { flex: 1; min-width: 60px; }
.modal .sx-row select.sel { width: auto; flex: 0 0 auto; max-width: 60%; }
.sx-row .pbtn { white-space: nowrap; }
.sx-row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.sx-sub { margin: 10px 0 2px; color: var(--muted); font-size: 12px; }
.sx-codes { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 6px; font-size: 12px; color: var(--muted); }
.sx-codes .pbtn { padding: 2px 8px; font-size: 12px; }
.modal label.sx-chk { display: flex; gap: 6px; align-items: center; margin: 6px 0; color: inherit; font-size: 13px; }
.sx-chks { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 8px; }
@media screen and (max-width: 760px), screen and (max-height: 500px) and (pointer: coarse) { .sx-form { grid-template-columns: 1fr; width: auto; } .sx-row3 { grid-template-columns: 1fr; } }
.cf-prev { padding: 4px 12px; border: 1px solid var(--border); border-radius: 3px; min-width: 70px; text-align: center; }
.cf-list { display: flex; flex-direction: column; gap: 4px; width: 560px; max-width: 100%; max-height: 50vh; overflow: auto; }
.cf-item { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border: 1px solid var(--border); border-radius: 4px; }
.cf-item .cf-d { flex: 1; } .cf-item .cf-r { color: var(--muted); font-family: Consolas, monospace; font-size: 12px; }
.cf-item .pbtn { padding: 2px 8px; }
.cf-sw { width: 40px; text-align: center; border: 1px solid var(--border); border-radius: 3px; font-size: 12px; }
.cf-empty { color: var(--muted); padding: 12px 0; }
.dv-bad { position: absolute; border: 2px solid #e03131; border-radius: 50%; pointer-events: none; z-index: 3; }
/* Formula yozishda: nom taklifi va argumentlar koʻrsatmasi */
.fx-ac { position: fixed; z-index: 900; display: none; min-width: 260px; max-width: 420px; background: #fff; border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow); padding: 3px 0; font-size: 13px; }
.fx-ac .ac-it { display: flex; gap: 10px; align-items: baseline; padding: 4px 10px; cursor: pointer; }
.fx-ac .ac-it.on, .fx-ac .ac-it:hover { background: var(--accent-soft); }
.fx-ac .ac-n { font-family: Consolas, monospace; font-weight: 600; color: var(--accent-dark); white-space: nowrap; }
.fx-ac .ac-d { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-hint { position: fixed; z-index: 899; display: none; max-width: 520px; background: #fffef3; border: 1px solid #d9d2a6; border-radius: 6px; box-shadow: 0 3px 10px rgba(0, 0, 0, .12); padding: 6px 10px; font-size: 12.5px; line-height: 1.45; }
.fx-hint .fn-n, .fn-sig .fn-n { font-family: Consolas, monospace; font-weight: 600; }
.fx-hint b, .fn-sig b { color: var(--accent-dark); }
.fx-hint .fx-hd { color: var(--muted); margin-top: 2px; }
.fn-sig { margin-top: 8px; font-size: 13px; min-height: 20px; }
/* Son formati oynasi */
.nf-wrap { display: flex; gap: 14px; width: 600px; max-width: 100%; min-height: 330px; }
.nf-cats { flex: 0 0 150px; border-right: 1px solid var(--border); padding-right: 8px; }
.nf-cat { padding: 5px 8px; border-radius: 4px; cursor: pointer; }
.nf-cat:hover { background: var(--hover); } .nf-cat.on { background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }
.nf-right { flex: 1; min-width: 0; }
.nf-prev { border: 1px solid var(--border); border-radius: 4px; padding: 6px 10px; min-height: 22px; font-family: Calibri, Arial, sans-serif; font-size: 14px; margin-bottom: 6px; background: #fafbfc; }
.nf-pick { max-height: 190px; overflow: auto; border: 1px solid var(--border); border-radius: 4px; margin-top: 6px; }
.nf-it { padding: 3px 8px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.nf-it:hover { background: var(--hover); } .nf-it.on { background: var(--accent-soft); }
.nf-code { font-family: Consolas, monospace; }
@media screen and (max-width: 760px), screen and (max-height: 500px) and (pointer: coarse) { .nf-wrap { flex-direction: column; width: auto; } .nf-cats { flex: none; border: 0; display: flex; flex-wrap: wrap; gap: 2px; } }
/* Saralash oynasi */
.srt { width: 520px; max-width: 100%; display: flex; flex-direction: column; gap: 8px; }
.srt-list { display: flex; flex-direction: column; gap: 6px; }
.srt-row { display: flex; gap: 6px; align-items: center; }
.srt-row .srt-n { flex: 0 0 74px; color: var(--muted); font-size: 12px; }
.modal .srt-row select.sel { width: auto; flex: 1; }
.srt > .pbtn { align-self: flex-start; }
/* Nomlar boshqaruvchisi */
.nm-list { display: flex; flex-direction: column; gap: 4px; width: 640px; max-width: 100%; max-height: 50vh; overflow: auto; margin-bottom: 8px; }
.nm-row { display: grid; grid-template-columns: 1fr 1.6fr 1fr 34px; gap: 6px; align-items: center; }
.nm-head span { color: var(--muted); font-size: 12px; }
.modal .nm-row input.inp, .modal .nm-row select.sel { height: 28px; }
.nm-row .pbtn { padding: 2px 8px; }
.csv-prev { max-height: 220px; overflow: auto; border: 1px solid var(--border); border-radius: 4px; }
.csv-prev table { border-collapse: collapse; font-size: 12px; }
.csv-prev td { border: 1px solid #e3e6ea; padding: 2px 6px; white-space: nowrap; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.findbar .fopts { gap: 12px; font-size: 12px; color: var(--muted); }
.findbar .fopts label { display: flex; gap: 4px; align-items: center; cursor: pointer; }

/* Tezkor amallar (sarlavha qatorida) — tor oynada yashiriladi */
.tb-quick { display: contents; }
@media (max-width: 1100px) { .tb-quick { display: none; } }

/* Formula yozishda yordam: argument izohi, namuna, tanlangan funksiya */
.fx-hint .fx-ha { margin-top: 3px; }
.fx-hint .fx-ha b { font-family: Consolas, monospace; }
.fx-hint .fx-hx, .fx-ac .ac-x { margin-top: 3px; font-family: Consolas, monospace; font-size: 12px; color: #4b5563; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fx-ac .ac-foot { border-top: 1px solid var(--border); margin-top: 3px; padding: 5px 10px 3px; background: #fafaf7; }
.fx-ac .ac-foot .fn-sig { margin: 0; font-size: 12.5px; }
.fx-ac .ac-k { color: var(--muted); font-size: 11px; margin-top: 3px; }
.fn-ex { font-family: Consolas, monospace; font-size: 12px; color: #4b5563; margin-top: 4px; max-width: 420px; overflow-wrap: anywhere; }
.fn-more { margin-top: 6px; color: var(--accent-dark); }

/* Tanlangan katakdagi xato — izoh tugmasi (formula qatorida) */
.fx-err { flex: none; display: none; max-width: 40%; height: 24px; padding: 0 10px; border: 1px solid #f2c94c; border-radius: 12px; background: #fff8e1; color: #7a4d00; font: inherit; font-size: 12px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fx-err:hover { background: #ffefb3; }

/* Formulalar yoʻriqnomasi paneli */
.fg-panel { position: fixed; top: 0; right: 0; bottom: 0; width: 380px; z-index: 950; display: none; flex-direction: column; background: var(--panel, #fff); border-left: 1px solid var(--border); box-shadow: -6px 0 18px rgba(0, 0, 0, .08); font-size: 13px; }
.fg-panel.open { display: flex; }
html.fg-open body { margin-right: 380px; }
.fg-head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 14px; border-bottom: 1px solid var(--border); font-size: 14px; }
.fg-head b { flex: 1; }
.fg-body { flex: 1; overflow: auto; padding: 10px 14px 16px; }
.fg-row { display: flex; gap: 6px; }
.fg-q { flex: 1; min-width: 0; }
.fg-muted { color: var(--muted); font-size: 12px; margin: 6px 0; }
.fg-list { display: flex; flex-direction: column; }
.fg-it { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; padding: 6px 8px; border: 0; border-radius: 6px; background: none; font: inherit; cursor: pointer; color: inherit; }
.fg-it:hover, .fg-it:focus-visible { background: var(--accent-soft); outline: none; }
.fg-n { font-family: Consolas, monospace; font-weight: 700; color: var(--accent-dark); }
.fg-d { color: var(--muted); font-size: 12px; line-height: 1.35; }
.fg-back { margin: 0 0 6px -4px; color: var(--accent-dark); }
.fg-title { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 18px; margin: 4px 0 6px; }
.fg-cat { font-size: 11px; padding: 1px 8px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-dark); }
.fg-desc { margin: 4px 0 8px; font-size: 14px; line-height: 1.45; }
.fg-sig { padding: 6px 8px; background: #f6f7f9; border-radius: 6px; overflow-wrap: anywhere; }
.fg-args { margin: 8px 0 4px; display: grid; gap: 4px; }
.fg-arg { display: grid; grid-template-columns: minmax(90px, auto) 1fr; gap: 8px; line-height: 1.35; }
.fg-arg code { font-family: Consolas, monospace; color: var(--accent-dark); font-size: 12px; }
.fg-body h5 { margin: 14px 0 6px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.fg-tblw { overflow-x: auto; }
.fg-tbl { border-collapse: collapse; font-size: 12px; }
.fg-tbl th { background: #f1f3f4; color: #5f6368; font-weight: 500; padding: 2px 6px; border: 1px solid #dadce0; }
.fg-tbl td { padding: 2px 8px; border: 1px solid #e2e3e5; white-space: nowrap; max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.fg-tbl td.num { text-align: right; }
.fg-tbl td.fg-f { background: #fff4c2; font-weight: 700; outline: 2px solid #e0b100; outline-offset: -2px; }
.fg-fx { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; margin-top: 8px; }
.fg-fx code { font-family: Consolas, monospace; font-size: 12.5px; background: #f6f7f9; padding: 2px 6px; border-radius: 4px; overflow-wrap: anywhere; }
.fg-fx span { font-weight: 700; }
.fg-human { margin-top: 12px; padding: 8px 10px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 6px 6px 0; }
.fg-human p { margin: 4px 0 0; line-height: 1.5; }
.fg-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.fg-err { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin: 8px 0; }
.fg-err.on { border-color: #e0b100; background: #fffbea; }
.fg-err-h { display: flex; gap: 8px; align-items: baseline; }
.fg-err-h code { font-family: Consolas, monospace; font-weight: 700; color: #b42318; }
.fg-err p { margin: 6px 0 0; line-height: 1.45; }
.m-ui .fg-panel { width: 100%; z-index: 1200; }
.m-ui.fg-open body { margin-right: 0; }
