/* YNOT Ops Mini App v1 — "YNOT Production" look (ref/variables.css, styles.css, components.css).
   Palette is the Production one; light/dark follows Telegram colorScheme via html[data-scheme]. */
:root {
  --bg: #f7f7fa;                      /* --color-gray-100 */
  --card: #fdfdfd;                    /* --surface-action: white .82 + blur, as one opaque colour */
  --fill: rgba(0, 26, 54, .06);       /* --surface-secondary: tracks, chips */
  --pill: #fff;                       /* active segment (--action-secondary) */
  --border: rgba(0, 0, 0, .05);
  --shadow: rgba(0, 0, 0, .1);
  --line: rgba(0, 0, 0, .06);         /* row dividers inside cards */
  --text: #202429;                    /* --color-gray-900 */
  --text-default: #202429;
  --text-2: #646466;                  /* --color-gray-600 / --text-secondary */
  --av-bg: #646466;
  --av-text: #fff;
  --blue: #3a70e7;                    /* --fix-blue-primary */
  --green: rgba(120, 218, 113, .8);   /* --fix-green */
  --orange: rgba(245, 172, 105, .8);  /* --fix-orange */
  --red: rgba(224, 0, 0, .8);         /* --fix-red */
  --red-text: #d42a2a;
  --orange-text: #b8640f;
  --blue-text: #3a70e7;
  --dot-ok: rgb(98, 200, 92);
  --dot-warn: rgb(240, 160, 80);
  --dot-down: rgb(224, 32, 32);
  --dot-unknown: #a3a5a9;
  --warn-bg: rgba(245, 172, 105, .1); /* --notification-bg-warning */
  --error-bg: rgba(224, 0, 0, .1);    /* --notification-bg-error */
  --t-blue-bg: #ddf4ff;   --t-blue: #0969da;
  --t-violet-bg: #f5f0ff; --t-violet: #8250df;
  --t-mint-bg: #dafbe1;   --t-mint: #1a7f37;
  --t-sand-bg: #fff8c5;   --t-sand: #9a6700;
  --noise-opacity: .03;
  --radius: .5rem;                    /* --border-radius */
  --speed: .3s;                       /* --transition-speed */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif,
    "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
}
@media (prefers-color-scheme: dark) {
  :root:not([data-scheme="light"]) {
    --bg: #202429; --card: #32363a; --fill: rgba(255, 255, 255, .06); --pill: rgba(0, 0, 0, .4);
    --border: rgba(0, 0, 0, .36); --shadow: rgba(0, 0, 0, .2); --line: rgba(255, 255, 255, .07);
    --text: #f7f7fa; --text-default: rgba(255, 255, 255, .75); --text-2: rgba(255, 255, 255, .43);
    --av-bg: #c9ccd1; --av-text: #202429; --red-text: #ff6b6b; --orange-text: #f2a65a; --blue-text: #8fb0ff;
    --dot-unknown: #7d8085; --warn-bg: rgba(245, 172, 105, .15); --error-bg: rgba(224, 0, 0, .15);
    --t-blue-bg: rgba(58, 112, 231, .2);    --t-blue: #8fb0ff;
    --t-violet-bg: rgba(130, 80, 223, .22); --t-violet: #c3a6ff;
    --t-mint-bg: rgba(46, 160, 67, .2);     --t-mint: #7ee787;
    --t-sand-bg: rgba(212, 167, 44, .18);   --t-sand: #e3b341;
    --noise-opacity: .05;
  }
}
:root[data-scheme="dark"] {
  color-scheme: dark;
  --bg: #202429; --card: #32363a; --fill: rgba(255, 255, 255, .06); --pill: rgba(0, 0, 0, .4);
  --border: rgba(0, 0, 0, .36); --shadow: rgba(0, 0, 0, .2); --line: rgba(255, 255, 255, .07);
  --text: #f7f7fa; --text-default: rgba(255, 255, 255, .75); --text-2: rgba(255, 255, 255, .43);
  --av-bg: #c9ccd1; --av-text: #202429; --red-text: #ff6b6b; --orange-text: #f2a65a; --blue-text: #8fb0ff;
  --dot-unknown: #7d8085; --warn-bg: rgba(245, 172, 105, .15); --error-bg: rgba(224, 0, 0, .15);
  --t-blue-bg: rgba(58, 112, 231, .2);    --t-blue: #8fb0ff;
  --t-violet-bg: rgba(130, 80, 223, .22); --t-violet: #c3a6ff;
  --t-mint-bg: rgba(46, 160, 67, .2);     --t-mint: #7ee787;
  --t-sand-bg: rgba(212, 167, 44, .18);   --t-sand: #e3b341;
  --noise-opacity: .05;
}
:root[data-scheme="light"] { color-scheme: light; }

/* ---- base + grain ----------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; padding: 0 0 calc(24px + env(safe-area-inset-bottom, 0px)); min-height: 100vh; overflow-x: hidden;
  font: 400 13px/1.5 var(--font); color: var(--text-default);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  transition: color var(--speed) ease-in-out;
}
/* Production noise (ref styles.css body:after). z-index 0 in the root stacking context:
   above the canvas (html) background, below the positioned content (main z 1, .topbar z 1). */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: var(--noise-opacity);   /* .03 light, .05 dark */
  background-image: url(../img/noize.png);
  background-size: 50%;
}
main {
  position: relative; z-index: 1; min-height: calc(100vh - 80px); overflow-x: hidden; /* full-height swipe area */
  touch-action: pan-y; /* the browser only scrolls vertically here; horizontal drags belong to the tab paging */
}
a { color: var(--blue-text); text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus { outline: none; }
button:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.muted { color: var(--text-2); font-size: 12px; }
.topbar, .seg, .check { -webkit-user-select: none; user-select: none; }

/* ---- header: ONE row like Production — logo | pill switcher | avatar --- */
.topbar {
  position: relative; z-index: 2; /* scrolls with the page; above the grain and above main (avatar tooltip overlaps it) */
  display: grid; grid-template-columns: 40px minmax(0, 1fr) 40px; align-items: center; column-gap: 12px;
  min-height: 72px;
  padding: calc(8px + env(safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px))
    max(1rem, env(safe-area-inset-right, 0px)) 8px max(1rem, env(safe-area-inset-left, 0px));
}
.logo { width: 32px; height: 32px; object-fit: contain; display: block; cursor: pointer; transition: filter var(--speed) ease-in-out, transform .2s ease; }
.logo:active { transform: scale(.95); }
:root[data-scheme="dark"] .logo { filter: invert(1) brightness(.8); }

/* Avatar (Production: 40px black circle, white initial) */
.avatar {
  width: 40px; height: 40px; border-radius: 50%; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: #000; color: #fff; font-size: 16px; font-weight: 600; text-transform: uppercase;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Dark: a black circle vanishes on the dark page — use the chip letter palette (light circle, dark letter). */
:root[data-scheme="dark"] .avatar { background: var(--av-bg); color: var(--av-text); }
.avatar { cursor: pointer; -webkit-tap-highlight-color: transparent; }
/* Staff: no switcher — plain centred title instead */
/* Fixed columns: hidden centre (loading / staff) must not pull the avatar into column 2. */
.topbar > .logo { grid-column: 1; }
#tabs, .topbar-title { grid-column: 2; }
.avatar-wrap { grid-column: 3; }
.topbar-title { justify-self: center; font-size: 15px; font-weight: 600; color: var(--text); }

/* Username tooltip under the avatar (YNOT CRM .username-tooltip) */
.avatar-wrap { position: relative; width: 40px; height: 40px; }
.user-tip {
  position: absolute; top: 46px; right: 0; z-index: 20;
  display: inline-flex; align-items: center; height: 30px; padding: 0 15px; border-radius: 10px;
  font-size: 14px; font-weight: 100; line-height: 30px; white-space: nowrap; color: var(--text);
  background: transparent; border: 1px solid var(--border); box-shadow: 0 4px 15px var(--shadow);
  -webkit-backdrop-filter: blur(15px); backdrop-filter: blur(15px);
  opacity: 1; transform: translateY(0); pointer-events: none;
  transition: opacity .4s ease-in-out, transform .4s ease-in-out;
}
.user-tip.is-hidden { opacity: 0; transform: translateY(-10px); }

/* Segmented control (ref .filter-tabs / .filter-slider): two equal halves, the slider
   moves by [data-active] on the track, so no inline styles are needed. */
.seg {
  position: relative; display: flex; justify-self: center; width: 100%; max-width: 260px;
  height: 40px; padding: 3px; border-radius: 20px; background: var(--fill);
}
.seg-slider {
  position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc(50% - 3px);
  border-radius: 17px; background: var(--pill);
  box-shadow: 0 1px 3px 0 var(--shadow), 0 1px 2px -1px var(--shadow);
  transition: transform var(--speed) cubic-bezier(.4, 0, .2, 1), background-color var(--speed);
}
.seg[data-active="systems"] .seg-slider, .seg[data-active="done"] .seg-slider { transform: translateX(100%); }
.seg-btn {
  position: relative; z-index: 1; flex: 1 1 0; min-width: 0;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  padding: 0 4px; border: 0; border-radius: 17px; background: transparent; color: var(--text);
  font-size: 13px; line-height: 34px; white-space: nowrap;
}
/* iOS-style unread dot at the top-right of the tab label */
.seg-label { position: relative; }
.tab-dot { position: absolute; top: 7px; right: -10px; width: 7px; height: 7px; border-radius: 50%; }
.tab-dot-red { background: var(--dot-down); }
.tab-dot-blue { background: var(--blue); }

/* ---- screens + notices ------------------------------------------------ */
.screen { padding: 48px 24px; text-align: center; color: var(--text-2); }
.screen-title { font-size: 16px; font-weight: 600; line-height: 24px; color: var(--text); margin-bottom: 4px; }
.screen-text { margin-bottom: 14px; }
.btn-primary {
  height: 28px; padding: 0 14px; border: 0; border-radius: 14px;
  background: var(--blue); color: #fff; font-size: 13px; line-height: 28px;
  transition: transform .1s ease;
}
.btn-primary:active { transform: scale(.95); }
.inline-error, .snapshot-warn {
  margin: 0 1rem 12px; padding: 8px 12px; border-radius: var(--radius); font-size: 13px; line-height: 18px;
}
.inline-error { background: var(--error-bg); color: var(--red-text); }
.snapshot-warn { background: var(--warn-bg); color: var(--orange-text); font-weight: 600; border-left: 3px solid var(--orange); }
.view { padding: 4px max(1rem, env(safe-area-inset-right, 0px)) 0 max(1rem, env(safe-area-inset-left, 0px)); }
/* Paging (js/app.js): while a swipe/tap slide runs, the other page sits beside the shown one;
   JS sets top (below the banners) and the translate3d()s, and removes everything when the slide ends. */
.view.page-nb { position: absolute; left: 0; right: 0; }
.tasks-note, .dev-note {
  margin: 0 4px 8px; font-size: 11px; line-height: 16px; color: var(--text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dev-note { margin: 16px 0 0; text-align: center; opacity: .7; }
.btn-link { display: block; margin: 8px auto 0; padding: 8px; border: 0; background: none; color: var(--blue-text); }

/* ---- cards (ref .card) ------------------------------------------------ */
.card {
  position: relative; overflow: hidden;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--card); box-shadow: 0 2px 4px var(--shadow); color: var(--text);
  transition: background-color var(--speed) ease-in-out;
}
.row { padding: 10px 20px; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }

/* ---- tasks ------------------------------------------------------------ */
.group { margin-bottom: 16px; }
.group-hdr {
  display: flex; align-items: baseline; gap: 6px; padding: 0 4px 6px;
  font-size: 12px; line-height: 16px; color: var(--text-2);
}
.group-name { font-weight: 600; }
.group-count { font-variant-numeric: tabular-nums; }
.group-empty { padding: 0 4px; }

/* Unseen task: small blue dot at the start of the row */
.new-dot { display: none; flex: none; width: 7px; height: 7px; margin: 6.5px -9px 0 -10px; border-radius: 50%; background: var(--blue); }
.task.unseen .new-dot { display: block; }

/* To-do rows: checkbox | one-line title + one muted line; tap expands detail. */
.task { display: flex; align-items: flex-start; gap: 12px; padding: 9px 16px; cursor: pointer; }
.check {
  position: relative; flex: none; width: 20px; height: 20px; margin-top: 0;
  border: 1.5px solid var(--text-2); border-radius: 50%; opacity: .7;
}
.check.checked { background: var(--text-2); border-color: transparent; opacity: 1; }
.check.checked::after {
  content: ''; position: absolute; left: 6px; top: 2.5px; width: 5px; height: 10px;
  border: solid var(--card); border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.task-body { flex: 1; min-width: 0; }
.task-title {
  display: block; font-weight: 400; line-height: 20px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
a.task-title { color: var(--blue-text); }
.task-sub { font-size: 12px; line-height: 16px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task.done .task-title, .task.done .task-sub { color: var(--text-2); text-decoration: line-through; }
.task-detail { display: none; margin-top: 4px; font-size: 12px; line-height: 16px; color: var(--text-2); overflow-wrap: anywhere; }
.task.open .task-detail { display: block; }
.task-full { margin-bottom: 2px; color: var(--text-default); }

/* ---- person filter: horizontally scrollable Production custom-tags ---- */
.chips-row {
  display: flex; gap: 5px; margin: 0 -1rem 10px; padding: 2px 1rem 4px;
  overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  -webkit-user-select: none; user-select: none;
}
.chips-row::-webkit-scrollbar { display: none; }
.pchip {
  flex: none; display: inline-flex; align-items: center; gap: 5px;
  height: 28px; padding: 0 10px 0 4px; border: 0; border-radius: 14px;
  background: var(--fill); color: var(--text); font-size: 13px; font-weight: 300; line-height: 1; white-space: nowrap;
  transition: background-color var(--speed) ease, color var(--speed) ease, transform .1s ease;
}
.pchip:active { transform: scale(.95); }
.pchip-all { padding: 0 12px; }   /* «Все»: no avatar, symmetric padding */
/* Name and count as line-height:1 blocks inside the align-items:center chip → identical centres. */
.pchip-name, .pchip-count { display: block; line-height: 1; }
.pchip.sel { background: var(--blue); color: #fff; }
.pchip-count { font-size: 12px; font-weight: 600; opacity: .7; font-variant-numeric: tabular-nums; }
.pchip.sel .pchip-count { opacity: 1; }
.pav {
  flex: none; display: inline-flex; align-items: center; justify-content: center; overflow: hidden;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--av-bg); color: var(--av-text); font-size: 10px; font-weight: 600; line-height: 1; text-transform: uppercase;
}
.pav img { width: 100%; height: 100%; object-fit: cover; display: block; }   /* colour always (KS, YNOT AI msg 833) */

/* ---- Открытые · Готово + search ---------------------------------------- */
.tasks-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.seg.seg-sm { flex: 1; max-width: none; height: 32px; }
.seg-sm .seg-slider { border-radius: 13px; }
.seg-sm .seg-btn { line-height: 26px; border-radius: 13px; }
.mode-count { margin-left: 3px; font-size: 12px; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; }
.icon-btn {
  flex: none; display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%;
  background: var(--fill); color: var(--text-2); transition: background-color var(--speed) ease, color var(--speed) ease;
}
.icon-btn.active { background: var(--blue); color: #fff; }
.search-wrap { position: relative; margin-bottom: 10px; }
.search {
  display: block; width: 100%; height: 32px; padding: 0 32px 0 12px; border: 1px solid var(--border); border-radius: 16px;
  background: var(--card); color: var(--text); font: inherit; font-size: 16px; /* 16px: no iOS zoom on focus */
  -webkit-appearance: none; appearance: none;
}
.search:focus { outline: none; border-color: var(--blue); }
.search::-webkit-search-cancel-button { display: none; }
.search-clear {
  position: absolute; top: 0; right: 0; display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0; border: 0; background: none; color: var(--text-2);
}
.search::placeholder { color: var(--text-2); font-size: 13px; }
.more-row {
  display: block; width: 100%; padding: 8px 16px 8px 48px; border: 0; border-top: 1px solid var(--line);
  background: none; color: var(--blue-text); font-size: 13px; text-align: left;
}
.empty { padding: 32px 16px; text-align: center; color: var(--text-2); }

/* ---- systems ---------------------------------------------------------- */
.sys-summary { padding: 0 4px 10px; line-height: 20px; }
.sys-counts { font-weight: 600; color: var(--text); }
.sys-row { display: flex; gap: 10px; align-items: flex-start; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; margin-top: 5px; background: var(--dot-unknown); }
.dot.ok { background: var(--dot-ok); } .dot.warn { background: var(--dot-warn); }
.dot.down { background: var(--dot-down); } .dot.unknown { background: var(--dot-unknown); }
.sys-main { flex: 1; min-width: 0; }
.sys-name { font-weight: 500; line-height: 18px; color: var(--text); overflow-wrap: anywhere; }
.sys-summary-text { font-size: 12px; line-height: 18px; color: var(--text-default); overflow-wrap: anywhere; }
.sys-time { flex: none; max-width: 42%; text-align: right; overflow-wrap: anywhere; color: var(--text-2); }
.sys-rel { font-size: 12px; line-height: 18px; font-weight: 500; white-space: nowrap; color: var(--text-default); }
.sys-sched { font-size: 11px; line-height: 16px; color: var(--text-2); }

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