/* AltDesk — фирменные цвета: чёрный, красный, белый. Мотив — скошенная красная полоса из логотипа. */
:root {
  --bg: #f3f3f1;
  --surface: #ffffff;
  --ink: #0a0a0a;
  --ink-2: #2e2e2e;
  --muted: #6b6b6b;
  --line: #e4e4e2;
  --line-2: #cfcfcc;
  --hover: #f7f7f5;

  --red: #ff0000;          /* фирменный: полосы, метки, сектор в логотипе */
  --red-ink: #d40000;      /* для текста и кнопок на белом — контраст выше 4.5:1 */
  --red-ink-hover: #b00000;
  --red-soft: #ffeded;
  --on-red: #ffffff;

  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 4px 14px rgba(0, 0, 0, .04);
  --skew: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0b0b; --surface: #151515; --ink: #f4f4f2; --ink-2: #d6d6d3; --muted: #9a9a96;
    --line: #262626; --line-2: #3a3a3a; --hover: #1c1c1c;
    --red-ink: #ff4747; --red-ink-hover: #ff6b6b; --red-soft: #2c1010;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0b0b; --surface: #151515; --ink: #f4f4f2; --ink-2: #d6d6d3; --muted: #9a9a96;
  --line: #262626; --line-2: #3a3a3a; --hover: #1c1c1c;
  --red-ink: #ff4747; --red-ink-hover: #ff6b6b; --red-soft: #2c1010;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
.muted { color: var(--muted); }
.center { text-align: center; }
:focus-visible { outline: 2px solid var(--red-ink); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--red); color: #fff; }

/* --- логотип: в тёмной теме подменяется белой версией через <picture> --- */
.logo { display: block; flex: none; line-height: 0; }
.logo img { display: block; height: 26px; width: auto; }

/* --- верхняя панель: логотип и меню, ниже — вкладки изданий --- */
.topbar { position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; height: 58px; padding: 0 24px; }
.pubtabs {
  display: flex; align-items: stretch; gap: 2px; height: 46px; padding: 0 14px;
  overflow-x: auto; scrollbar-width: none; border-top: 1px solid var(--line);
}
.pubtabs::-webkit-scrollbar { display: none; }
.pubtabs a {
  position: relative; display: flex; align-items: center; padding: 0 12px; white-space: nowrap;
  text-decoration: none; color: var(--muted); font-weight: 700; font-size: 14px;
}
.pubtabs a:hover { color: var(--ink); }
.pubtabs a.active { color: var(--ink); }
.pubtabs a.active::after {
  content: ""; position: absolute; left: 8px; right: 8px; bottom: 0; height: 5px;
  background: var(--red); clip-path: var(--skew);
}
.pubtabs .sep { flex: none; width: 1px; margin: 13px 8px; background: var(--line-2); }
.usermenu { display: flex; align-items: center; gap: 16px; white-space: nowrap; font-size: 14px; }
.usermenu a { text-decoration: none; color: var(--muted); font-weight: 600; }
.usermenu a.active, .usermenu a:hover { color: var(--ink); }
.usermenu .who { color: var(--ink-2); font-weight: 600; padding-left: 16px; border-left: 1px solid var(--line); }
.usermenu form { margin: 0; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.linkbtn:hover { color: var(--red-ink); }

.page { max-width: 1120px; margin: 0 auto; padding: 28px 24px 72px; }

/* --- кнопки и поля --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 16px; border-radius: 6px; border: 1.5px solid var(--ink);
  background: transparent; color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; white-space: nowrap;
  transition: background-color .12s, color .12s, border-color .12s;
}
.btn:hover { background: var(--ink); color: var(--surface); }
.btn.primary { background: var(--red-ink); border-color: var(--red-ink); color: var(--on-red); }
.btn.primary:hover { background: var(--red-ink-hover); border-color: var(--red-ink-hover); }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--hover); color: var(--ink); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 5px; }
.btn.wide { width: 100%; }
.btn:disabled, .btn:disabled:hover { opacity: .4; cursor: not-allowed; background: transparent; color: var(--ink); }
.btn.primary:disabled, .btn.primary:disabled:hover { background: var(--red-ink); border-color: var(--red-ink); color: var(--on-red); }
.btn.htmx-request { opacity: .6; }

input[type=text], input[type=password], input[type=search] {
  height: 40px; padding: 0 12px; border-radius: 6px; border: 1.5px solid var(--line-2);
  background: var(--surface); color: var(--ink); font: inherit; width: 100%;
}
input[type=text]:focus, input[type=password]:focus, input[type=search]:focus { outline: none; border-color: var(--ink); }

/* --- вход --- */
main.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 40px 32px 32px; box-shadow: var(--shadow);
}
.login-card .logo { margin: 0 auto; width: max-content; }
.login-card .logo img { height: 50px; }
.login-card .tagline { text-align: center; margin: 16px 0 28px; color: var(--muted); }
.login-card label { display: block; font-size: 13px; font-weight: 700; color: var(--ink-2); margin-bottom: 16px; }
.login-card label input { margin-top: 6px; }
.login-card .btn { margin-top: 8px; height: 44px; }
.error { color: var(--red-ink); background: var(--red-soft); padding: 9px 12px; border-radius: 6px; font-size: 14px; font-weight: 600; }

/* --- заголовок страницы --- */
.feedhead { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; }
.feedhead h1 { font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.feedhead h1::after { content: ""; display: block; width: 64px; height: 6px; margin-top: 8px; background: var(--red); clip-path: var(--skew); }
.feedhead p { margin: 10px 0 0; }
.newbadge {
  display: inline-block; padding: 8px 14px; border-radius: 6px; background: var(--red-ink); color: var(--on-red);
  font-weight: 700; font-size: 13px; text-decoration: none;
}
.newbadge:hover { background: var(--red-ink-hover); }

/* --- фильтры --- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.seg {
  display: inline-flex; max-width: 100%; overflow-x: auto; scrollbar-width: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 3px;
}
.seg::-webkit-scrollbar { display: none; }
.seg label { position: relative; }
.seg input, .toggle input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; white-space: nowrap; padding: 5px 11px; border-radius: 5px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg span:hover { color: var(--ink); }
.seg input:checked + span { background: var(--ink); color: var(--surface); }
.seg input:focus-visible + span, .toggle input:focus-visible + span { outline: 2px solid var(--red-ink); }
.toggle { position: relative; }
.toggle span {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border: 1px solid var(--line);
  background: var(--surface); border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer;
}
.toggle span::before { content: ""; width: 14px; height: 14px; border-radius: 3px; border: 1.5px solid var(--line-2); }
.toggle input:checked + span { color: var(--ink); border-color: var(--ink); }
.toggle input:checked + span::before { background: var(--red); border-color: var(--red); box-shadow: inset 0 0 0 2px var(--surface); }
.search { max-width: 280px; height: 36px !important; flex: 1 1 180px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); font-size: 13px; font-weight: 600; text-decoration: none; color: var(--ink-2);
}
.chip b { font-weight: 600; color: var(--muted); }
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip.active { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.chip.active b { color: inherit; opacity: .65; }
.chip i, .rub i { width: 7px; height: 7px; border-radius: 50%; background: var(--rc, var(--line-2)); display: inline-block; flex: none; }
/* Рубрики в фирменной гамме: красным — только происшествия, остальные нейтральные */
.r-incidents { --rc: var(--red); }

/* --- лента тем --- */
.stories { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; }
.story { position: relative; display: grid; grid-template-columns: 78px 1fr auto; gap: 16px; align-items: start; padding: 14px 18px; border-top: 1px solid var(--line); }
.story:first-child { border-top: 0; }
.story:hover { background: var(--hover); }
.story .when { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; font-weight: 600; padding-top: 2px; }
.story .title { font-weight: 700; font-size: 16px; text-decoration: none; line-height: 1.35; }
.story .title:hover { color: var(--red-ink); }
.story.st-skipped .title { color: var(--muted); font-weight: 500; }
.story.st-taken::before, .story.st-done::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--red);
}
.story.st-done::before { background: var(--ink); }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 5px; font-size: 13px; color: var(--muted); }
.meta .src { color: var(--ink-2); font-weight: 600; }
.meta .more { color: var(--red-ink); font-weight: 700; }
.rub { display: inline-flex; align-items: center; gap: 5px; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: 12px; font-weight: 700; background: var(--bg); color: var(--ink-2); border: 1px solid var(--line); }
.tag.kids { background: var(--red-soft); color: var(--red-ink); border-color: transparent; }
.tag.fed { background: transparent; }
.tag.ok { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.tag.bad { background: var(--red-ink); color: var(--on-red); border-color: var(--red-ink); }
.story .actions { display: flex; gap: 4px; align-items: center; }
.status { font-size: 13px; font-weight: 700; margin: 0; }
.status.st-taken { color: var(--ink); }
.status.st-taken::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--red); vertical-align: 1px; }
.status.st-skipped { color: var(--muted); }
.status.st-done { color: var(--ink); }

.empty { text-align: center; padding: 64px 16px; background: var(--surface); border: 1px dashed var(--line-2); border-radius: 10px; }
.empty h1, .empty h2 { font-size: 20px; margin-bottom: 6px; }

/* --- карточка темы --- */
.back { display: inline-block; margin-bottom: 16px; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 600; }
.back:hover { color: var(--red-ink); }
.storycard { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 26px 28px; box-shadow: var(--shadow); overflow: hidden; }
.storycard h1 { font-size: 28px; font-weight: 800; letter-spacing: -.015em; margin-top: 12px; max-width: 860px; }
.storycard .meta { margin-top: 0; }
.storyactions { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.storyactions .row { display: flex; flex-wrap: wrap; gap: 8px; }
.storyactions .status { margin-bottom: 12px; }
.hint { margin: 12px 0 0; font-size: 13px; color: var(--muted); }
.section { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--ink); margin: 32px 0 12px; }
.section::before { content: ""; width: 22px; height: 5px; background: var(--red); clip-path: var(--skew); }
.items { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.item { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px 20px; overflow: hidden; }
.item.main::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--red); }
.item .meta { margin: 0 0 6px; }
.item .meta b { color: var(--ink); }
.item .meta a { color: var(--muted); font-weight: 600; }
.item .meta a:hover { color: var(--red-ink); }
.item h3 { font-size: 17px; font-weight: 700; }
.item .summary { margin: 6px 0 0; color: var(--ink-2); }
.item details { margin-top: 10px; }
.item summary { cursor: pointer; color: var(--red-ink); font-size: 14px; font-weight: 700; }
.fulltext { margin-top: 8px; color: var(--ink-2); max-width: 760px; }
.fulltext p { margin: 0 0 10px; }

/* --- таблица источников --- */
.tablewrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
.grid th, .grid td { text-align: left; padding: 10px 14px; border-top: 1px solid var(--line); vertical-align: top; }
.grid th { border-top: 0; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 800; }
.grid .num { text-align: right; font-variant-numeric: tabular-nums; }
.grid tr.off td { color: var(--muted); }
.grid a { text-decoration: none; font-weight: 700; }
.grid a:hover { color: var(--red-ink); }
.grid .state { min-width: 240px; }
.grid td:nth-child(2), .grid td:nth-child(3) { white-space: nowrap; }

/* --- телефон --- */
@media (max-width: 720px) {
  .topbar-row { padding: 0 16px; height: 52px; }
  .pubtabs { padding: 0 6px; }
  .topbar .logo img { height: 20px; }
  .usermenu .who, .usermenu a:not(.active) { display: none; }
  .page { padding: 18px 16px 48px; }
  .feedhead { flex-direction: column; align-items: flex-start; }
  .feedhead h1 { font-size: 26px; }
  .story { grid-template-columns: 1fr; gap: 6px; padding: 14px; }
  .story .when { order: -1; }
  .story .actions { justify-content: flex-start; }
  .search { max-width: none; }
  .storycard { padding: 20px 16px; }
  .storycard h1 { font-size: 22px; }
}
