/* Oylik daftari — telefon birinchi, keyin kompyuter.
   Ranglar: Rishton sopolining ishqor ko'ki va firuzasi, oq loy foni. */

:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-2: #f1eee6;
  --text: #1b2230;
  --muted: #5f6878;
  --border: #e2ddd1;
  --primary: #1f4e9c;        /* ishqor ko'k */
  --primary-ink: #ffffff;
  --primary-soft: #e6edf8;
  --accent: #1a9a8c;         /* firuza */
  --clay: #b5652b;           /* sopol jigarrang */
  --pos: #0f7a4a;
  --pos-soft: #e3f3ea;
  --neg: #b3261e;
  --neg-soft: #fbe9e7;
  --focus: #f0a020;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 2px 8px rgba(20, 30, 50, .05);
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1520;
    --surface: #18202e;
    --surface-2: #212b3b;
    --text: #e9edf4;
    --muted: #9aa5b6;
    --border: #2c3747;
    --primary: #6f9bea;
    --primary-ink: #0b1220;
    --primary-soft: #1d2a42;
    --accent: #45c2b2;
    --clay: #d98a50;
    --pos: #5fd394;
    --pos-soft: #16302a;
    --neg: #ff8a80;
    --neg-soft: #3a1f22;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1520;
  --surface: #18202e;
  --surface-2: #212b3b;
  --text: #e9edf4;
  --muted: #9aa5b6;
  --border: #2c3747;
  --primary: #6f9bea;
  --primary-ink: #0b1220;
  --primary-soft: #1d2a42;
  --accent: #45c2b2;
  --clay: #d98a50;
  --pos: #5fd394;
  --pos-soft: #16302a;
  --neg: #ff8a80;
  --neg-soft: #3a1f22;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}
a { color: var(--primary); }
h1 { font-size: 1.5rem; margin: 0; line-height: 1.2; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
small { font-size: .82em; }
code { background: var(--surface-2); padding: .05em .35em; border-radius: 6px; font-size: .9em; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- sarlavha ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  max-width: 920px; margin: 0 auto; padding: 6px 12px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; color: var(--text); text-decoration: none; margin-right: auto;
  min-height: 44px;
}
.brand-mark {
  width: 22px; height: 22px; border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, var(--surface) 0 3px, transparent 3.5px),
    conic-gradient(var(--primary) 0 25%, var(--accent) 0 50%, var(--primary) 0 75%, var(--accent) 0);
  box-shadow: 0 0 0 2px var(--clay);
}
.nav { display: flex; gap: 2px; order: 3; width: 100%; }
.nav a {
  flex: 1; text-align: center; padding: 10px 6px; min-height: 44px;
  color: var(--muted); text-decoration: none; font-weight: 600; border-radius: 10px;
}
.nav a.on { color: var(--primary); background: var(--primary-soft); }
.topbar-tools { display: flex; gap: 4px; }
.topbar-tools form { margin: 0; }
.icon-btn {
  width: 44px; height: 44px; display: grid; place-items: center;
  border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* Ikat naqshli chiziq (Rishton ranglari) */
.ikat {
  height: 6px;
  background:
    repeating-linear-gradient(90deg,
      var(--primary) 0 14px, var(--accent) 14px 18px, var(--surface) 18px 20px,
      var(--clay) 20px 30px, var(--surface) 30px 32px, var(--accent) 32px 36px);
  -webkit-mask: linear-gradient(180deg, #000 0 100%);
  opacity: .9;
}
.ikat-round { border-radius: var(--radius) var(--radius) 0 0; margin: -20px -20px 16px; }

@media (min-width: 720px) {
  .nav { order: 0; width: auto; }
  .nav a { flex: none; padding: 10px 14px; }
}

/* ---------- sahifa ---------- */
.page { max-width: 920px; margin: 0 auto; padding: 14px 12px 24px; }
.page-head { margin: 4px 2px 14px; }
.page-head-sub { color: var(--muted); margin-top: 4px; }
.back { display: inline-block; text-decoration: none; padding: 8px 0; min-height: 44px; font-weight: 600; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 14px;
}
.card-title { font-size: 1.02rem; margin: 0 0 12px; }
details > summary.card-title { margin: 0; }
details[open] > summary.card-title { margin-bottom: 12px; }
summary { cursor: pointer; min-height: 32px; font-weight: 600; }
.more { margin-top: 12px; }
.more > summary { color: var(--primary); font-size: .95rem; padding: 8px 0; }
.empty { text-align: center; }

.alert { padding: 12px 14px; border-radius: 12px; margin: 0 0 12px; border: 1px solid transparent; }
.alert-error { background: var(--neg-soft); color: var(--neg); border-color: color-mix(in srgb, var(--neg) 30%, transparent); }
.alert-ok { background: var(--pos-soft); color: var(--pos); }
.alert-info { background: var(--primary-soft); color: var(--primary); }

/* ---------- formalar ---------- */
label { display: block; font-weight: 600; font-size: .93rem; }
input, textarea, select {
  display: block; width: 100%; margin-top: 6px;
  font: inherit; font-size: 1rem; /* iOS kattalashtirmasligi uchun 16px */
  color: var(--text); background: var(--surface);
  border: 1.5px solid var(--border); border-radius: 12px;
  padding: 10px 12px; min-height: 48px;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, textarea:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--primary-soft); }
input[type="file"] { padding: 10px; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 500; min-height: 44px; }
.check input { width: 22px; height: 22px; min-height: 0; margin: 0; flex: none; }
.stack > * + * { margin-top: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { color: var(--muted); font-size: .88rem; margin: 10px 0 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 10px 18px;
  font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
  color: var(--primary); background: var(--primary-soft);
  border: 1.5px solid transparent; border-radius: 12px;
  -webkit-tap-highlight-color: transparent;
  transition: transform .06s ease, filter .12s ease;
}
.btn:active { transform: scale(.98); }
.btn:hover { filter: brightness(.97); }
.btn[disabled], .btn.disabled { opacity: .45; pointer-events: none; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-danger { background: var(--neg-soft); color: var(--neg); border-color: color-mix(in srgb, var(--neg) 35%, transparent); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-block { display: flex; width: 100%; margin-top: 12px; }
.link-btn {
  background: none; border: 0; padding: 8px 4px; min-height: 40px; cursor: pointer;
  font: inherit; font-size: .88rem; color: var(--primary); text-decoration: underline;
}
.link-btn.danger { color: var(--neg); }

.quick-row { display: flex; gap: 8px; align-items: stretch; }
.quick-row input { margin: 0; }
.quick-row .btn { flex: none; }
.input-lg { font-size: 1.1rem; }

.preview { min-height: 1.5em; margin-top: 8px; font-weight: 600; font-variant-numeric: tabular-nums; }
.preview-ok { color: var(--pos); }
.preview-error { color: var(--neg); }
.preview .warn { color: var(--clay); font-weight: 600; }

.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg-item { flex: 1 1 auto; margin: 0; font-weight: 600; }
.seg-item input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; }
.seg-item span {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 44px; padding: 8px 12px; border-radius: 10px;
  border: 1.5px solid var(--border); background: var(--surface); cursor: pointer;
}
.seg-item input:checked + span { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.seg-item input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- oy tanlash ---------- */
.month-nav { display: flex; align-items: center; gap: 8px; margin: 4px 0 14px; }
.month-title { flex: 1; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 1.15rem; }
.month-arrow { width: 52px; padding: 0; font-size: 1.6rem; line-height: 1; }
.chip {
  display: inline-block; font-size: .74rem; font-weight: 700; letter-spacing: .02em;
  padding: 2px 8px; border-radius: 999px; background: var(--primary-soft); color: var(--primary);
}
.chip-muted { background: var(--surface-2); color: var(--muted); }

/* ---------- jami ---------- */
.totals { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.total {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow);
}
.total:first-child { grid-column: 1 / -1; }
.total-label { color: var(--muted); font-size: .85rem; font-weight: 600; }
.total-value { font-size: 1.2rem; font-weight: 800; text-align: left; }
.total-sub { color: var(--muted); font-size: .82rem; }
.total-pay .total-value { color: var(--pos); }
.total-debt .total-value { color: var(--neg); }
@media (min-width: 720px) {
  .totals { grid-template-columns: repeat(3, 1fr); }
  .total:first-child { grid-column: auto; }
}

/* ---------- ishchilar ro'yxati ---------- */
.worker-list { list-style: none; margin: 0; padding: 0; }
.worker-row { display: block; color: inherit; text-decoration: none; padding: 14px 16px; margin-bottom: 10px; }
a.worker-row:hover { border-color: var(--primary); }
.worker-row.is-left { opacity: .75; }
.wr-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.wr-name { font-weight: 800; font-size: 1.08rem; color: var(--text); text-decoration: none; }
.wr-balance { margin-left: auto; font-weight: 800; }
.wr-balance.pos { color: var(--pos); }
.wr-balance.neg { color: var(--neg); }
.wr-balance.zero { color: var(--muted); font-weight: 600; font-size: .9rem; }
.wr-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 6px; color: var(--muted); font-size: .9rem; }
.wr-meta b { color: var(--text); font-weight: 700; }

/* ---------- ishchi kartasi ---------- */
.calc { width: 100%; border-collapse: collapse; }
.calc th { text-align: left; font-weight: 500; color: var(--muted); padding: 8px 0; }
.calc td { padding: 8px 0; font-weight: 600; }
.calc tbody tr + tr th, .calc tbody tr + tr td { border-top: 1px dashed var(--border); }
.calc tfoot th, .calc tfoot td { border-top: 2px solid var(--text); padding-top: 12px; font-size: 1.2rem; font-weight: 800; color: var(--text); }
.calc tfoot small { display: block; font-size: .75rem; font-weight: 600; color: var(--muted); }
.calc tfoot .pos td { color: var(--pos); }
.calc tfoot .neg td { color: var(--neg); }

.quick-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quick-buttons form { margin: 0; }
.btn-amount { width: 100%; min-height: 60px; font-size: 1.2rem; font-variant-numeric: tabular-nums; }
@media (min-width: 720px) { .quick-buttons { grid-template-columns: repeat(4, 1fr); } }

.entries { list-style: none; margin: 0; padding: 0; }
.entry { padding: 10px 0; border-top: 1px solid var(--border); }
.entry:first-child { border-top: 0; }
.entry-main { display: flex; justify-content: space-between; gap: 10px; font-weight: 700; }
.entry-kind::before {
  content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px;
  margin-right: 8px; background: var(--primary); vertical-align: 1px;
}
.entry-bonus .entry-kind::before { background: var(--pos); }
.entry-fine .entry-kind::before { background: var(--neg); }
.entry-payment .entry-kind::before { background: var(--accent); }
.entry-bonus .entry-amount { color: var(--pos); }
.entry-sub { display: flex; align-items: center; flex-wrap: wrap; gap: 0 12px; color: var(--muted); font-size: .9rem; }
.entry-sub form { margin: 0 0 0 auto; }
.entry-note { color: var(--text); }

/* ---------- hisobot jadvali ---------- */
.table-scroll { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
.report { border-collapse: collapse; width: 100%; min-width: 900px; font-size: .92rem; }
.report th, .report td { padding: 9px 8px; border-bottom: 1px solid var(--border); }
.report thead th { text-align: right; color: var(--muted); font-weight: 700; font-size: .8rem; white-space: nowrap; }
.report thead th:first-child, .report tbody th, .report tfoot th { text-align: left; }
.report tbody th { font-weight: 700; white-space: nowrap; }
.report tfoot th, .report tfoot td { font-weight: 800; border-top: 2px solid var(--text); border-bottom: 0; }
.report .pos { color: var(--pos); }
.report .neg { color: var(--neg); }

/* ---------- kirish ---------- */
.login-wrap { min-height: 80vh; display: grid; place-items: center; }
.login-card { width: 100%; max-width: 380px; padding: 20px; overflow: hidden; }
.login-card h1 { margin-bottom: 4px; }

/* ---------- bekor qilish ---------- */
.toast {
  position: fixed; left: 12px; right: 12px; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 20;
  max-width: 560px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px;
  background: #1b2230; color: #fff; border-radius: 14px; padding: 8px 8px 8px 16px;
  box-shadow: 0 8px 28px rgba(0,0,0,.25);
  transition: opacity .3s ease, transform .3s ease;
}
:root[data-theme="dark"] .toast { background: #2c3a52; }
.toast span { flex: 1; font-weight: 600; }
.toast form { margin: 0; }
.toast-btn {
  min-height: 44px; padding: 8px 14px; border: 0; border-radius: 10px; cursor: pointer;
  font: inherit; font-weight: 800; background: #f0c060; color: #1b2230;
}
.toast.hide { opacity: 0; transform: translateY(20px); pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- davomat ---------- */
.att-list { list-style: none; margin: 0; padding: 0; }
.att-item { border-top: 1px solid var(--border); }
.att-list li:first-child .att-item { border-top: 0; }
.att-item > summary {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  min-height: 52px; padding: 6px 0; list-style: none;
}
.att-item > summary::-webkit-details-marker { display: none; }
.att-name { font-weight: 700; }
.att-chip {
  margin-left: auto; font-size: .82rem; font-weight: 800; padding: 4px 10px; border-radius: 999px;
  background: var(--pos-soft); color: var(--pos);
}
.att-half .att-chip { background: color-mix(in srgb, var(--clay) 18%, transparent); color: var(--clay); }
.att-absent .att-chip { background: var(--neg-soft); color: var(--neg); }
.att-why { width: 100%; color: var(--muted); font-size: .88rem; font-weight: 500; }
.att-item[open] > summary { padding-bottom: 10px; }
.att-form { padding-bottom: 14px; }
.seg-att .seg-item { flex: 1 1 0; }
.seg-att .seg-item:nth-child(1) input:checked + span { background: var(--pos); border-color: var(--pos); color: #fff; }
.seg-att .seg-item:nth-child(2) input:checked + span { background: var(--clay); border-color: var(--clay); color: #fff; }
.seg-att .seg-item:nth-child(3) input:checked + span { background: var(--neg); border-color: var(--neg); color: #fff; }

.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-wd { text-align: center; font-size: .75rem; font-weight: 700; color: var(--muted); padding-bottom: 2px; }
.cal-cell {
  display: grid; place-items: center; aspect-ratio: 1 / 1; min-height: 40px;
  border-radius: 10px; font-weight: 700; font-variant-numeric: tabular-nums; text-decoration: none;
  color: var(--text); border: 1.5px solid transparent;
}
a.cal-cell:hover { border-color: var(--primary); }
.cal-present { background: var(--pos-soft); color: var(--pos); }
.cal-half { background: color-mix(in srgb, var(--clay) 22%, var(--surface)); color: var(--clay);
  background-image: linear-gradient(135deg, transparent 50%, color-mix(in srgb, var(--clay) 18%, transparent) 50%); }
.cal-absent { background: var(--neg); color: #fff; }
.cal-future { color: var(--muted); opacity: .55; }
.cal-off { color: var(--muted); opacity: .35; text-decoration: line-through; }
.cal-sel { border-color: var(--text); box-shadow: 0 0 0 2px var(--surface) inset; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: .82rem; color: var(--muted); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.dot-present { background: var(--pos); }
.dot-half { background: var(--clay); }
.dot-absent { background: var(--neg); }
.att-panel { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); }
.att-panel h3 { margin: 0 0 4px; font-size: 1rem; }
.att-days { margin-top: 12px; }
.entry-absent .entry-kind::before { background: var(--neg); }
.entry-half .entry-kind::before { background: var(--clay); }
