/* ==========================================================================
   OXU xonadonlar — hisobot tizimi
   Mobil-birinchi, desktopga kengayadigan dizayn
   ========================================================================== */

:root {
  --ink:            #0f1720;
  --ink-2:          #1b2733;
  --ink-3:          #2a3947;
  --paper:          #f4f6f8;
  --card:           #ffffff;
  --line:           #dfe5eb;
  --line-soft:      #eceff3;

  --text:           #16212c;
  --text-2:         #5b6b7b;
  --text-3:         #8a99a8;

  --gold:           #c8963e;
  --gold-soft:      #fdf4e3;
  --green:          #12805c;
  --green-soft:     #e6f5ef;
  --red:            #c0392b;
  --red-soft:       #fdecea;
  --blue:           #1f6feb;
  --blue-soft:      #e8f1fe;

  --radius:         14px;
  --radius-sm:      9px;
  --shadow:         0 1px 2px rgba(16,33,44,.06), 0 6px 20px rgba(16,33,44,.06);
  --shadow-lg:      0 10px 40px rgba(16,33,44,.16);

  --header-h:       58px;
  --bottomnav-h:    62px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, "Noto Sans", sans-serif;
  --mono: "SF Mono", "Segoe UI Mono", "Roboto Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--paper);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ---------------------------------------------------------------- Header */
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--header-h);
  background: var(--ink);
  color: #fff;
  display: flex; align-items: center; gap: 12px;
  padding: 0 14px;
  padding-top: env(safe-area-inset-top);
  box-shadow: 0 1px 0 rgba(255,255,255,.06);
}
.topbar .brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar .logo {
  width: 32px; height: 32px; border-radius: 9px; flex: none;
  background: linear-gradient(140deg, var(--gold), #a97a2b);
  display: grid; place-items: center;
  font-weight: 700; font-size: 14px; color: #1a1206;
}
.topbar .title { font-weight: 650; font-size: 15px; letter-spacing: -.01em; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.topbar .sub { font-size: 11px; color: #8fa2b4; display: none; }
.topbar .spacer { flex: 1; }

.topbar-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 9px; border: 0;
  background: rgba(255,255,255,.08); color: #dbe4ec;
  display: grid; place-items: center; cursor: pointer; font-size: 16px;
}
.icon-btn:hover { background: rgba(255,255,255,.16); color: #fff; }

.user-chip {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.08); border-radius: 999px;
  padding: 5px 12px 5px 6px; color: #dbe4ec; font-size: 13px;
}
.user-chip .av {
  width: 26px; height: 26px; border-radius: 50%; background: var(--gold);
  color: #1a1206; display: grid; place-items: center; font-weight: 700; font-size: 12px;
}
.user-chip .role { font-size: 10.5px; color: #93a5b6; display: block; line-height: 1.1; }

/* ---------------------------------------------------------------- Nav */
.mainnav { display: none; }
@media (min-width: 900px) {
  .mainnav { display: flex; gap: 2px; margin-left: 18px; }
  .mainnav a {
    color: #a9bacb; padding: 8px 13px; border-radius: 9px;
    font-size: 13.5px; font-weight: 550; text-decoration: none; white-space: nowrap;
  }
  .mainnav a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
  .mainnav a.on { background: rgba(200,150,62,.18); color: var(--gold); }
  .topbar .sub { display: block; }
}

.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 45;
  height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: #fff; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr);
}
.bottomnav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--text-3); font-size: 10.5px; font-weight: 550;
  text-decoration: none; padding-top: 6px;
}
.bottomnav a .ic { font-size: 19px; line-height: 1; }
.bottomnav a.on { color: var(--gold); }
@media (min-width: 900px) { .bottomnav { display: none; } }

/* ---------------------------------------------------------------- Layout */
.wrap { max-width: 1400px; margin: 0 auto; padding: 14px; }
@media (min-width: 900px) { .wrap { padding: 22px 26px 40px; } }
@media (max-width: 899px) { body { padding-bottom: calc(var(--bottomnav-h) + 16px); } }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
}
.page-head h1 { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: -.02em; }
.page-head .lead { margin: 3px 0 0; color: var(--text-2); font-size: 13.5px; }
@media (min-width: 900px) { .page-head h1 { font-size: 25px; } }

/* ---------------------------------------------------------------- Oy tanlash */
.period-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px; margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.period-bar form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; flex: 1; }
.period-now {
  font-weight: 700; font-size: 15px; padding: 0 6px; white-space: nowrap;
}
.nav-arrow {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; color: var(--text-2); display: grid; place-items: center;
  cursor: pointer; text-decoration: none; font-size: 15px; flex: none;
}
.nav-arrow:hover { background: var(--paper); color: var(--text); text-decoration: none; }

select.input, input.input, textarea.input {
  font-family: inherit; font-size: 14px; color: var(--text);
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 8px 11px; outline: none; width: 100%;
}
select.input { padding-right: 30px; cursor: pointer; }
input.input:focus, select.input:focus, textarea.input:focus {
  border-color: var(--gold); box-shadow: 0 0 0 3px rgba(200,150,62,.15);
}
.input-sm { max-width: 150px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 9px 15px; border-radius: var(--radius-sm); font-size: 14px;
  font-weight: 600; font-family: inherit; cursor: pointer; text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--paper); text-decoration: none; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:hover { background: var(--ink-2); }
.btn-gold { background: var(--gold); border-color: var(--gold); color: #21180a; }
.btn-gold:hover { background: #b98833; }
.btn-green { background: var(--green); border-color: var(--green); color: #fff; }
.btn-green:hover { background: #0d6a4c; }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------------------------------------------------------------- KPI */
.kpi-grid {
  display: grid; gap: 10px; margin-bottom: 16px;
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 700px) { .kpi-grid { grid-template-columns: repeat(4, 1fr); gap: 14px; } }

.kpi {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 13px 14px; box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.kpi .lbl {
  font-size: 11.5px; color: var(--text-2); font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px;
  display: flex; align-items: center; gap: 5px;
}
.kpi .val { font-size: 22px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.kpi .val small { font-size: 13px; font-weight: 600; color: var(--text-2); margin-left: 2px; }
.kpi .hint { font-size: 11.5px; color: var(--text-3); margin-top: 5px; }
@media (min-width: 700px) { .kpi .val { font-size: 26px; } }

.kpi.accent-gold  { border-top: 3px solid var(--gold); }
.kpi.accent-green { border-top: 3px solid var(--green); }
.kpi.accent-red   { border-top: 3px solid var(--red); }
.kpi.accent-blue  { border-top: 3px solid var(--blue); }

.trend { font-size: 12px; font-weight: 700; padding: 2px 7px; border-radius: 999px; }
.trend.up   { background: var(--green-soft); color: var(--green); }
.trend.down { background: var(--red-soft); color: var(--red); }
.trend.flat { background: var(--line-soft); color: var(--text-2); }

/* ---------------------------------------------------------------- Card */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 16px; overflow: hidden;
}
.card-head {
  padding: 13px 15px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex-wrap: wrap;
}
.card-head h2 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.card-head .meta { font-size: 12.5px; color: var(--text-2); }
.card-body { padding: 15px; }
.card-body.tight { padding: 0; }

/* ---------------------------------------------------------------- Progress */
.bar { height: 7px; background: var(--line-soft); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--green); border-radius: 99px; }
.bar.warn > span { background: var(--gold); }
.bar.mini { height: 5px; }

/* ---------------------------------------------------------------- Grafik */
.chart {
  display: flex; align-items: flex-end; gap: 5px; height: 140px;
  padding: 6px 2px 0;
}
.chart .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end;
  align-items: center; gap: 5px; height: 100%; min-width: 0; }
.chart .bar-v {
  width: 100%; max-width: 42px; background: var(--line);
  border-radius: 6px 6px 3px 3px; min-height: 3px;
  transition: background .15s;
}
.chart .col.has > .bar-v { background: linear-gradient(180deg, #486076, var(--ink-3)); }
.chart .col.on > .bar-v { background: linear-gradient(180deg, var(--gold), #a97a2b); }
.chart .nm { font-size: 10px; color: var(--text-3); font-weight: 600; }
.chart .col.on .nm { color: var(--gold); }
.chart .vl { font-size: 10px; color: var(--text-2); font-weight: 700; }

/* ---------------------------------------------------------------- Jadval */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 900px; }
table.grid th {
  background: var(--paper); text-align: left; font-weight: 650; font-size: 11.5px;
  color: var(--text-2); text-transform: uppercase; letter-spacing: .03em;
  padding: 10px 9px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5; white-space: nowrap;
}
table.grid td { padding: 9px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.grid tbody tr:hover { background: #fafbfc; }
table.grid td.r, table.grid th.r { text-align: right; }
table.grid td.c, table.grid th.c { text-align: center; }
table.grid tr.floor-row td {
  background: var(--gold-soft); font-weight: 700; font-size: 12.5px;
  color: #7a5a1c; letter-spacing: .02em; padding: 7px 9px;
  border-bottom: 1px solid #f0e1c2;
}
table.grid tr.closed td { background: var(--green-soft); }
table.grid tr.closed:hover td { background: #ddf0e7; }
table.grid tr.flagged { box-shadow: inset 3px 0 0 var(--red); }
table.grid tfoot td {
  background: var(--ink); color: #fff; font-weight: 700; font-size: 14px;
  border: 0; padding: 12px 9px;
}
.cell-client { max-width: 320px; }
.cell-client .name { font-weight: 600; color: inherit; text-decoration: none; display: block; }
.cell-client .name:hover { color: var(--gold); text-decoration: underline; }
.cell-client .more { color: var(--text-3); font-size: 12px; }

.pay-input {
  width: 100px; text-align: right; font-variant-numeric: tabular-nums;
  border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px;
  font-size: 13.5px; font-family: inherit; background: #fff;
}
.pay-input:focus { border-color: var(--gold); outline: none;
  box-shadow: 0 0 0 3px rgba(200,150,62,.15); }
.pay-input.saved { border-color: var(--green); background: var(--green-soft); }
.pay-input.error { border-color: var(--red); background: var(--red-soft); }

.pay-wrap { display: inline-flex; align-items: center; gap: 6px; }
.pay-add-btn {
  flex: none; width: 28px; height: 28px; border-radius: 7px; border: none;
  background: var(--gold); color: #fff; font-size: 16px; font-weight: 700;
  line-height: 1; cursor: pointer; display: inline-flex; align-items: center;
  justify-content: center; transition: background .12s;
}
.pay-add-btn:hover { background: #a97a2b; }
.pay-add-btn:disabled { opacity: .5; cursor: default; }
.pay-add-btn.saved { background: var(--green); }

/* ---------------------------------------------------------------- Mobil kartalar */
.rows-mobile { display: block; }
@media (min-width: 1000px) { .rows-mobile { display: none; } }
.table-desktop { display: none; }
@media (min-width: 1000px) { .table-desktop { display: block; } }

.floor-title {
  background: var(--gold-soft); color: #7a5a1c; font-weight: 700; font-size: 12px;
  padding: 7px 14px; letter-spacing: .03em; border-top: 1px solid #f0e1c2;
  border-bottom: 1px solid #f0e1c2;
}
.mrow {
  padding: 12px 14px; border-bottom: 1px solid var(--line-soft);
  display: block; color: inherit; text-decoration: none;
}
.mrow:hover { text-decoration: none; background: #fafbfc; }
.mrow.closed { background: var(--green-soft); }
.mrow-top { display: flex; align-items: baseline; gap: 8px; }
.mrow-no {
  font-weight: 700; font-size: 13px; background: var(--ink); color: #fff;
  border-radius: 6px; padding: 2px 7px; flex: none; min-width: 30px; text-align: center;
}
.mrow-name { font-weight: 620; font-size: 14.5px; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: inherit; text-decoration: none; }
.mrow-name:hover { color: var(--gold); text-decoration: underline; }
.mrow-meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.mrow-nums {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 9px;
}
.mrow-nums div { min-width: 0; }
.mrow-nums .k { font-size: 10.5px; color: var(--text-3); text-transform: uppercase;
  letter-spacing: .03em; font-weight: 600; }
.mrow-nums .v { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.mrow-nums .v.green { color: var(--green); }
.mrow-nums .v.red { color: var(--red); }
.mrow-pay { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.mrow-pay label { font-size: 11.5px; color: var(--text-2); font-weight: 600; flex: none; }

/* ---------------------------------------------------------------- Badge */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px;
  letter-spacing: .02em; white-space: nowrap;
}
.badge.sold   { background: var(--blue-soft); color: var(--blue); }
.badge.booked { background: var(--gold-soft); color: #96702a; }
.badge.free   { background: var(--line-soft); color: var(--text-2); }
.badge.done   { background: var(--green-soft); color: var(--green); }
.badge.debt   { background: var(--red-soft); color: var(--red); }
.badge.flag   { background: var(--red-soft); color: var(--red); }

/* ---------------------------------------------------------------- Xabarlar */
.msgs { margin-bottom: 14px; display: grid; gap: 8px; }
.msg {
  padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13.5px;
  border: 1px solid transparent; display: flex; gap: 9px; align-items: flex-start;
}
.msg.success { background: var(--green-soft); border-color: #bfe4d5; color: #0c5c43; }
.msg.error   { background: var(--red-soft); border-color: #f5c9c4; color: #92251a; }
.msg.warning { background: var(--gold-soft); border-color: #ecd9b0; color: #7a5a1c; }
.msg.info    { background: var(--blue-soft); border-color: #c7dcfb; color: #14539f; }

.empty { padding: 40px 20px; text-align: center; color: var(--text-3); }
.empty .ic { font-size: 34px; opacity: .4; display: block; margin-bottom: 8px; }

/* ---------------------------------------------------------------- Form */
.form-grid { display: grid; gap: 14px; }
@media (min-width: 700px) { .form-grid.cols-2 { grid-template-columns: 1fr 1fr; } }
.field label {
  display: block; font-size: 12.5px; font-weight: 650; color: var(--text-2);
  margin-bottom: 5px;
}
.field .help { font-size: 11.5px; color: var(--text-3); margin-top: 4px; }
.field .err { font-size: 12px; color: var(--red); margin-top: 4px; font-weight: 600; }
.field.span-2 { grid-column: 1 / -1; }
.checkbox { width: 17px; height: 17px; accent-color: var(--gold); }
.form-actions {
  display: flex; gap: 10px; margin-top: 18px; padding-top: 16px;
  border-top: 1px solid var(--line-soft); flex-wrap: wrap;
}

/* ---------------------------------------------------------------- Login */
.auth-wrap {
  min-height: 100vh; min-height: 100dvh; display: grid; place-items: center;
  padding: 20px; background: var(--ink);
  background-image: radial-gradient(900px 500px at 15% -10%, #22364a 0%, transparent 60%),
                    radial-gradient(700px 500px at 110% 110%, #3a2c14 0%, transparent 55%);
}
.auth-card {
  width: 100%; max-width: 400px; background: #fff; border-radius: 18px;
  padding: 30px 26px; box-shadow: var(--shadow-lg);
}
.auth-logo {
  width: 52px; height: 52px; border-radius: 14px; margin: 0 auto 16px;
  background: linear-gradient(140deg, var(--gold), #a97a2b);
  display: grid; place-items: center; font-weight: 800; font-size: 20px; color: #1a1206;
}
.auth-card h1 { margin: 0 0 4px; font-size: 20px; text-align: center; font-weight: 700; }
.auth-card .sub { text-align: center; color: var(--text-2); font-size: 13px;
  margin: 0 0 22px; }
.auth-card .field { margin-bottom: 13px; }
.auth-foot { margin-top: 20px; text-align: center; font-size: 11.5px; color: var(--text-3); }

/* ---------------------------------------------------------------- Install */
.install-banner {
  position: fixed; left: 12px; right: 12px;
  bottom: calc(var(--bottomnav-h) + 12px + env(safe-area-inset-bottom));
  z-index: 60; background: var(--ink); color: #fff;
  border-radius: var(--radius); padding: 13px 15px; box-shadow: var(--shadow-lg);
  display: none; align-items: center; gap: 12px;
}
.install-banner.show { display: flex; }
.install-banner .txt { flex: 1; min-width: 0; }
.install-banner .t1 { font-weight: 650; font-size: 14px; }
.install-banner .t2 { font-size: 12px; color: #9fb0c1; }
.install-banner .x { background: none; border: 0; color: #7d8fa0; font-size: 20px;
  cursor: pointer; padding: 0 4px; }
@media (min-width: 900px) {
  .install-banner { left: auto; right: 22px; bottom: 22px; max-width: 380px; }
}

/* ---------------------------------------------------------------- Modal */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,32,.5); z-index: 70;
  display: none; align-items: flex-end; justify-content: center;
}
.sheet-backdrop.show { display: flex; }
@media (min-width: 700px) { .sheet-backdrop.show { align-items: center; } }
.sheet {
  background: #fff; width: 100%; max-width: 520px; border-radius: 18px 18px 0 0;
  padding: 20px; max-height: 88vh; overflow-y: auto;
}
@media (min-width: 700px) { .sheet { border-radius: 16px; } }

/* ---------------------------------------------------------------- Misc */
.hr { height: 1px; background: var(--line-soft); margin: 16px 0; border: 0; }
.stack { display: grid; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.muted { color: var(--text-2); }
.small { font-size: 12.5px; }
.strong { font-weight: 700; }
.green { color: var(--green); }
.red { color: var(--red); }
.gold { color: var(--gold); }
.nowrap { white-space: nowrap; }
.hide-mobile { display: none; }
@media (min-width: 700px) { .hide-mobile { display: initial; } }

.dl { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; font-size: 13.5px; }
.dl dt { color: var(--text-2); font-weight: 600; }
.dl dd { margin: 0; font-weight: 600; text-align: right; }

.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: #fff; font-size: 13px; font-weight: 600; color: var(--text-2);
  text-decoration: none; cursor: pointer;
}
.chip:hover { background: var(--paper); text-decoration: none; }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }

@media print {
  .topbar, .bottomnav, .period-bar, .install-banner, .btn, .no-print { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #999; }
  table.grid { min-width: 0; font-size: 10px; }
}
