:root {
  --bg: #f5f6f8; --card: #ffffff; --text: #1d2330; --muted: #6b7280; --line: #e3e6eb;
  --brand: #1f4e79; --brand-2: #163a5a; --danger: #b42318; --ok: #067647;
  --unset: #eef0f3; --open: #dcf5e5; --open-b: #7cc79a; --closed: #d9dce1;
  --pending: #fff1c7; --pending-b: #e3a008; --confirmed: #dbe7fb; --confirmed-b: #3b73c4;
  --done: #ebe4f7; --done-b: #7c5cbf; --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.35rem; margin: 0 0 .75rem; }
h2 { font-size: 1.1rem; margin: 1.25rem 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* layout */
.top { background: var(--brand); color: #fff; position: sticky; top: 0; z-index: 10; }
.top-in { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; gap: .75rem; padding: .55rem 16px; }
.brand { color: #fff; font-weight: 700; letter-spacing: .04em; font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: .15rem; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav a { color: #dbe6f2; padding: .35rem .6rem; border-radius: 8px; white-space: nowrap; }
.nav a.on, .nav a:hover { background: var(--brand-2); color: #fff; text-decoration: none; }
.who { display: flex; gap: .5rem; align-items: center; }
.who a { color: #dbe6f2; }
.linkbtn { background: none; border: 0; color: #dbe6f2; cursor: pointer; font: inherit; padding: 0; }
main { max-width: 1180px; margin: 0 auto; padding: 16px; }

/* cards & forms */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 900px) { .grid2 { grid-template-columns: 1.2fr 1fr; } }
.fields { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .fields { grid-template-columns: 1fr 1fr; } .fields .full { grid-column: 1 / -1; } }
label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .25rem; }
input, select, textarea { width: 100%; font: inherit; padding: .55rem .65rem; border: 1px solid #c9ced6;
  border-radius: 8px; background: #fff; color: var(--text); min-height: 42px; }
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc0e8; border-color: var(--brand); }
.field-error input, .field-error select, .field-error textarea { border-color: var(--danger); }
.err { color: var(--danger); font-size: .85rem; margin-top: .2rem; }
.hint { color: var(--muted); font-size: .82rem; margin-top: .2rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; min-height: 42px;
  padding: .5rem 1rem; border-radius: 8px; border: 1px solid var(--brand); background: var(--brand); color: #fff;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--brand-2); text-decoration: none; }
.btn.ghost { background: #fff; color: var(--brand); }
.btn.ghost:hover { background: #eef4fb; }
.btn.danger { background: #fff; color: var(--danger); border-color: #f0b4ae; }
.btn.danger:hover { background: #fdf0ef; }
.btn.small { min-height: 34px; padding: .3rem .7rem; font-size: .88rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 12px; }
.alert { padding: .7rem .9rem; border-radius: 8px; margin-bottom: 14px; }
.alert.ok { background: #e7f6ec; color: var(--ok); border: 1px solid #b5e2c4; }
.alert.bad { background: #fdecea; color: var(--danger); border: 1px solid #f3c1bb; }
details.more { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 10px; }
details.more summary { cursor: pointer; font-weight: 600; color: var(--brand); }

/* tables */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; }
th, td { padding: .5rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f0f3f7; font-size: .8rem; text-transform: uppercase; letter-spacing: .02em; color: #4b5563; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tr.cancelled td { color: var(--muted); text-decoration: line-through; }
tfoot td { font-weight: 700; background: #f7f9fb; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }
.money-big { font-size: 1.25rem; font-weight: 700; }
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 12px; }
.toolbar form { display: flex; gap: .5rem; flex: 1; min-width: 220px; }
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; }
.tabs a { padding: .35rem .75rem; border-radius: 999px; border: 1px solid var(--line); background: #fff; }
.tabs a.on { background: var(--brand); color: #fff; border-color: var(--brand); }

/* badges */
.badge { display: inline-block; font-size: .78rem; font-weight: 600; padding: .1rem .5rem; border-radius: 999px;
  border: 1px solid transparent; white-space: nowrap; }
.st-PENDING { background: var(--pending); border-color: var(--pending-b); color: #7a4a00; }
.st-CONFIRMED { background: var(--confirmed); border-color: var(--confirmed-b); color: #163e78; }
.st-DONE { background: var(--done); border-color: var(--done-b); color: #4b2d8c; }
.st-CANCELLED { background: #f3f4f6; border-color: #cfd3da; color: #6b7280; }
.st-OPEN { background: var(--open); border-color: var(--open-b); color: #0b5b30; }
.st-CLOSED { background: var(--closed); border-color: #9aa1ab; color: #374151; }
.st-UNSET { background: var(--unset); border-color: #d6dae0; color: #6b7280; }

/* calendar */
.cal-head { display: flex; align-items: center; gap: .5rem; margin-bottom: 10px; }
.cal-head h1 { margin: 0; flex: 1; text-align: center; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal .wd { text-align: center; font-size: .75rem; font-weight: 700; color: var(--muted); padding: 2px 0; }
.day { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 3px; min-height: 86px;
  display: flex; flex-direction: column; gap: 3px; }
.day.out { opacity: .45; }
.day.today { border: 2px solid var(--brand); }
.day .num { font-weight: 700; font-size: .85rem; padding-left: 2px; }
.slot { display: block; border-radius: 6px; padding: 2px 4px; font-size: .72rem; line-height: 1.2; border: 1px solid transparent;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: inherit; }
.slot:hover { text-decoration: none; filter: brightness(.96); }
.slot .p { font-weight: 700; }
.slot.UNSET { background: var(--unset); color: #8b929c; }
.slot.OPEN { background: var(--open); border-color: var(--open-b); color: #0b5b30; }
.slot.CLOSED { background: repeating-linear-gradient(45deg, #e6e8ec, #e6e8ec 4px, #d5d9df 4px, #d5d9df 8px); color: #374151; }
.slot.b-PENDING { background: var(--pending); border-color: var(--pending-b); color: #6b4200; }
.slot.b-CONFIRMED { background: var(--confirmed); border-color: var(--confirmed-b); color: #163e78; }
.slot.b-DONE { background: var(--done); border-color: var(--done-b); color: #4b2d8c; }
.slot.past { opacity: .75; }
.slot .nm { display: none; }
.hist { font-size: .7rem; color: #4b2d8c; background: #f5f1fc; border-radius: 6px; padding: 1px 4px;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis; display: block; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem; margin: 10px 0; font-size: .8rem; }
@media (min-width: 760px) {
  .day { min-height: 118px; padding: 5px; }
  .slot { font-size: .8rem; padding: 3px 6px; }
  .slot .nm { display: inline; }
  .cal { gap: 6px; }
}
@media (max-width: 420px) { .slot .p { font-size: .68rem; } main { padding: 12px; } }

/* login */
.login { max-width: 380px; margin: 8vh auto; }
.login .brand-big { text-align: center; color: var(--brand); font-weight: 800; font-size: 1.6rem; letter-spacing: .06em; margin-bottom: 4px; }

@media print { .top, .actions, .toolbar, form { display: none !important; } body { background: #fff; } }
.center { text-align: center; }
.mt0 { margin-top: 0; }
.w100 { width: 100%; }
.inline { display: inline; }
.stack > * + * { margin-top: 12px; }
input[type=checkbox] { width: auto; min-height: auto; margin-right: .4rem; }
@media (max-width: 700px) {
  .top-in { flex-wrap: wrap; row-gap: .35rem; padding: .45rem 12px; }
  .brand { flex: 1; }
  .nav { order: 3; flex: 0 0 100%; }
  .nav a { padding: .35rem .55rem; }
  .who a { max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .hide-sm { display: none; }
}
.hidden { display: none; }

/* ---- v3: ikonkalar, pastki menyu, telefon uchun ixcham ko'rinish ---- */
.ic { flex: none; vertical-align: middle; }
.who a { display: inline-flex; align-items: center; gap: .3rem; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; min-height: 38px;
  padding: 0; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--brand); cursor: pointer; }
.icon-btn:hover { background: #eef4fb; text-decoration: none; }
.icon-btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.tabbar { display: none; }
.mob-only { display: none; }

@media (max-width: 700px) {
  body { font-size: 14px; }
  main { padding: 10px 10px calc(74px + env(safe-area-inset-bottom)); }
  .top-in { flex-wrap: nowrap; padding: .4rem 12px; }
  .top .nav, .who-name, .who-out { display: none; }
  .brand { flex: 1; }
  h1 { font-size: 1.1rem; margin-bottom: .5rem; }
  h2 { font-size: .95rem; margin: .8rem 0 .4rem; }
  .card { padding: 12px; margin-bottom: 10px; border-radius: 12px; }
  .grid2 { gap: 10px; }
  .fields { gap: 8px; }
  label { font-size: .78rem; margin-bottom: .15rem; color: #4b5563; }
  input, select, textarea { min-height: 38px; padding: .35rem .55rem; font-size: 16px; border-radius: 9px; }
  textarea { min-height: 56px; }
  .btn { min-height: 38px; padding: .35rem .8rem; font-size: .9rem; border-radius: 9px; }
  .btn.small { min-height: 32px; padding: .25rem .6rem; font-size: .82rem; }
  .actions { margin-top: 8px; gap: .4rem; }
  .hint, .crumb, .desk-only, .legend .note { display: none !important; }
  .mob-only { display: block; }
  .alert { padding: .5rem .7rem; margin-bottom: 10px; font-size: .88rem; }
  .kv { gap: .2rem .7rem; font-size: .88rem; }
  .money-big { font-size: 1.05rem; }
  th, td { padding: .38rem .45rem; font-size: .84rem; }
  th { font-size: .7rem; }
  .toolbar { gap: .35rem; margin-bottom: 8px; flex-wrap: nowrap; }
  .toolbar form { min-width: 0; gap: .35rem; }
  .toolbar input { min-width: 0; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-bottom: 8px; }
  .tabs a { padding: .25rem .6rem; font-size: .8rem; white-space: nowrap; }
  .badge { font-size: .7rem; padding: .05rem .4rem; }
  .legend { gap: .25rem; margin: 8px 0; }
  .cal-head { margin-bottom: 6px; }
  .cal-head h1 { font-size: 1.05rem; }
  .cal { gap: 3px; }
  .cal .wd { font-size: .68rem; }
  .day { min-height: 62px; padding: 2px; gap: 2px; border-radius: 7px; }
  .day .num { font-size: .72rem; }
  .slot { font-size: .62rem; padding: 1px 3px; border-radius: 5px; }
  .hist { font-size: .6rem; }
  details.more { margin-top: 10px; padding-top: 8px; }

  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: #fff;
    border-top: 1px solid var(--line); padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    box-shadow: 0 -2px 10px rgba(16, 24, 40, .06); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
    color: #6b7280; font-size: .62rem; padding: 3px 0; border-radius: 10px; min-width: 0; }
  .tabbar a span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .tabbar a.on { color: var(--brand); font-weight: 700; }
  .tabbar a:hover { text-decoration: none; }
  .tabbar a.add { flex: 0 0 48px; height: 44px; margin: 0 4px; background: var(--brand); color: #fff; border-radius: 14px; align-self: center; }
  .tabbar a.add.on { background: var(--brand-2); color: #fff; }
}
/* Telegram ichida yuqori panel yo'q; kompyuterdagi Telegram oynasi ham tor bo'ladi */
body.tg .top { display: none; }
@media (max-width: 700px) {
  .fields { grid-template-columns: 1fr 1fr; }
  .fields .full { grid-column: 1 / -1; }
  .fields > div { min-width: 0; }
}
