:root {
  --bg: #f6f4ee;
  --surface: #ffffff;
  --ink: #1c2b22;
  --muted: #66736b;
  --line: #e3e0d6;
  --primary: #14532d;
  --primary-ink: #ffffff;
  --primary-soft: #e3efe6;
  --accent: #92d050;
  --bsb: #1d4ed8;
  --bsb-soft: #e4ebfc;
  --chsb: #b45309;
  --chsb-soft: #fbeedd;
  --danger: #b42318;
  --danger-soft: #fde8e6;
  --warn-soft: #fff4d6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(28, 43, 34, .06), 0 4px 16px rgba(28, 43, 34, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111612; --surface: #1a211c; --ink: #e8efe9; --muted: #98a59c; --line: #2b352e;
    --primary: #4ade80; --primary-ink: #0b1a10; --primary-soft: #1d3324;
    --bsb: #8fb0ff; --bsb-soft: #1c2640; --chsb: #f4b66a; --chsb-soft: #3a2a17;
    --danger: #ff8a7d; --danger-soft: #3b1e1b; --warn-soft: #3a3217;
    --shadow: none; color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
body.auth { padding-bottom: 0; }
a { color: var(--primary); }
h1 { font-size: 1.55rem; line-height: 1.2; margin: .3rem 0 .4rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin: 1.6rem 0 .6rem; }
h3 { font-size: 1rem; margin: 0; }
.muted { color: var(--muted); margin-top: 0; }
.small { font-size: .875rem; }
.center { text-align: center; }

.wrap { max-width: 760px; margin: 0 auto; padding: 16px; }
body.wide .wrap { max-width: 1200px; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.1rem; color: var(--ink); text-decoration: none; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.topnav { display: none; gap: 4px; flex: 1; }
.topnav a { color: var(--ink); text-decoration: none; padding: 6px 10px; border-radius: 8px; font-size: .95rem; }
.topnav a:hover { background: var(--primary-soft); }
.sub-pill { margin-left: auto; font-size: .8rem; padding: 5px 10px; border-radius: 999px; text-decoration: none; white-space: nowrap; }
.sub-active { background: var(--primary-soft); color: var(--primary); }
.sub-pending { background: var(--warn-soft); color: var(--chsb); }
.sub-none { background: var(--danger-soft); color: var(--danger); }

/* Bottom tab bar (telefon) */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: flex;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px;
  font-size: .72rem; color: var(--muted); text-decoration: none;
}
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.on { color: var(--primary); font-weight: 600; }
@media (min-width: 860px) {
  .topnav { display: flex; }
  .tabbar { display: none; }
  body { padding-bottom: 32px; }
}

/* Cards, lists */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; box-shadow: var(--shadow); }
.stack > * + * { margin-top: 12px; }
.notice { display: block; text-decoration: none; color: var(--ink); background: var(--warn-soft); border-color: transparent; }
.notice b { display: block; }
.notice span { color: var(--muted); font-size: .92rem; }
.list { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: var(--ink);
}
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; text-decoration: none; color: inherit; }
.row-main b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-main small { color: var(--muted); }
.chip { font-size: .78rem; font-weight: 700; padding: 4px 8px; border-radius: 8px; background: var(--primary-soft); color: var(--primary); white-space: nowrap; }
.chip-bsb { background: var(--bsb-soft); color: var(--bsb); }
.chip-chsb { background: var(--chsb-soft); color: var(--chsb); }
.status { font-size: .8rem; color: var(--chsb); white-space: nowrap; }
.status.ok { color: var(--primary); }
.status.bad { color: var(--danger); }
.back { display: inline-block; margin: 4px 0 6px; text-decoration: none; color: var(--muted); font-size: .92rem; }
.actions-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.actions-row.center { justify-content: center; }

/* Home big buttons */
.hello { margin: 8px 0 4px; }
.big-actions { display: grid; gap: 12px; grid-template-columns: 1fr; margin: 14px 0; }
@media (min-width: 560px) { .big-actions { grid-template-columns: 1fr 1fr; } }
.big {
  display: flex; flex-direction: column; gap: 4px; padding: 22px 20px; border-radius: 18px;
  text-decoration: none; color: #fff; min-height: 150px; justify-content: flex-end; position: relative; overflow: hidden;
  transition: transform .12s ease;
}
.big:active { transform: scale(.98); }
.big-bsb { background: linear-gradient(135deg, #1e40af, #2563eb); }
.big-chsb { background: linear-gradient(135deg, #9a3412, #d97706); }
.big-tag { position: absolute; top: 14px; right: 16px; font-size: 2.6rem; font-weight: 800; opacity: .18; letter-spacing: -.02em; }
.big-title { font-size: 1.25rem; font-weight: 700; }
.big-sub { opacity: .85; font-size: .92rem; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-weight: 600; font-size: .92rem; }
.field small { color: var(--muted); font-size: .82rem; }
.field .err, .err { color: var(--danger); font-size: .85rem; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); width: 100%;
  border: 1.5px solid var(--line); border-radius: 10px; padding: 11px 12px; min-height: 46px;
}
textarea { min-height: 220px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.has-error input, .has-error textarea, .has-error select { border-color: var(--danger); }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; }
input[type=file] { padding: 10px; }
.grid2 { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.inline-form { display: flex; gap: 10px; align-items: flex-end; }
.grow { flex: 1; }
details > summary { cursor: pointer; font-weight: 600; }
details[open] > summary { margin-bottom: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600;
  min-height: 46px; padding: 10px 18px; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--surface); color: var(--ink); text-decoration: none; cursor: pointer;
}
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-danger { background: transparent; border-color: var(--danger-soft); color: var(--danger); }
.btn-ghost { background: transparent; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: .88rem; border-radius: 10px; }
.btn-lg { min-height: 56px; font-size: 1.08rem; }
.btn-block { width: 100%; }

.messages { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.msg { padding: 12px 14px; border-radius: 12px; background: var(--primary-soft); font-size: .95rem; }
.msg-error { background: var(--danger-soft); color: var(--danger); }
.msg-warning { background: var(--warn-soft); }

/* Auth */
.auth .wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card h1 { text-align: center; }
.auth-card > .muted { text-align: center; }
.auth-logo { display: block; width: 72px; height: 72px; border-radius: 18px; margin: 0 auto 8px; }

/* Roster guide */
.steps { margin: 0; padding-left: 1.3rem; }
.steps li + li { margin-top: 6px; }
.prompt-box { background: var(--bg); border: 1px dashed var(--line); border-radius: 12px; padding: 12px; margin-top: 12px; }
.prompt-box pre { margin: 0 0 10px; white-space: pre-wrap; font: .86rem/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; max-height: 220px; overflow: auto; }

/* Task grid */
.task-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); gap: 8px; }
.task-grid label { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: .78rem; color: var(--muted); }
.task-grid input { text-align: center; padding: 8px 4px; min-height: 40px; }

/* Score sheet */
.fill-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.sheet-wrap {
  overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  max-height: calc(100dvh - 150px); min-height: 360px; box-shadow: var(--shadow);
}
.sheet { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .92rem; }
.sheet th, .sheet td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 0; text-align: center; }
.sheet th { position: sticky; top: 0; z-index: 2; background: var(--surface); padding: 8px 4px; font-weight: 700; min-width: 54px; }
.sheet th small { display: block; font-weight: 400; color: var(--muted); font-size: .72rem; }
.sheet .c-n { width: 36px; min-width: 36px; color: var(--muted); padding: 0 4px; }
@media (max-width: 699px) { .sheet .c-n { display: none; } .fill-intro { display: none; } }
.sheet .c-name {
  position: sticky; left: 0; z-index: 1; background: var(--surface); text-align: left; padding: 6px 10px;
  min-width: 104px; max-width: 112px; white-space: normal; overflow: hidden; font-size: .8rem; line-height: 1.2;
  box-shadow: 1px 0 0 var(--line);
}
@media (min-width: 700px) { .sheet .c-name { min-width: 220px; max-width: 300px; font-size: .92rem; white-space: nowrap; text-overflow: ellipsis; } }
.sheet th.c-name { z-index: 3; }
.sheet td input {
  border: 0; border-radius: 0; min-height: 54px; padding: 4px; text-align: center; width: 100%; min-width: 64px;
  background: color-mix(in srgb, var(--primary) 6%, transparent); font-weight: 700; font-size: 1.15rem;
}
.sheet td input::placeholder { color: color-mix(in srgb, var(--muted) 55%, transparent); font-weight: 400; }
.sheet td input:focus { box-shadow: inset 0 0 0 2px var(--primary); }
.sheet td input.bad { background: var(--danger-soft); color: var(--danger); }
.sheet .c-sum { background: color-mix(in srgb, var(--accent) 22%, var(--surface)); font-weight: 700; padding: 0 8px; white-space: nowrap; }
.sheet td input[type=checkbox] { width: 20px; height: 20px; min-width: 0; min-height: 0; margin: 0 10px; accent-color: var(--primary); }
.sheet tr.absent td:not(.c-name):not(:last-child) { background: var(--bg); }
.sheet tr.absent .c-name { color: var(--muted); text-decoration: line-through; }
.fill-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 12px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}

/* Done */
.done { text-align: center; padding: 32px 20px; }
.done-icon { width: 72px; height: 72px; margin: 0 auto 10px; border-radius: 50%; display: grid; place-items: center; font-size: 2.2rem; background: var(--primary-soft); color: var(--primary); }

/* Billing */
.sub-status { display: flex; flex-direction: column; gap: 2px; }
.sub-status.sub-active { background: var(--primary-soft); color: var(--ink); border-color: transparent; }
.sub-status.sub-pending { background: var(--warn-soft); color: var(--ink); border-color: transparent; }
.sub-status.sub-none { background: var(--danger-soft); color: var(--ink); border-color: transparent; }
.price b { font-size: 2rem; letter-spacing: -.02em; }
.cards { display: flex; flex-direction: column; gap: 10px; }
.pay-card { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1.5px solid var(--line); border-radius: 14px; cursor: pointer; }
.pay-card:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.pay-card input { accent-color: var(--primary); width: 20px; height: 20px; }
.pay-card-body { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.pay-card-type { font-size: .8rem; color: var(--muted); font-weight: 600; }
.pay-card-num { font: 600 1rem/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: nowrap; }
.pay-card-holder { font-size: .85rem; color: var(--muted); }

/* Tariflar */
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 640px) { .plans { grid-template-columns: repeat(4, 1fr); } }
.plan {
  position: relative; display: flex; flex-direction: column; gap: 2px; padding: 14px 12px; cursor: pointer;
  border: 1.5px solid var(--line); border-radius: 14px; background: var(--surface);
}
.plan input { position: absolute; opacity: 0; pointer-events: none; }
.plan:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.plan-name { font-size: .85rem; color: var(--muted); font-weight: 600; }
.plan-price { font-size: 1.3rem; font-weight: 700; letter-spacing: -.01em; }
.plan-price small { font-size: .8rem; font-weight: 500; color: var(--muted); }
.plan-note { font-size: .76rem; color: var(--muted); }
.plan-note b { color: var(--primary); font-weight: 600; }

/* Qo'shimcha muddat ogohlantirishi */
.grace-banner {
  display: block; margin-bottom: 12px; padding: 12px 14px; border-radius: 12px; text-decoration: none;
  background: var(--warn-soft); color: var(--ink); border: 1px solid color-mix(in srgb, var(--chsb) 30%, transparent);
}
.grace-banner b { display: block; }
.grace-banner span { font-size: .9rem; color: var(--muted); }
.sub-grace { background: var(--warn-soft); color: var(--chsb); }
.sub-status.sub-grace { background: var(--warn-soft); color: var(--ink); border-color: transparent; }
