/* ============ Tokens ============ */
:root {
  color-scheme: light;
  --bg: #f3f6fa;
  --paper: #ffffff;
  --paper-2: #f8fafc;
  --ink: #17233a;
  --ink-2: #4f5c73;
  --ink-3: #8390a5;
  --line: #e2e7ef;
  --line-2: #d0d7e2;
  --focus: #3b62e0;

  /* Task sources */
  --pq: #5b4bd5;  --pq-soft: #eeecfc;  --pq-ink: #4334b8;
  --pa: #00978f;  --pa-soft: #e3f5f3;  --pa-ink: #007069;
  --vm: #c27c0e;  --vm-soft: #fbf1e1;  --vm-ink: #8f5a05;

  /* Statuses: progress stages are one blue ramp; outcomes use status colors */
  --st-new: #a3acbb;
  --st-collect: #86b6ef;
  --st-letter: #3987e5;
  --st-upload: #1c5cab;
  --st-resolved: #0ca30c;
  --st-returned: #d03b3b;
  --good-ink: #08700a;
  --warn: #e39b07;
  --warn-ink: #8a5b00;
  --warn-soft: #fff4dc;
  --crit-ink: #b42828;
  --crit-soft: #fdeaea;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 20px;
  --shadow-1: 0 1px 2px rgb(23 35 58 / 6%), 0 1px 1px rgb(23 35 58 / 4%);
  --shadow-2: 0 10px 30px -12px rgb(23 35 58 / 22%), 0 2px 6px rgb(23 35 58 / 6%);
  --shadow-3: 0 24px 60px -20px rgb(23 35 58 / 35%);

  --font: 'Golos Text', 'Segoe UI', system-ui, sans-serif;
  --display: 'Golos Text', 'Segoe UI', system-ui, sans-serif;
  --official: #1f3a6e;
  --official-soft: #edf1f8;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.5 var(--font);
  font-feature-settings: 'tnum' 1;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2.5px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}

/* ============ Shell ============ */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 24px;
  padding: 0 28px; height: 64px;
  background: rgb(255 255 255 / 86%);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--official);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M9 16.5l4.5 4.5L23 11.5' stroke='white' stroke-width='3' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-size: 100%;
}
.brand-name { font: 700 16px/1 var(--display); }

.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  padding: 8px 14px; border-radius: 999px; text-decoration: none;
  color: var(--ink-2); font-weight: 500; transition: background .2s, color .2s;
}
.nav a:hover { background: var(--paper-2); color: var(--ink); }
.nav a[aria-current='page'] { background: var(--ink); color: #fff; }

.usermenu { position: relative; }
.usermenu > button {
  display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 12px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--paper);
}
.usermenu .who { text-align: right; line-height: 1.15; }
.usermenu .who small { display: block; color: var(--ink-3); font-size: 12px; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 210px; padding: 6px;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-2);
  animation: pop .18s var(--ease);
}
.menu button { display: block; width: 100%; text-align: left; padding: 9px 12px; border: 0; background: none; border-radius: 8px; }
.menu button:hover { background: var(--paper-2); }

main { padding: 28px; max-width: 1480px; margin: 0 auto; }

/* ============ Generic controls ============ */
.btn {
  text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--paper); font-weight: 500;
  transition: background .15s, border-color .15s, transform .1s, box-shadow .15s;
}
.btn:hover { background: var(--paper-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: #24345a; }
.btn.danger { color: var(--crit-ink); border-color: #f2c4c4; }
.btn.danger:hover { background: var(--crit-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgb(23 35 58 / 6%); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 14px; border-radius: 8px; }
.icon-btn {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  border: 0; background: transparent; color: var(--ink-2);
}
.icon-btn:hover { background: rgb(23 35 58 / 7%); color: var(--ink); }
.icon { width: 18px; height: 18px; flex: none; }

.input, .select, .textarea {
  width: 100%; height: 42px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--paper);
  transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; padding: 10px 14px; resize: vertical; min-height: 80px; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 4px rgb(59 98 224 / 14%); }
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field small { color: var(--ink-3); font-size: 12.5px; }

.segmented {
  display: inline-flex; padding: 4px; gap: 2px; border-radius: 12px;
  background: rgb(23 35 58 / 6%); position: relative;
}
.segmented button {
  position: relative; z-index: 1; border: 0; background: transparent;
  padding: 7px 16px; border-radius: 9px; font-weight: 500; color: var(--ink-2);
  transition: color .2s;
}
.segmented button[aria-pressed='true'] { color: var(--ink); background: var(--paper); box-shadow: var(--shadow-1); }

.search { position: relative; }
.search .icon { position: absolute; left: 12px; top: 50%; translate: 0 -50%; color: var(--ink-3); }
.search .input { padding-left: 38px; }

.avatar {
  --hue: 230;
  display: inline-grid; place-items: center; flex: none;
  width: 30px; height: 30px; border-radius: 50%;
  background: hsl(var(--hue) 70% 93%); color: hsl(var(--hue) 45% 32%);
  font-size: 12px; font-weight: 600; letter-spacing: .02em;
  border: 2px solid var(--paper);
}
.avatar.lg { width: 38px; height: 38px; font-size: 14px; }
.avatars { display: flex; }
.avatars .avatar + .avatar { margin-left: -9px; }
.avatars .more { background: var(--paper-2); color: var(--ink-2); }

.empty {
  display: grid; place-items: center; gap: 10px; text-align: center;
  padding: 56px 20px; color: var(--ink-2);
}
.empty h3 { margin: 0; color: var(--ink); font-size: 17px; }
.empty p { margin: 0; max-width: 46ch; }

.panel {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.panel-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px 0; }
.panel-h h2 { margin: 0; font-size: 16px; font-weight: 600; }
.panel-h p { margin: 2px 0 0; color: var(--ink-3); font-size: 13px; }
.panel-b { padding: 16px 22px 22px; }

.page-h { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 24px; }
.page-h h1 { margin: 0; font: 700 clamp(22px, 2.4vw, 30px)/1.15 var(--display); letter-spacing: -.01em; }
.page-h p { margin: 6px 0 0; color: var(--ink-2); }

/* Status pill */
.status {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  padding: 4px 10px 4px 8px; border-radius: 999px; font-size: 13px; font-weight: 500;
  background: var(--paper-2); border: 1px solid var(--line);
}
.status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.status.new { --c: var(--st-new); }
.status.collect { --c: var(--st-collect); }
.status.letter { --c: var(--st-letter); }
.status.upload { --c: var(--st-upload); }
.status.resolved { --c: var(--st-resolved); background: #e8f6e8; border-color: #c4e7c4; color: var(--good-ink); }
.status.returned { --c: var(--st-returned); background: var(--crit-soft); border-color: #f4c9c9; color: var(--crit-ink); }

.due { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-size: 13px; color: var(--ink-2); }
.due b { font-weight: 600; color: var(--ink); }
.due.soon { color: var(--warn-ink); }
.due.soon b { color: var(--warn-ink); }
.due.late { color: var(--crit-ink); }
.due.late b { color: var(--crit-ink); }

.tag {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 6px;
  font-size: 12px; font-weight: 500; background: var(--paper-2); color: var(--ink-2); border: 1px solid var(--line);
}
.src { --c: var(--official); --soft: var(--official-soft); --cink: var(--official); }
.src-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px 2px 4px; border-radius: 6px;
  background: var(--soft); color: var(--cink); font-size: 12px; font-weight: 600;
}
.src-chip i { font: 700 10px/1 var(--display); background: var(--c); color: #fff; padding: 4px 4px; border-radius: 4px; font-style: normal; }

/* ============ Home: source cards ============ */
.home-h { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 26px; }
.home-h h1 { margin: 0; font: 700 clamp(24px, 3vw, 34px)/1.12 var(--display); letter-spacing: -.015em; }
.home-h p { margin: 8px 0 0; color: var(--ink-2); max-width: 60ch; }

.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }

.src-card {
  position: relative; overflow: hidden; text-align: left; isolation: isolate;
  display: flex; flex-direction: column; gap: 18px;
  min-height: 250px; padding: 26px 26px 22px;
  border: 1px solid var(--line); border-radius: 26px; background: var(--paper);
  box-shadow: var(--shadow-1);
  transition: box-shadow .3s var(--ease), border-color .3s, transform .3s var(--ease);
}
.src-card:hover { box-shadow: var(--shadow-2); border-color: var(--line-2); transform: translateY(-2px); }
.src-card::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--official); }
.mono {
  display: inline-grid; place-items: center; flex: none;
  width: 48px; height: 48px; border-radius: 12px;
  background: var(--official-soft); color: var(--official);
  border: 1px solid #d6deeb;
  font: 700 16px/1 var(--display); letter-spacing: .02em;
}
.card-head { display: flex; align-items: center; gap: 14px; }
.src-card .title { font-size: 17px; font-weight: 600; line-height: 1.25; }
.src-card .subtitle { color: var(--ink-3); font-size: 13.5px; margin-top: 4px; }
.src-card .count { margin-top: auto; display: flex; align-items: baseline; gap: 10px; }
.src-card .count b { font: 600 40px/1 var(--display); letter-spacing: -.01em; }
.src-card .count span { color: var(--ink-2); }
.src-card .flags { display: flex; gap: 8px; flex-wrap: wrap; min-height: 26px; }
.flag { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 500; }
.flag.late { background: var(--crit-soft); color: var(--crit-ink); }
.flag.soon { background: var(--warn-soft); color: var(--warn-ink); }
.flag.done { background: #e8f6e8; color: var(--good-ink); }
.flag .icon { width: 14px; height: 14px; }

/* Segmented status bar: 2px surface gaps between segments */
.stackbar { display: flex; gap: 2px; height: 10px; border-radius: 999px; overflow: hidden; background: var(--paper-2); }
.stackbar > i { display: block; min-width: 4px; background: var(--c); transition: flex-grow .6s var(--ease); }
.stackbar.lg { height: 14px; }
.stackbar.empty::after { content: ''; flex: 1; background: var(--line); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend span::before { content: ''; width: 9px; height: 9px; border-radius: 3px; background: var(--c); }

.c-new { --c: var(--st-new); } .c-collect { --c: var(--st-collect); } .c-letter { --c: var(--st-letter); }
.c-upload { --c: var(--st-upload); } .c-resolved { --c: var(--st-resolved); } .c-returned { --c: var(--st-returned); }
.c-pq { --c: var(--pq); } .c-pa { --c: var(--pa); } .c-vm { --c: var(--vm); }

/* ============ Split view ============ */
.split { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 24px; align-items: start; }
.rail { position: sticky; top: 88px; display: grid; gap: 14px; }
.rail .src-card { min-height: 0; padding: 22px; gap: 14px; transform: none; cursor: default; }
.rail .src-card .count b { font-size: 34px; }
.rail .back { justify-self: start; }

.st-list { display: grid; gap: 2px; margin: 4px -8px 0; }
.st-list button {
  display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 10px;
  padding: 7px 8px; border: 0; background: transparent; border-radius: 8px; text-align: left; color: var(--ink-2);
}
.st-list button::before { content: ''; width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.st-list button b { color: var(--ink); font-weight: 600; }
.st-list button:hover { background: var(--paper-2); }
.st-list button[aria-pressed='true'] { background: var(--soft); color: var(--ink); }

.mini-src {
  text-decoration: none; color: inherit;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px;
  padding: 14px 16px; border-radius: 18px; border: 1px solid var(--line); background: var(--paper); text-align: left;
  transition: border-color .2s, box-shadow .2s;
}
.mini-src:hover { border-color: color-mix(in srgb, var(--c) 40%, var(--line)); box-shadow: var(--shadow-2); }
.mini-src .mono { width: 38px; height: 38px; font-size: 13px; border-radius: 10px; }
.mini-src .t { font-weight: 500; font-size: 14px; line-height: 1.25; }
.mini-src .t small { display: block; color: var(--ink-3); font-size: 12.5px; }
.mini-src .n { font: 700 20px/1 var(--display); }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .search { flex: 1 1 260px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--paper); font-size: 13.5px; font-weight: 500; color: var(--ink-2);
}
.chip i { font-style: normal; color: var(--ink-3); font-weight: 600; }
.chip:hover { border-color: var(--ink-3); }
.chip[aria-pressed='true'] { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip[aria-pressed='true'] i { color: rgb(255 255 255 / 70%); }

/* Task rows */
.tasks { display: grid; gap: 10px; }
.task {
  position: relative; display: grid; grid-template-columns: 1fr auto; gap: 8px 22px;
  padding: 16px 18px 16px 22px; border-radius: 16px; background: var(--paper); border: 1px solid var(--line);
  cursor: pointer; text-align: left;
  transition: border-color .2s, box-shadow .2s, transform .2s var(--ease);
  animation: rowIn .45s var(--ease) both; animation-delay: calc(var(--i, 0) * 28ms);
}
.task::before { content: ''; position: absolute; left: 0; top: 14px; bottom: 14px; width: 4px; border-radius: 0 4px 4px 0; background: var(--c); }
.task:hover { border-color: var(--line-2); box-shadow: var(--shadow-2); }
.task.active { border-color: var(--focus); box-shadow: 0 0 0 3px rgb(59 98 224 / 15%); }
.task .head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); }
.task .head .ref { font-weight: 600; color: var(--ink); }
.task .text {
  grid-column: 1; margin: 0; color: var(--ink); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.task .side { grid-column: 2; grid-row: 1 / span 2; display: grid; justify-items: end; align-content: space-between; gap: 10px; }
.task .side .row { display: flex; align-items: center; gap: 12px; }
.task .side .msgs { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-3); font-size: 13px; }
.task .side .msgs.unread { color: var(--focus); font-weight: 600; }
.task .side .msgs.unread::after { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--focus); }
.task .pick { position: absolute; left: -32px; top: 18px; }
.tasks.picking { padding-left: 32px; }
.checkbox { width: 18px; height: 18px; accent-color: var(--ink); cursor: pointer; }

.bulkbar {
  position: fixed; left: 50%; bottom: 24px; translate: -50% 0; z-index: 40;
  display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 18px;
  background: var(--ink); color: #fff; border-radius: 16px; box-shadow: var(--shadow-3);
  animation: rise .3s var(--ease);
}
.bulkbar .btn { height: 36px; }
.bulkbar .btn.ghost { color: #fff; }
.bulkbar .btn.ghost:hover { background: rgb(255 255 255 / 12%); }

.list-meta { display: flex; justify-content: space-between; align-items: center; color: var(--ink-3); font-size: 13px; margin: 0 2px 10px; }

/* ============ Drawer (task panel) ============ */
.scrim {
  position: fixed; inset: 0; z-index: 50; background: rgb(23 35 58 / 28%);
  animation: fade .25s ease;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 51;
  width: min(680px, 100vw); display: flex; flex-direction: column;
  background: var(--paper); box-shadow: var(--shadow-3);
  animation: slideIn .38s var(--ease);
}
.drawer.closing { animation: slideOut .26s ease forwards; }
.scrim.closing { animation: fade .26s ease reverse forwards; }
.drawer-h { padding: 18px 22px 14px; border-bottom: 1px solid var(--line); }
.drawer-h .top { display: flex; align-items: center; gap: 10px; }
.drawer-h .top .sp { flex: 1; }
.drawer-h h2 { margin: 12px 0 2px; font-size: 19px; line-height: 1.3; }
.drawer-h .sub { color: var(--ink-2); font-size: 13.5px; }
.drawer-b { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.drawer-sec { padding: 18px 22px; border-bottom: 1px solid var(--line); }
.drawer-sec h3 { margin: 0 0 12px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.content-text { white-space: pre-wrap; line-height: 1.6; margin: 0; }
.content-text.clamped { max-height: 9.6em; overflow: hidden; mask-image: linear-gradient(#000 60%, transparent); }
.meta-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 20px; margin-top: 16px; }
.meta-grid div { min-width: 0; }
.meta-grid dt { color: var(--ink-3); font-size: 12.5px; }
.meta-grid dd { margin: 2px 0 0; font-weight: 500; white-space: pre-line; overflow-wrap: anywhere; }

/* Stepper */
.stepper { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.step {
  position: relative; display: grid; gap: 8px; padding: 12px 12px 12px; text-align: left;
  border-radius: 14px; border: 1px solid var(--line); background: var(--paper-2);
  transition: background .25s, border-color .25s, box-shadow .25s, transform .15s;
}
.step:not(:disabled):hover { border-color: var(--line-2); background: var(--paper); box-shadow: var(--shadow-1); }
.step:disabled { cursor: default; }
.step .n {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  font: 700 12px/1 var(--display); background: var(--paper); border: 1.5px solid var(--line-2); color: var(--ink-3);
  transition: all .3s var(--ease);
}
.step .l { font-size: 13px; font-weight: 600; line-height: 1.25; }
.step.done .n { background: var(--c); border-color: var(--c); color: #fff; }
.step.current { background: var(--paper); border-color: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 20%, transparent); }
.step.current .n { background: var(--c); border-color: var(--c); color: #fff; animation: pulse 1.8s ease-out 1; }
.final { display: grid; gap: 6px; }
.final .step { grid-template-columns: auto 1fr; align-items: center; padding: 8px 10px; }
.final .step .n { width: 24px; height: 24px; }
.final .step .n .icon { width: 14px; height: 14px; }
.step.done .n .icon { width: 14px; height: 14px; }
.step-note { margin: 10px 0 0; font-size: 13px; color: var(--ink-3); }
.confirm-box {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; padding: 12px 14px;
  border-radius: 12px; background: #e8f6e8; border: 1px solid #c4e7c4; animation: pop .2s var(--ease);
}
.confirm-box p { margin: 0; flex: 1 1 200px; font-size: 14px; color: var(--good-ink); }

.people { display: flex; flex-wrap: wrap; gap: 8px; }
.person { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border-radius: 999px; background: var(--paper-2); border: 1px solid var(--line); font-size: 14px; }
.person .avatar { border: 0; }

/* Chat */
.chat { padding: 18px 22px 8px; display: grid; gap: 14px; }
.msg { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 10px; }
.msg .avatar { width: 34px; height: 34px; border: 0; }
.msg .meta { display: flex; gap: 8px; align-items: baseline; font-size: 13px; }
.msg .meta b { font-weight: 600; }
.msg .meta time { color: var(--ink-3); font-size: 12px; }
.msg .bubble {
  margin-top: 4px; padding: 10px 14px; border-radius: 4px 14px 14px 14px;
  background: var(--paper-2); border: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5;
}
.msg.me { grid-template-columns: minmax(0, 1fr) 34px; }
.msg.me .avatar { grid-column: 2; grid-row: 1; }
.msg.me > div { grid-column: 1; grid-row: 1; display: grid; justify-items: end; }
.msg.me .meta { flex-direction: row-reverse; }
.msg.me .bubble { background: #eaf0ff; border-color: #d3defc; border-radius: 14px 4px 14px 14px; }
.event { display: flex; align-items: center; gap: 10px; color: var(--ink-3); font-size: 12.5px; }
.event::before, .event::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.event span { text-align: center; max-width: 80%; }
.event b { color: var(--ink-2); font-weight: 600; }
.composer { display: flex; gap: 10px; align-items: flex-end; padding: 14px 22px 18px; border-top: 1px solid var(--line); background: var(--paper); }
.composer .textarea { min-height: 44px; max-height: 160px; resize: none; padding: 11px 14px; }
.composer .btn { height: 44px; width: 44px; padding: 0; flex: none; }

/* Picker */
.picker { display: grid; gap: 8px; }
.picker-list { max-height: 280px; overflow: auto; display: grid; gap: 2px; border: 1px solid var(--line); border-radius: 12px; padding: 6px; }
.picker-list label { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 8px; cursor: pointer; }
.picker-list label:hover { background: var(--paper-2); }

/* ============ Modal ============ */
.modal-wrap { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgb(23 35 58 / 30%); animation: fade .2s ease; }
.modal { width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--paper); border-radius: var(--r-lg); box-shadow: var(--shadow-3); animation: pop .25s var(--ease); }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px 6px; }
.modal-h h2 { margin: 0; font-size: 18px; }
.modal-b { display: grid; gap: 14px; padding: 12px 22px; }
.modal-f { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 22px 20px; }
.form-error { color: var(--crit-ink); background: var(--crit-soft); padding: 10px 12px; border-radius: 10px; font-size: 14px; }

/* ============ Dashboard ============ */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.kpi { padding: 18px 20px; display: grid; gap: 4px; }
.kpi .v { font: 700 34px/1.05 var(--display); letter-spacing: -.02em; }
.kpi .k { color: var(--ink-2); font-weight: 500; }
.kpi .s { color: var(--ink-3); font-size: 13px; }
.kpi .ico { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; margin-bottom: 8px; }
.kpi .ico.late { background: var(--crit-soft); color: var(--crit-ink); }
.kpi .ico.soon { background: var(--warn-soft); color: var(--warn-ink); }
.kpi .ico.done { background: #e8f6e8; color: var(--good-ink); }
.kpi .ico.act { background: #eaf0ff; color: #2c4fbf; }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 18px; }
.dash-grid .wide { grid-column: 1 / -1; }

.bars { display: grid; gap: 16px; }
.bar-row { display: grid; grid-template-columns: 170px minmax(0, 1fr) 64px; align-items: center; gap: 14px; }
.bar-row .lbl { display: flex; align-items: center; gap: 10px; font-weight: 500; font-size: 14px; line-height: 1.2; }
.bar-row .lbl .mono { width: 34px; height: 34px; font-size: 12px; border-radius: 9px; }
.bar-row .tot { text-align: right; font-weight: 600; }
.bar-row .tot small { display: block; color: var(--ink-3); font-weight: 400; font-size: 12px; }
.bar-row .stackbar { height: 26px; border-radius: 6px; cursor: default; }
.bar-row .stackbar > i { position: relative; }
.bar-row .stackbar > i:first-child { border-radius: 6px 0 0 6px; }
.bar-row .stackbar > i:last-child { border-radius: 0 6px 6px 0; }
.bar-row .stackbar > i:hover { filter: brightness(1.08) saturate(1.1); }

.tip {
  position: fixed; z-index: 90; pointer-events: none; padding: 9px 12px; border-radius: 10px;
  background: var(--ink); color: #fff; font-size: 13px; line-height: 1.4; box-shadow: var(--shadow-2); max-width: 260px;
}
.tip b { font-weight: 600; }
.tip .sw { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; background: var(--c); }

.colchart { position: relative; }
.colchart svg { display: block; width: 100%; height: auto; overflow: visible; }
.colchart .grid line { stroke: var(--line); stroke-width: 1; }
.colchart .axis text { fill: var(--ink-3); font-size: 11.5px; }
.colchart .val { fill: var(--ink-2); font-size: 11.5px; font-weight: 600; }
.colchart rect.hit { fill: transparent; }
.colchart g.col:hover rect.seg { filter: brightness(1.08); }

.ptable { width: 100%; border-collapse: collapse; }
.ptable th { text-align: left; font-size: 12.5px; font-weight: 500; color: var(--ink-3); padding: 0 10px 10px; border-bottom: 1px solid var(--line); }
.ptable td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.ptable tr:last-child td { border-bottom: 0; }
.ptable .num { text-align: right; white-space: nowrap; }
.ptable .who { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.ptable .stackbar { height: 10px; min-width: 160px; }
.ptable .late { color: var(--crit-ink); font-weight: 600; }
.pct { font-weight: 600; }

.feed { display: grid; gap: 2px; }
.feed button { display: grid; grid-template-columns: 30px 1fr; gap: 10px; padding: 9px 8px; border: 0; background: transparent; text-align: left; border-radius: 10px; }
.feed button:hover { background: var(--paper-2); }
.feed .avatar { width: 30px; height: 30px; border: 0; }
.feed p { margin: 0; font-size: 13.5px; line-height: 1.4; }
.feed p.q { color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.feed time { color: var(--ink-3); font-size: 12px; }

.upcoming { display: grid; gap: 4px; }
.upcoming button { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 10px 8px; border: 0; border-radius: 10px; background: transparent; text-align: left; }
.upcoming button:hover { background: var(--paper-2); }
.upcoming .t { min-width: 0; font-size: 13.5px; }
.upcoming .t span { display: block; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.datebox { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 12px; background: var(--paper-2); border: 1px solid var(--line); line-height: 1; }
.datebox b { font: 700 16px/1 var(--display); }
.datebox small { font-size: 11px; color: var(--ink-3); margin-top: 3px; }
.datebox.late { background: var(--crit-soft); border-color: #f4c9c9; color: var(--crit-ink); }
.datebox.soon { background: var(--warn-soft); border-color: #f5dfa8; color: var(--warn-ink); }

.notice { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 14px; background: var(--warn-soft); color: var(--warn-ink); margin-bottom: 18px; }
.notice p { margin: 0; flex: 1; }

/* ============ Upload ============ */
.drops { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.drop {
  position: relative; display: grid; gap: 12px; align-content: start; padding: 22px; min-height: 250px;
  border-radius: 24px; border: 2px dashed color-mix(in srgb, var(--c) 35%, var(--line)); background: var(--paper);
  transition: background .2s, border-color .2s, transform .2s var(--ease);
}
.drop.over { background: var(--soft); border-color: var(--c); transform: scale(1.01); }

.drop h3 { margin: 0; font-size: 16px; }
.drop p { margin: 0; color: var(--ink-2); font-size: 13.5px; }
.drop .last { color: var(--ink-3); font-size: 12.5px; margin-top: auto; }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop .btn { position: relative; z-index: 1; justify-self: start; pointer-events: none; }
.drop.busy::after { content: ''; position: absolute; inset: 0; border-radius: 22px; background: rgb(255 255 255 / 60%) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Ccircle cx='20' cy='20' r='14' fill='none' stroke='%2317233a' stroke-width='3' stroke-dasharray='60 30'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 20 20' to='360 20 20' dur='.8s' repeatCount='indefinite'/%3E%3C/circle%3E%3C/svg%3E") center/40px no-repeat; }
.result { margin-top: 18px; animation: rise .35s var(--ease); }
.result-stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.result-stats div { padding: 12px 14px; border-radius: 12px; background: var(--paper-2); }
.result-stats b { display: block; font: 700 24px/1.1 var(--display); }
.result-stats span { color: var(--ink-2); font-size: 13px; }
.names { display: flex; flex-wrap: wrap; gap: 8px; }
.name-chip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 4px 4px 12px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--paper); font-size: 14px; }
.name-chip small { color: var(--ink-3); }

.utable { width: 100%; border-collapse: collapse; }
.utable th { text-align: left; font-size: 12.5px; font-weight: 500; color: var(--ink-3); padding: 12px 14px; border-bottom: 1px solid var(--line); }
.utable td { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.utable tr.off td { color: var(--ink-3); }
.role { display: inline-flex; padding: 2px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 500; background: var(--paper-2); border: 1px solid var(--line); }
.role.admin { background: var(--pq-soft); color: var(--pq-ink); border-color: transparent; }

/* ============ Login ============ */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; padding: 48px; background: var(--paper); border-top: 4px solid var(--official); border-right: 1px solid var(--line); }
.login-art h2 { margin: 0 0 28px; max-width: 22ch; font: 600 clamp(24px, 2.6vw, 34px)/1.25 var(--display); letter-spacing: -.01em; }
.login-art .sources { display: grid; gap: 12px; max-width: 460px; }
.login-art .sources div { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper-2); }
.login-art .sources b { display: block; font-weight: 600; }
.login-art .sources small { color: var(--ink-3); font-size: 13px; }
.login-art p { max-width: 38ch; color: var(--ink-2); margin: 0; font-size: 16px; }
.login-form { display: grid; place-items: center; padding: 32px; }
.login-form form { width: min(380px, 100%); display: grid; gap: 16px; }
.login-form h1 { margin: 0 0 6px; font: 700 26px/1.2 var(--display); }

/* Toasts */
#toasts { position: fixed; z-index: 100; left: 20px; bottom: 20px; display: grid; gap: 8px; }
.toast { padding: 12px 16px; border-radius: 12px; background: var(--ink); color: #fff; box-shadow: var(--shadow-3); animation: rise .3s var(--ease); max-width: 360px; font-size: 14px; }
.toast.err { background: var(--crit-ink); }

.skeleton { border-radius: 16px; background: linear-gradient(90deg, #eef1f6 0, #f7f9fc 50%, #eef1f6 100%) 0 0 / 200% 100%; animation: shimmer 1.2s linear infinite; }

/* ============ Motion ============ */
.tasks.calm .task { animation: none; }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(4px); } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
@keyframes rowIn { from { opacity: 0; transform: translateY(8px); } }
@keyframes slideIn { from { transform: translateX(100%); } }
@keyframes slideOut { to { transform: translateX(100%); } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--c) 45%, transparent); } 100% { box-shadow: 0 0 0 12px transparent; } }
@keyframes shimmer { to { background-position: -200% 0; } }

::view-transition-group(*) { animation-duration: .5s; animation-timing-function: var(--ease); }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .3s; }
::view-transition-old(card-pq), ::view-transition-new(card-pq),
::view-transition-old(card-pa), ::view-transition-new(card-pa),
::view-transition-old(card-vm), ::view-transition-new(card-vm) { height: 100%; object-fit: none; object-position: left top; }

/* ============ Responsive ============ */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid { grid-template-columns: 1fr; }
  .split { grid-template-columns: 280px minmax(0, 1fr); }
}
@media (max-width: 860px) {
  main { padding: 18px 16px; }
  .topbar { padding: 0 16px; gap: 12px; }
  .nav { overflow-x: auto; }
  .usermenu .who { display: none; }
  .cards, .drops { grid-template-columns: 1fr; }
  .src-card { min-height: 220px; }
  .split { grid-template-columns: 1fr; }
  .rail { position: static; }
  .rail .mini-src { display: none; }
  .task { grid-template-columns: 1fr; }
  .task .side { grid-column: 1; grid-row: auto; justify-items: start; }
  .bar-row { grid-template-columns: 1fr 56px; }
  .bar-row .lbl { grid-column: 1 / -1; }
  .result-stats { grid-template-columns: repeat(2, 1fr); }
  .login { grid-template-columns: 1fr; }
  .login-art { padding: 28px; border-right: 0; border-bottom: 1px solid var(--line); }
  .login-art .sources { display: none; }
  .stepper { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .meta-grid { grid-template-columns: 1fr; }
  .brand-name { display: none; }
}

/* ============ Notifications ("Хабардор қилиш") ============ */
.bell { position: relative; margin-left: auto; margin-right: 10px; }
.bell-btn {
  position: relative; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink-2);
}
.bell-btn .icon { width: 20px; height: 20px; }
.bell-btn:hover { background: var(--paper-2); color: var(--ink); }
.bell.has-new .bell-btn { color: var(--focus); border-color: color-mix(in srgb, var(--focus) 40%, var(--line)); }
.bell.has-new .bell-btn .icon { animation: ring 1.2s ease-in-out 2; transform-origin: 50% 4px; }
.bell-count {
  position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--st-returned); color: #fff; font-size: 12px; font-weight: 700; line-height: 20px; text-align: center;
  box-shadow: 0 0 0 2px var(--paper);
}
.bell-panel {
  position: absolute; right: 0; top: calc(100% + 8px); width: min(400px, calc(100vw - 24px)); max-height: 70vh; overflow: auto;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-2);
  z-index: 40; animation: pop .18s var(--ease);
}
.bell-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.bell-list { display: grid; }
.note {
  display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 10px; text-align: left; padding: 12px 14px;
  border: 0; border-bottom: 1px solid var(--line); background: none; width: 100%;
}
.note:hover { background: var(--paper-2); }
.note.new { background: #eef3ff; }
.note.new:hover { background: #e4ecff; }
.note .avatar { width: 34px; height: 34px; border: 0; }
.note-b { display: grid; gap: 3px; font-size: 13.5px; }
.note-text { color: var(--ink-2); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.note time { color: var(--ink-3); font-size: 12px; }
.note.new time::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--focus); margin-right: 6px; vertical-align: 1px; }
.bell-empty { margin: 0; padding: 20px 16px; color: var(--ink-3); font-size: 14px; }

.composer { flex-direction: column; align-items: stretch; position: relative; }
.composer-row { display: flex; gap: 10px; align-items: flex-end; }
.composer-row .textarea { flex: 1; }
.notify-btn { position: relative; width: 44px; height: 44px; flex: none; border: 1px solid var(--line-2); }
.notify-btn.on { color: var(--focus); border-color: color-mix(in srgb, var(--focus) 45%, var(--line)); background: #eef3ff; }
.notify-btn b {
  position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--focus); color: #fff; font-size: 11px; line-height: 18px;
}
.notify-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); }
.notify-chips > span { display: inline-flex; align-items: center; gap: 4px; }
.notify-chips .icon { width: 15px; height: 15px; }
.chip { border: 1px solid color-mix(in srgb, var(--focus) 35%, var(--line)); background: #eef3ff; color: var(--ink); border-radius: 999px; padding: 3px 10px; font-size: 13px; }
.chip:hover { background: #e0e9ff; }
.notify-pop {
  position: absolute; left: 22px; right: 22px; bottom: calc(100% - 8px); max-height: 340px; display: grid; grid-template-rows: auto auto minmax(0, 1fr);
  gap: 8px; padding: 12px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-3);
  animation: pop .18s var(--ease); z-index: 5;
}
.notify-pop-h { display: flex; align-items: center; justify-content: space-between; }
.notify-pop .picker-list { overflow: auto; }
.notify-pop .picker-list .tag { margin-left: auto; }

.msg .notified { display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; font-size: 12px; color: var(--ink-3); }
.msg .notified .icon { width: 13px; height: 13px; }
.msg.for-me .bubble { background: #fff7e0; border-color: #f3d98a; box-shadow: 0 0 0 3px #fff3cc; }
.msg.for-me .notified { color: var(--warn-ink); font-weight: 600; }

.mention { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; background: #fff3cc; color: var(--warn-ink); font-size: 12px; font-weight: 600; margin-right: 6px; }
.mention .icon { width: 13px; height: 13px; }

@keyframes ring { 0%, 100% { transform: rotate(0); } 15% { transform: rotate(14deg); } 30% { transform: rotate(-12deg); } 45% { transform: rotate(8deg); } 60% { transform: rotate(-4deg); } }
