:root {
  --bg: #f3f6fc; --card: #ffffff; --soft: #eef2f9; --text: #0f172a; --muted: #64748b; --line: #e3e8f1;
  --accent: #2563eb; --accent-soft: #e6eeff; --accent-text: #ffffff;
  --danger: #e11d48; --danger-soft: #ffe4ea; --warn: #c2620a; --warn-soft: #fff1dc;
  --ok: #15803d; --ok-soft: #dcfce7;
  --shadow: 0 1px 2px rgb(15 23 42 / .04), 0 4px 16px rgb(15 23 42 / .05);
  --c-l: 93%; --c-s: 85%; --cf-l: 36%;      /* fan ranglari: --h (hue) element ustida beriladi */
  --radius: 18px;
}
:root[data-theme="dark"] {
  --bg: #0d1219; --card: #171f2b; --soft: #1f2937; --text: #e8edf5; --muted: #8b97a8; --line: #263244;
  --accent: #4f8cff; --accent-soft: #1b2a46; --accent-text: #ffffff;
  --danger: #fb7185; --danger-soft: #3b1720; --warn: #fbbf24; --warn-soft: #3a2a0c;
  --ok: #4ade80; --ok-soft: #12301f;
  --shadow: none;
  --c-l: 22%; --c-s: 38%; --cf-l: 76%;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { background: var(--bg); }
body { margin: 0; color: var(--text); font: 15px/1.4 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
       padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
button { font: inherit; color: inherit; cursor: pointer; }
.ic { display: block; flex: none; }

/* --- sarlavha --- */
#top { padding: 18px 16px 6px; }
#top h1 { margin: 0; font-size: 24px; letter-spacing: -.02em; }
#top .sub { color: var(--muted); font-size: 14px; margin-bottom: 2px; }
main { padding: 4px 16px 0; }

/* --- pastki tab-bar --- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 8; display: flex; align-items: center;
          background: var(--card); border-top: 1px solid var(--line);
          padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
.tabbar button { flex: 1; border: 0; background: none; color: var(--muted); display: flex; flex-direction: column;
                 align-items: center; gap: 2px; font-size: 11px; font-weight: 600; padding: 4px 0; }
.tabbar button.on { color: var(--accent); }
.tabbar .plus { flex: none; width: 52px; height: 52px; margin: -22px 8px 0; border-radius: 50%; background: var(--accent);
                color: var(--accent-text); justify-content: center; box-shadow: 0 6px 18px rgb(37 99 235 / .35); }

/* --- kartalar --- */
.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow); }
.card-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.card-h h2 { margin: 0; font-size: 16px; }
.link { border: 0; background: none; color: var(--accent); font-weight: 600; font-size: 14px; padding: 0; }
.section { margin: 18px 4px 8px; font-size: 13px; font-weight: 700; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.section .n { background: var(--soft); border-radius: 10px; padding: 0 7px; font-size: 12px; }
.empty { color: var(--muted); padding: 6px 0; margin: 0; }
.muted { color: var(--muted); }

/* --- statistika --- */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat { background: var(--card); border-radius: 16px; padding: 12px; box-shadow: var(--shadow); min-width: 0; }
.stat .top { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 12px; font-weight: 600; }
.stat .badge-ic { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.stat .v { font-size: 26px; font-weight: 750; letter-spacing: -.02em; margin-top: 6px; }
.stat .v small { font-size: 13px; font-weight: 600; color: var(--muted); margin-left: 3px; }
.stat .s { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .s.bad { color: var(--danger); font-weight: 600; }
.bar { height: 5px; border-radius: 3px; background: var(--soft); margin-top: 8px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

/* --- "hozir / keyingi" kartasi --- */
.focus { background: linear-gradient(135deg, #2563eb, #4f46e5); color: #fff; border-radius: 20px; padding: 16px;
         margin-bottom: 12px; box-shadow: 0 8px 24px rgb(37 99 235 / .25); }
.focus .lbl { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; opacity: .8; }
.focus .t { font-size: 20px; font-weight: 750; margin-top: 4px; }
.focus .m { display: flex; gap: 12px; flex-wrap: wrap; font-size: 14px; opacity: .9; margin-top: 6px; }
.focus .m span { display: flex; align-items: center; gap: 4px; }
.focus .bar { background: rgb(255 255 255 / .25); } .focus .bar i { background: #fff; }

/* --- vaqt chizig'i (kun) --- */
.timeline { position: relative; }
.tl { display: flex; gap: 10px; position: relative; padding-bottom: 10px; }
.tl:last-child { padding-bottom: 0; }
.tl .rail { width: 12px; flex: none; display: flex; flex-direction: column; align-items: center; }
.tl .dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--line); background: var(--card); margin-top: 16px; }
.tl .rail::after { content: ""; flex: 1; width: 2px; background: var(--line); margin-top: 2px; }
.tl:last-child .rail::after { display: none; }
.tl.now .dot { border-color: var(--accent); background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.tl.past { opacity: .55; }
.tl .item { flex: 1; }

.item { --h: 220; display: flex; gap: 12px; align-items: flex-start; border-radius: 14px; padding: 10px 12px;
        background: hsl(var(--h) var(--c-s) var(--c-l)); border-left: 4px solid hsl(var(--h) 70% 55%); min-width: 0; }
.item.work { background: var(--soft); border-left-color: var(--muted); }
.item.overlap { box-shadow: inset 0 0 0 2px var(--danger); }
.item .tm { width: 44px; flex: none; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 14px; }
.item .tm small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }
.item .bd { flex: 1; min-width: 0; }
.item .tt { font-weight: 700; color: hsl(var(--h) 60% var(--cf-l)); }
.item.work .tt { color: var(--text); }
.item .tt span { font-weight: 500; color: var(--text); }
.item .mt { display: flex; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: 13px; margin-top: 2px; }
.item .mt span { display: flex; align-items: center; gap: 3px; }
.warn { color: var(--danger); font-size: 12px; font-weight: 700; margin-top: 3px; display: flex; gap: 4px; align-items: center; }
.due { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-radius: 14px; background: var(--warn-soft);
       font-size: 14px; margin-top: 8px; }
.due b { color: var(--warn); }
.pause { padding: 12px; border-radius: 14px; background: var(--ok-soft); color: var(--ok); font-weight: 600; }

/* --- jadval: hafta navigatsiyasi --- */
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.seg { display: flex; background: var(--soft); border-radius: 12px; padding: 3px; }
.seg button { border: 0; background: none; padding: 7px 14px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--muted); }
.seg.full button { flex: 1; padding: 7px 2px; font-size: 13px; }
.seg button.on { background: var(--card); color: var(--accent); box-shadow: var(--shadow); }
.weeknav { margin-left: auto; display: flex; align-items: center; gap: 2px; font-weight: 600; font-size: 14px; }
.weeknav button { border: 0; background: none; color: var(--accent); width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; }
.todaybtn { border: 0; background: var(--accent-soft); color: var(--accent); border-radius: 10px; padding: 6px 10px; font-weight: 600; font-size: 13px; }
.strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 12px; }
.strip button { border: 0; background: var(--card); border-radius: 14px; padding: 8px 0 6px; display: flex; flex-direction: column;
                align-items: center; gap: 1px; box-shadow: var(--shadow); }
.strip .d { font-size: 11px; color: var(--muted); font-weight: 600; }
.strip .n { font-size: 17px; font-weight: 700; }
.strip .dots { display: flex; gap: 2px; height: 5px; }
.strip .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.strip .dots i.w { background: var(--muted); } .strip .dots i.p { background: hsl(95 55% 42%); } .strip .dots i.x { background: var(--danger); }
.strip button.today .n { color: var(--accent); }
.strip button.sel { background: var(--accent); } .strip button.sel * { color: var(--accent-text) !important; }
.strip button.sel .dots i { background: var(--accent-text); }

/* --- jadval: hafta to'ri --- */
.wgrid { background: var(--card); border-radius: var(--radius); padding: 10px 6px 10px 0; box-shadow: var(--shadow); }
.wg-head, .wg-body { display: grid; grid-template-columns: 30px repeat(7, 1fr); }
.wg-head div { text-align: center; font-size: 11px; color: var(--muted); font-weight: 600; padding-bottom: 6px; }
.wg-head div b { display: block; font-size: 14px; color: var(--text); }
.wg-head div.today b { color: var(--accent); }
.wg-hours { position: relative; }
.wg-hours span { position: absolute; right: 4px; transform: translateY(-50%); font-size: 10px; color: var(--muted); }
.wg-col { position: relative; border-left: 1px solid var(--line);
          background-image: linear-gradient(var(--line) 1px, transparent 1px); background-size: 100% var(--hp); }
.wg-col.today { background-color: color-mix(in srgb, var(--accent) 5%, transparent); }
.wg-col.pause { background-color: var(--ok-soft); }
.blk { --h: 220; position: absolute; left: 1px; right: 1px; border-radius: 7px; padding: 3px 3px; overflow: hidden;
       background: hsl(var(--h) var(--c-s) var(--c-l)); border-left: 3px solid hsl(var(--h) 70% 55%);
       font-size: 10px; line-height: 1.15; color: hsl(var(--h) 60% var(--cf-l)); font-weight: 700; }
.blk, .blk small { white-space: nowrap; text-overflow: ellipsis; }
.blk small { display: block; font-weight: 500; color: var(--muted); }
.blk.work { background: var(--soft); border-left-color: var(--muted); color: var(--text); }
.blk.overlap { outline: 2px solid var(--danger); outline-offset: -2px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin: 10px 4px 0; font-size: 12px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 5px; }
.legend i { width: 9px; height: 9px; border-radius: 3px; background: hsl(var(--h) 70% 55%); }

/* --- vazifalar --- */
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 20px; padding: 6px 12px;
        font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chip i { width: 8px; height: 8px; border-radius: 50%; background: hsl(var(--h) 70% 55%); }
.trow { display: flex; gap: 12px; align-items: center; padding: 11px 0; border-top: 1px solid var(--line); }
.trow:first-child { border-top: 0; padding-top: 2px; } .trow:last-child { padding-bottom: 2px; }
.check { width: 24px; height: 24px; flex: none; border-radius: 8px; border: 2px solid var(--line); display: grid; place-items: center; background: none; padding: 0; }
.trow.done .check { background: var(--ok); border-color: var(--ok); color: #fff; }
.trow .bd { flex: 1; min-width: 0; }
.trow .tt { font-weight: 600; }
.trow.done .tt { text-decoration: line-through; color: var(--muted); }
.trow .cs { --h: 220; display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); margin-top: 2px; }
.trow .cs i { width: 7px; height: 7px; border-radius: 50%; background: hsl(var(--h) 70% 55%); }
.pill { flex: none; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 20px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.pill.over, .pill.today { background: var(--danger-soft); color: var(--danger); }
.pill.soon { background: var(--warn-soft); color: var(--warn); }
.pill.week { background: var(--accent-soft); color: var(--accent); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }

/* --- tezkor amallar (vazifa oynasi) --- */
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 4px 0 8px; }
.quick button { border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--muted); }
.quick .c { width: 50px; height: 50px; border-radius: 50%; border: 2px solid currentColor; display: grid; place-items: center; }
.quick .q1 .c { color: #16a34a; } .quick .q2 .c { color: #eab308; } .quick .q3 .c { color: var(--accent); } .quick .q4 .c { color: var(--ok); }

/* --- ish: kunlar --- */
.dayrow { display: grid; grid-template-columns: auto 1fr auto; gap: 8px 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.dayrow:first-child { border-top: 0; padding-top: 0; }
.switch { width: 44px; height: 26px; border-radius: 13px; border: 0; background: var(--line); position: relative; padding: 0; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff;
                 box-shadow: 0 1px 3px rgb(0 0 0 / .25); transition: transform .15s; }
.dayrow.on .switch { background: var(--accent); } .dayrow.on .switch::after { transform: translateX(18px); }
.dn { font-weight: 600; } .dn small { color: var(--muted); font-weight: 500; margin-left: 6px; }
.dayrow.on .dn small { display: none; }
.addspan { border: 0; background: none; color: var(--accent); width: 30px; height: 30px; display: grid; place-items: center; }
.spans { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 6px; }
.spans:empty { display: none; }
.span { display: flex; align-items: center; gap: 6px; background: var(--accent-soft); border-radius: 12px; padding: 4px 6px 4px 10px; }
.span input { flex: 1; min-width: 0; background: none; border: 0; color: var(--accent); font: inherit; font-weight: 700; padding: 6px 0; }
.span i { color: var(--muted); font-style: normal; }
.span .rm { border: 0; background: none; color: var(--muted); font-size: 16px; padding: 4px 6px; }
.bulk { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.bulk summary { color: var(--accent); font-weight: 600; font-size: 14px; cursor: pointer; }
.bulk .chips { margin-top: 10px; }
.hours { font-size: 30px; font-weight: 750; letter-spacing: -.02em; }

/* --- forma va oynalar --- */
.sheet-bg { position: fixed; inset: 0; background: rgb(0 0 0 / .4); z-index: 10; display: none; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 11; background: var(--card); border-radius: 22px 22px 0 0;
         padding: 10px 16px calc(16px + env(safe-area-inset-bottom)); max-height: 90vh; overflow: auto;
         transform: translateY(105%); transition: transform .22s; }
.sheet::before { content: ""; display: block; width: 38px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 12px; }
.sheet.open { transform: none; }
.sheet h3 { margin: 0 0 4px; font-size: 19px; }
.sheet .subt { color: var(--muted); font-size: 14px; margin-bottom: 12px; }
label { display: block; font-size: 13px; color: var(--muted); font-weight: 600; margin: 12px 0 5px; }
input, select { width: 100%; font: inherit; color: var(--text); background: var(--soft); border: 1px solid transparent; border-radius: 12px; padding: 11px 12px; }
input:focus, select:focus { outline: none; border-color: var(--accent); }
.pair { display: flex; gap: 10px; } .pair > * { flex: 1; min-width: 0; }
.btn { width: 100%; border: 0; border-radius: 14px; padding: 13px; font-weight: 700; margin-top: 14px; }
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.ghost { background: var(--soft); }
.btn.danger { background: none; color: var(--danger); margin-top: 6px; }
.btn[disabled] { opacity: .6; }
.tick { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 500; font-size: 14px; margin-top: 14px; }
.tick input { width: 20px; height: 20px; flex: none; accent-color: var(--accent); }
.note { font-size: 13px; color: var(--muted); margin-top: 8px; }
.choice { display: grid; gap: 10px; }
.opt { display: flex; gap: 12px; align-items: center; text-align: left; border: 0; background: var(--soft); border-radius: 16px; padding: 14px; }
.opt .c { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.opt b { display: block; } .opt small { color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: rgb(15 23 42 / .92);
         color: #fff; padding: 10px 14px; border-radius: 12px; font-size: 14px; z-index: 20; display: none; max-width: 90vw; }
