/* ABSS «Проекты» — Teams tab. Teams-native type (Segoe UI), ABSS navy/azure as the only accent.
   Themes follow Teams: default / dark / contrast (data-theme on <html>). */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --line: #e1e4ea;
  --line-strong: #c9ced8;
  --ink: #1b2533;
  --ink-2: #4b5666;
  --ink-3: #6b7585;
  --accent: #0b4f8a;
  --accent-ink: #ffffff;
  --accent-soft: #e6eff8;
  --accent-line: #9fbfde;
  --hover: #eef1f5;
  --ok: #1d6b3a;   --ok-soft: #e4f2e9;
  --warn: #8a5300; --warn-soft: #fbf0dc;
  --bad: #a4262c;  --bad-soft: #fbe9ea;
  --muted-soft: #eceef2;
  --focus: #0b4f8a;
  --shadow: 0 1px 2px rgba(20, 30, 45, .06), 0 6px 18px rgba(20, 30, 45, .08);
  --r: 6px;
  --font: "Segoe UI", "Segoe UI Web (West European)", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: #1b1b1d; --surface: #252528; --surface-2: #2c2c30; --line: #3a3a3f; --line-strong: #4c4c53;
  --ink: #ececef; --ink-2: #c3c4c9; --ink-3: #9a9ba3;
  --accent: #6aa8e0; --accent-ink: #0f1a26; --accent-soft: #1f3247; --accent-line: #3d6488;
  --hover: #303035;
  --ok: #7fd09a; --ok-soft: #1f3528; --warn: #f0be6c; --warn-soft: #3a2f1c; --bad: #f2989c; --bad-soft: #3d2224;
  --muted-soft: #333338; --focus: #8cc0ee;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  color-scheme: dark;
}
html[data-theme="contrast"] {
  --bg: #000; --surface: #000; --surface-2: #000; --line: #fff; --line-strong: #fff;
  --ink: #fff; --ink-2: #fff; --ink-3: #fff;
  --accent: #ffff00; --accent-ink: #000; --accent-soft: #000; --accent-line: #ffff00;
  --hover: #1a1a00; --ok: #3ff23f; --ok-soft: #000; --warn: #ffff00; --warn-soft: #000; --bad: #ff6b6b; --bad-soft: #000;
  --muted-soft: #000; --focus: #00ffff; --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
::selection { background: var(--accent-soft); color: var(--ink); }
html[data-theme="contrast"] ::selection { background: #ffff00; color: #000; }
a { color: var(--accent); text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
.ic { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
#i-more circle { fill: currentColor; }
[hidden] { display: none !important; }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }

/* --- shell --- */
.app { display: grid; grid-template-rows: auto 1fr; height: 100%; }
.bar {
  display: flex; align-items: center; gap: 16px; padding: 0 20px;
  background: var(--surface); border-bottom: 1px solid var(--line); min-height: 48px;
}
.tabs { display: flex; gap: 4px; overflow-x: auto; }
.tabs a {
  position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 13px 10px 12px;
  color: var(--ink-2); text-decoration: none; white-space: nowrap; font-weight: 600;
}
.tabs a:hover { color: var(--ink); }
.tabs a[aria-selected="true"] { color: var(--ink); }
.tabs a[aria-selected="true"]::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0;
  background: var(--accent);
}
.count {
  min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: var(--accent-ink);
  font-size: 12px; line-height: 20px; text-align: center;
}
.me { margin-left: auto; color: var(--ink-3); font-size: 13px; white-space: nowrap; }

.main { display: grid; grid-template-columns: minmax(320px, 400px) 1fr; min-height: 0; }
.main.wide { grid-template-columns: 1fr; }
.main.wide .list-pane { display: none; }

/* --- list --- */
.list-pane { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: var(--surface); }
.filters { padding: 12px 14px 10px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.search { position: relative; display: block; }
.search .ic { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.search input {
  width: 100%; height: 34px; padding: 0 10px 0 32px; border: 1px solid var(--line-strong); border-radius: var(--r);
  background: var(--surface);
}
.search input::placeholder { color: var(--ink-3); }
.filter-row { display: flex; flex-wrap: wrap; gap: 6px; }
select, .input, textarea {
  height: 32px; padding: 0 8px; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface);
}
textarea { height: auto; min-height: 72px; padding: 8px; resize: vertical; width: 100%; }
.chip {
  height: 32px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 16px; background: var(--surface);
  color: var(--ink-2); cursor: pointer;
}
.chip:hover { background: var(--hover); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent-line); color: var(--ink); font-weight: 600; }

.list { overflow-y: auto; flex: 1; padding: 4px 0 24px; }
.group-h {
  position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; gap: 8px;
  padding: 14px 16px 6px; background: var(--surface); color: var(--ink-3); font-size: 12px; font-weight: 600;
  letter-spacing: .02em;
}
.row {
  display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px; align-items: baseline;
  padding: 9px 16px; color: inherit; text-decoration: none; border-left: 0; cursor: pointer;
}
.row:hover { background: var(--hover); }
.row[aria-current="true"] { background: var(--accent-soft); }
html[data-theme="contrast"] .row[aria-current="true"] { outline: 2px solid var(--accent); outline-offset: -2px; }
.row .code { font-weight: 600; color: var(--ink-2); font-size: 13px; }
.row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { grid-column: 2 / 4; color: var(--ink-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 32px 20px; color: var(--ink-3); }
.empty b { display: block; color: var(--ink); margin-bottom: 4px; }

/* stage pills */
.pill {
  display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 8px; border-radius: 10px;
  font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--muted-soft); color: var(--ink-2);
}
.pill.sales { background: var(--accent-soft); color: var(--accent); }
.pill.operations { background: var(--ok-soft); color: var(--ok); }
.pill.stalled { background: var(--warn-soft); color: var(--warn); }
.pill.lost, .pill.not_project { background: var(--bad-soft); color: var(--bad); }
.pill.unrev { background: var(--warn-soft); color: var(--warn); }
html[data-theme="contrast"] .pill { border: 1px solid currentColor; }

/* --- detail --- */
.detail-pane { overflow-y: auto; min-height: 0; }
.detail { max-width: 920px; padding: 20px 28px 64px; }
.btn.back { display: none; }
.d-head { display: grid; gap: 6px; margin-bottom: 14px; }
.d-code { display: flex; align-items: center; gap: 8px; color: var(--ink-3); font-weight: 600; font-size: 13px; }
.d-title { margin: 0; font-size: 22px; line-height: 1.25; font-weight: 600; text-wrap: balance; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 18px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: var(--r);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; font-weight: 600;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.sm { height: 28px; padding: 0 9px; font-size: 13px; }

.menu { position: relative; }
.menu-list {
  position: fixed; z-index: 20; min-width: 220px; padding: 4px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); box-shadow: var(--shadow);
}
.menu-list button {
  display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: none; border-radius: 4px; cursor: pointer;
}
.menu-list button:hover, .menu-list button:focus-visible { background: var(--hover); }
.menu-list button.danger { color: var(--bad); }

.notice {
  display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  padding: 10px 14px; margin-bottom: 16px; border-radius: var(--r); background: var(--warn-soft); color: var(--ink);
}
html[data-theme="contrast"] .notice { border: 1px solid var(--warn); }

.sec { padding: 16px 0; border-top: 1px solid var(--line); }
.sec h2 { margin: 0 0 10px; font-size: 15px; font-weight: 600; }
.facts { display: grid; grid-template-columns: 170px 1fr; gap: 7px 16px; margin: 0; }
.facts dt { color: var(--ink-3); }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.nil { color: var(--ink-3); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 4px; background: var(--muted-soft); font-size: 13px; }
html[data-theme="contrast"] .tag { border: 1px solid var(--line); }
.tag button { border: 0; background: none; padding: 0; margin-left: 2px; cursor: pointer; color: var(--ink-3); display: inline-flex; }

.files { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.files li { display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: start; padding: 4px 0; }
.files .ic { margin-top: 2px; color: var(--ink-3); }
.files a { overflow-wrap: anywhere; }
.files .where { display: block; color: var(--ink-3); font-size: 12px; }
.chron { margin: 0; padding-left: 18px; display: grid; gap: 4px; color: var(--ink-2); }

.hist { list-style: none; margin: 0; padding: 0; }
.hist li { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.hist li:last-child { border-bottom: 0; }
.hist .what { min-width: 0; }
.hist .meta { color: var(--ink-3); font-size: 12px; }
.hist .vals { color: var(--ink-2); font-size: 13px; overflow-wrap: anywhere; }
.hist .vals del { color: var(--ink-3); }
.hist li.undone .what { opacity: .6; }

/* --- form --- */
.form { display: grid; gap: 14px; }
.field { display: grid; grid-template-columns: 170px 1fr; gap: 6px 16px; align-items: start; }
.field > label { padding-top: 6px; color: var(--ink-2); font-weight: 600; }
.field .hint { grid-column: 2; color: var(--ink-3); font-size: 12px; margin-top: -2px; }
.field .input, .field select { width: 100%; max-width: 460px; }
.combo { position: relative; max-width: 460px; }
.combo .input { width: 100%; }
.opts {
  position: fixed; z-index: 30; max-height: 280px; overflow-y: auto; padding: 4px; margin: 0; list-style: none;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow);
}
.opts li { padding: 7px 10px; border-radius: 4px; cursor: pointer; }
.opts li .cat { color: var(--ink-3); font-size: 12px; margin-left: 6px; }
.opts li[aria-selected="true"], .opts li:hover { background: var(--hover); }
.multi { display: grid; gap: 6px; max-width: 460px; }
.multi .row2 { display: flex; gap: 6px; align-items: center; }
.multi .row2 .tag { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.multi .row2 select { flex: none; width: 150px; }
.form-actions { display: flex; gap: 8px; padding-top: 6px; position: sticky; bottom: 0; background: var(--bg); padding-bottom: 12px; }
.err { color: var(--bad); font-weight: 600; }

/* --- review / history pages --- */
.page { max-width: 1040px; padding: 20px 28px 64px; }
.page h1 { margin: 0 0 4px; font-size: 22px; font-weight: 600; }
.page .lead { margin: 0 0 18px; color: var(--ink-2); max-width: 70ch; }
.qtable { width: 100%; border-collapse: collapse; }
.qtable th { text-align: left; font-size: 12px; color: var(--ink-3); font-weight: 600; padding: 6px 10px 6px 0; border-bottom: 1px solid var(--line); }
.qtable td { padding: 9px 10px 9px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
.qtable td.act { white-space: nowrap; text-align: right; }
.qtable td.act .btn + .btn { margin-left: 6px; }

/* --- dialog, toasts --- */
dialog {
  width: min(560px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(10, 16, 26, .35); }
.dlg { padding: 20px 22px; display: grid; gap: 12px; }
.dlg h2 { margin: 0; font-size: 18px; font-weight: 600; }
.dlg p { margin: 0; color: var(--ink-2); }
.dlg ul { margin: 0; padding-left: 18px; color: var(--ink-2); }
.dlg .btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.pick { max-height: 320px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r); padding: 4px 8px; }
.pick label { display: grid; grid-template-columns: auto 1fr; gap: 8px; padding: 5px 0; align-items: start; }
.pick small { color: var(--ink-3); display: block; }

.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: grid; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 14px; border-radius: var(--r);
  background: var(--ink); color: var(--surface); box-shadow: var(--shadow);
  animation: rise .2s cubic-bezier(.16, 1, .3, 1);
}
html[data-theme="contrast"] .toast { background: #000; color: #fff; border: 1px solid #fff; }
.toast.bad { background: var(--bad); color: #fff; }
.toast .btn { height: 28px; background: transparent; color: inherit; border-color: currentColor; }
@keyframes rise { from { transform: translateY(6px); opacity: .4; } to { transform: none; opacity: 1; } }

.skel { height: 14px; margin: 12px 16px; border-radius: 4px; background: var(--muted-soft); }
.skel.w60 { width: 60%; } .skel.w80 { width: 80%; } .skel.w40 { width: 40%; }

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

/* --- narrow (Teams mobile, side panel) --- */
@media (max-width: 760px) {
  .bar { padding: 0 8px; gap: 8px; }
  .me { display: none; }
  .main { grid-template-columns: 1fr; }
  .main.has-detail .list-pane { display: none; }
  .main:not(.has-detail):not(.wide) .detail-pane { display: none; }
  .list-pane { border-right: 0; }
  .detail, .page { padding: 14px 16px 48px; }
  .btn.back { display: inline-flex; margin: 0 0 10px -8px; }
  .facts, .field { grid-template-columns: 1fr; gap: 2px 0; }
  .facts dd { margin-bottom: 8px; }
  .field > label { padding-top: 0; }
  .field .hint { grid-column: 1; }
  .qtable thead { display: none; }
  .qtable tr { display: grid; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .qtable td { border: 0; padding: 2px 0; }
  .qtable td.act { text-align: left; padding-top: 6px; }
}
