/* Ncrm — тема «Money Talks»: чёрный фон, приглушённое золото в подписях, бумага с рваными краями
   и гравировка как на купюре. Бумажные элементы (карточки, окна, меню, квитанции) переопределяют
   цветовые переменные, поэтому таблицы и статусы внутри них сами становятся «чернильными». */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  color-scheme: dark;

  --bg: #0a0a09;
  --fg: #ebe5d8;
  --fg-dim: #b0a898;
  --fg-faint: #857e71;
  --rule: #262420;
  --rule-strong: #3d3a32;
  --accent: #c0a76f;       /* подписи и акценты: золото на чёрном, чернила на бумаге */
  --accent-text: #d4bc87;
  --accent-dim: #7f6e48;
  --red: #dd8576;

  --st-pending: #b0a898;
  --st-done: #adbf8f;
  --st-paid: #d4bc87;
  --st-postponed: #d9a259;
  --st-declined: #dd8576;

  --paper: #dcd1b9;
  --paper-band: #d1c49f;
  --ink: #1c1913;
  --ink-dim: #5b5244;

  /* Forum — только логотип и крупные заголовки; текст и мелкие подписи — плотный PT Serif,
     тонкие шрифты на тёмном фоне плохо читаются */
  --font-caps: 'Forum', 'PT Serif', Georgia, serif;
  --font-text: 'PT Serif', Georgia, 'Times New Roman', serif;
  --font-head: 'Playfair Display', Georgia, serif;

  --header-height: 60px;
  --sidebar-width: 210px;

  --guilloche: url('/img/guilloche.svg');
  --newsprint: url('/img/newsprint.svg');
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.95' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .7 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --paper-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .3 0 0 0 0 .22 0 0 0 0 .1 0 0 0 .45 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23p)'/%3E%3C/svg%3E");

  /* Рваные края бумаги (зубцы до 8px) и прореха (до 19px) */
  --torn: 0% 7px, 3% 2px, 6% 6px, 9% 1px, 12% 5px, 15% 3px, 18% 8px, 21% 2px, 24% 6px, 27% 0px, 30% 5px,
    33% 3px, 36% 7px, 39% 1px, 42% 4px, 45% 2px, 48% 8px, 51% 3px, 54% 6px, 57% 0px, 60% 5px, 63% 2px,
    66% 7px, 69% 3px, 72% 6px, 75% 1px, 78% 5px, 81% 2px, 84% 7px, 87% 3px, 90% 6px, 93% 1px, 96% 5px,
    100% 2px, 100% calc(100% - 4px), 97% 100%, 94% calc(100% - 6px), 91% calc(100% - 2px),
    88% calc(100% - 7px), 85% calc(100% - 1px), 82% calc(100% - 5px), 79% calc(100% - 3px),
    76% calc(100% - 8px), 73% calc(100% - 2px), 70% calc(100% - 6px), 67% 100%, 64% calc(100% - 5px),
    61% calc(100% - 3px), 58% calc(100% - 7px), 55% calc(100% - 1px), 52% calc(100% - 4px),
    49% calc(100% - 2px), 46% calc(100% - 8px), 43% calc(100% - 3px), 40% calc(100% - 6px), 37% 100%,
    34% calc(100% - 5px), 31% calc(100% - 2px), 28% calc(100% - 7px), 25% calc(100% - 3px),
    22% calc(100% - 6px), 19% calc(100% - 1px), 16% calc(100% - 5px), 13% calc(100% - 2px),
    10% calc(100% - 7px), 7% calc(100% - 3px), 4% calc(100% - 6px), 0% calc(100% - 2px);
  --slit: 0% 16px, 4% 5px, 8% 18px, 12% 3px, 16% 13px, 20% 8px, 25% 19px, 29% 2px, 33% 12px, 38% 0px,
    42% 11px, 46% 5px, 51% 17px, 55% 2px, 59% 12px, 63% 6px, 68% 18px, 72% 4px, 76% 14px, 81% 1px,
    85% 11px, 89% 3px, 94% 15px, 100% 7px, 100% calc(100% - 9px), 95% calc(100% - 1px),
    91% calc(100% - 15px), 86% calc(100% - 4px), 81% calc(100% - 18px), 77% calc(100% - 3px),
    72% calc(100% - 12px), 67% calc(100% - 6px), 62% calc(100% - 19px), 57% calc(100% - 2px),
    53% calc(100% - 13px), 48% calc(100% - 5px), 43% calc(100% - 17px), 38% 100%, 34% calc(100% - 11px),
    29% calc(100% - 4px), 24% calc(100% - 16px), 19% calc(100% - 7px), 14% calc(100% - 19px),
    9% calc(100% - 3px), 5% calc(100% - 13px), 0% calc(100% - 5px);

  /* Старые имена — на них ссылаются инлайн-стили в разметке */
  --primary-color: var(--accent);
  --bg-color: var(--bg);
  --bg-secondary: #151513;
  --text-primary: var(--fg);
  --text-secondary: var(--fg-dim);
  --border-color: var(--rule);
}

/* Бумажный контекст: всё внутри пишется чернилами */
.company-card,
.company-detail-main,
.aside-card,
.modal-content,
.dropdown,
.status-menu,
.toast,
.public-report-card {
  color-scheme: light;
  --fg: #1c1913;
  --fg-dim: #4a4235;
  --fg-faint: #675e4f;
  --rule: rgba(28, 25, 19, 0.26);
  --rule-strong: #1c1913;
  --accent: #1c1913;
  --accent-text: #1c1913;
  --accent-dim: rgba(28, 25, 19, 0.45);
  --red: #8e3227;
  --st-pending: #4a4235;
  --st-done: #3d4f2c;
  --st-paid: #6b5626;
  --st-postponed: #7d521a;
  --st-declined: #8e3227;
  color: var(--fg);
}

html { background: var(--bg); }

body {
  font-family: var(--font-text);
  font-size: 16px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: lining-nums;
}

/* Плёночное зерно поверх всего, клики проходят насквозь */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: var(--grain);
  opacity: 0.06;
  pointer-events: none;
  z-index: 10000;
}

::selection { background: var(--accent-text); color: var(--bg); }

* { scrollbar-width: thin; scrollbar-color: #33312b transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #33312b; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

a { color: var(--accent-text); }
input, select, textarea, button { font-family: inherit; }
input[type="checkbox"] { accent-color: var(--accent); width: 14px; height: 14px; }

.hidden { display: none !important; }

/* Бумага и гравировка */
.paper-bg,
.company-card,
.aside-card,
.modal-content,
.dropdown,
.status-menu,
.toast {
  background-color: var(--paper);
  background-image:
    radial-gradient(ellipse at center, rgba(255, 250, 232, 0.42), rgba(100, 78, 36, 0.2) 100%),
    var(--paper-grain);
}
.engraved {
  font-family: var(--font-head);
  font-weight: 900;
  font-variant-numeric: lining-nums;
  background: repeating-linear-gradient(0deg, #2a2214 0 1.2px, rgba(42, 34, 20, 0.55) 1.2px 2.6px);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-stroke: 0.6px #2a2214;
}

/* Buttons */
.btn-primary {
  background: transparent;
  color: var(--accent-text);
  border: 1px solid #9a8657;
  padding: 11px 18px;
  border-radius: 0;
  font-family: var(--font-text);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 0.25s, color 0.25s, border-color 0.25s;
}
.btn-primary:hover { background: var(--accent); color: var(--bg); }
.btn-primary:disabled { opacity: 0.5; cursor: wait; }
.btn-primary .material-icons { font-size: 16px; margin-right: 4px; }

/* На бумаге главная кнопка — чернильный штамп */
.company-card .btn-primary,
.aside-card .btn-primary,
.modal-content .btn-primary,
.dropdown .btn-primary {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.aside-card .btn-primary:hover,
.modal-content .btn-primary:hover { background: #5a1f17; border-color: #5a1f17; color: var(--paper); }

.btn-text {
  background: none;
  border: none;
  color: var(--fg-dim);
  padding: 8px 10px;
  font-family: var(--font-text);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.2s;
}
.btn-text:hover { color: var(--fg); }
.btn-text.active-reorder { color: var(--accent-text); }
.btn-text .material-icons { font-size: 16px; }
.btn-danger-text { color: var(--red); margin-right: auto; }
.btn-danger-text:hover { color: var(--red); text-decoration: underline; }

.icon-btn {
  background: none;
  border: none;
  padding: 6px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-faint);
  transition: color 0.2s;
}
.icon-btn .material-icons { font-size: 19px; }
.icon-btn:hover { color: var(--accent-text); }
.icon-btn.active { color: var(--accent-text); }

/* Auth Screen — прореха в бумаге с гравированным именем */
#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: var(--bg);
}

.auth-container {
  width: 100%;
  max-width: 640px;
  text-align: center;
}

.auth-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
  margin-bottom: 34px;
}

.auth-tagline {
  font-family: var(--font-caps);
  font-size: 15px;
  letter-spacing: 0.42em;
  padding-left: 0.42em;
  text-transform: uppercase;
  color: var(--accent);
}

.auth-slit {
  width: min(620px, 88vw);
  height: 170px;
  display: flex;
  align-items: center;
  justify-content: center;
  clip-path: polygon(var(--slit));
  background:
    radial-gradient(ellipse at center, rgba(255, 248, 225, 0.35), rgba(90, 70, 30, 0.35) 100%),
    var(--guilloche) center / 860px auto,
    #cfc29d;
}
.auth-slit .logo-text {
  font-family: var(--font-head);
  font-weight: 900;
  font-size: 96px;
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: transparent;
}

.auth-logo h1 { font-size: 28px; font-weight: 400; }

.auth-form { width: 300px; margin: 0 auto; }

.auth-form h2 {
  font-family: var(--font-text);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.24em;
  padding-left: 0.24em;
  text-transform: uppercase;
  color: var(--fg-dim);
  margin-bottom: 14px;
}

.auth-form input {
  width: 100%;
  padding: 10px 2px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--rule-strong);
  border-radius: 0;
  color: var(--fg);
  font: italic 16px var(--font-text);
  text-align: center;
  margin-bottom: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.auth-form input::placeholder { color: var(--fg-faint); }
.auth-form input:focus { border-color: var(--accent); }

.auth-form .btn-primary { width: 100%; margin-top: 12px; padding: 14px; }

.error-message {
  background: rgba(192, 106, 94, 0.1);
  color: var(--red);
  border-left: 2px solid var(--red);
  padding: 10px 14px;
  margin-top: 16px;
  font-size: 14px;
  text-align: left;
}

/* Header */
.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  padding: 0 22px;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: 20px;
  min-width: 0;
}

.logo-text {
  font-family: var(--font-caps);
  font-size: 17px;
  letter-spacing: 0.45em;
  text-transform: uppercase;
  color: var(--accent);
}

.header-title {
  font-style: italic;
  color: var(--fg-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.user-menu { position: relative; }

/* Меню аккаунта — клочок бумаги */
.dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 260px;
  padding: 10px 0;
  clip-path: polygon(var(--torn));
  z-index: 2000;
}

.dropdown button {
  width: 100%;
  text-align: left;
  padding: 11px 18px;
  border: none;
  background: none;
  color: var(--fg);
  font-size: 15px;
  cursor: pointer;
}
.dropdown button:hover { background: rgba(28, 25, 19, 0.07); }

.user-info {
  padding: 12px 18px 12px;
  border-bottom: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
#user-name { font: 900 19px var(--font-head); font-variant-numeric: lining-nums; }
#user-email { font-size: 13px; color: var(--fg-dim); font-style: italic; }

.unpaid-earnings {
  padding: 10px 18px;
  border-bottom: 1px solid var(--rule);
  font-size: 13px;
  font-weight: 700;
  color: var(--st-paid);
}

/* Main Container */
.main-container {
  display: flex;
  padding-top: var(--header-height);
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  position: fixed;
  left: 0;
  top: var(--header-height);
  bottom: 0;
  width: var(--sidebar-width);
  border-right: 1px solid var(--rule);
  padding: 24px 0;
  overflow-y: auto;
  z-index: 50;
}

.nav-list { list-style: none; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 26px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-dim);
  transition: color 0.2s;
}
.nav-item .material-icons { display: none; font-size: 20px; }
.nav-item:hover { color: var(--fg); }
.nav-item.active { color: var(--accent); }

.nav-divider {
  height: 1px;
  background: var(--rule);
  margin: 12px 26px;
}

/* Content */
.content {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-width);
  padding: 34px 36px 48px;
}

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  max-width: 1080px;
  margin: 0 auto 26px;
}

.content-header h2 {
  font-family: var(--font-caps);
  font-size: 21px;
  font-weight: 400;
  letter-spacing: 0.28em;
  line-height: 1.5;
  text-transform: uppercase;
  color: var(--accent-text);
}

/* Pending Summary */
.pending-summary {
  max-width: 1080px;
  margin: 0 auto 28px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-style: italic;
  color: var(--fg-dim);
}
.pending-summary .material-icons { font-size: 18px; color: var(--accent); }
.pending-summary b { font-style: normal; color: var(--fg); font-weight: 700; }

/* Companies Grid — газетные вырезки на чёрном */
.companies-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 30px 24px;
  max-width: 1080px;
  margin: 0 auto;
}

.company-card {
  position: relative;
  padding: 22px 20px 20px;
  cursor: pointer;
  clip-path: polygon(var(--torn));
  background-image:
    linear-gradient(rgba(220, 209, 185, 0.93), rgba(220, 209, 185, 0.93)),
    var(--newsprint);
  background-size: auto, 640px auto;
  transform: rotate(var(--tilt, 0deg));
  transition: transform 0.3s;
}
.company-card:nth-child(3n + 1) { --tilt: -0.6deg; }
.company-card:nth-child(3n + 2) { --tilt: 0.45deg; }
.company-card:nth-child(3n) { --tilt: -0.25deg; }
.company-card:hover { transform: rotate(0deg) translateY(-3px); }
.company-card.reorder-active { cursor: grab; }
.company-card.reorder-active:hover { transform: rotate(var(--tilt, 0deg)); }
.company-card.reorder-active.dragging { opacity: 0.4; cursor: grabbing; }

.company-card .company-name-row {
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-start;
  gap: 2px;
  padding-right: 54px;
}

.company-card .company-name {
  font: 900 23px/1.15 var(--font-head);
  font-variant-numeric: lining-nums;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.company-card .company-deadline {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-dim);
  white-space: nowrap;
}
.company-card.deadline-urgent .company-deadline { color: #9d3b2f; }
.company-card.deadline-warning .company-deadline { color: #8f5f1f; }

.company-card .company-meta {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: 6px;
  font-size: 15px;
  font-style: italic;
  color: var(--fg-dim);
}

.company-card .company-task-stats {
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 2px 16px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--rule);
  font-style: normal;
  font-size: 13px;
  font-weight: 700;
}
.company-card .stat-done { color: var(--st-done); }
.company-card .stat-pending { color: var(--fg-dim); }
.company-card .company-task-stats span { white-space: nowrap; }

.company-card .company-actions {
  display: none;
  position: absolute;
  top: 12px;
  right: 10px;
  gap: 0;
}
.company-card:hover .company-actions { display: flex; }

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 80px 20px;
  color: var(--fg-dim);
  font-style: italic;
  max-width: 1080px;
  margin: 0 auto;
}
.empty-state .logo-text { font-size: 22px; opacity: 0.5; font-style: normal; }

/* Modal — лист бумаги с рваными краями */
.modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
}
.modal-content {
  position: relative;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 34px 36px 32px;
  clip-path: polygon(var(--torn));
}
.modal-content h3 {
  font: 900 26px/1.15 var(--font-head);
  font-variant-numeric: lining-nums;
  padding-bottom: 8px;
  margin-bottom: 6px;
  border-bottom: 3px double var(--ink);
}
.modal-content p { color: var(--fg-dim); }
.modal-content label {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-dim);
  margin-top: 16px;
  margin-bottom: 2px;
}
.modal-content input,
.modal-content textarea,
.modal-content select {
  width: 100%;
  padding: 6px 0;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--ink);
  border-radius: 0;
  color: var(--ink);
  font: 16px var(--font-text);
  outline: none;
}
.modal-content input::placeholder,
.modal-content textarea::placeholder { color: var(--fg-faint); font-style: italic; }
.modal-content input:focus,
.modal-content textarea:focus,
.modal-content select:focus { border-bottom-width: 2px; padding-bottom: 5px; }
.modal-content input[readonly] { font-weight: 700; }
.modal-content textarea { resize: vertical; min-height: 56px; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-top: 26px;
}

.modal-content-wide { max-width: 720px; }

.modal-note { font-style: italic; margin: 10px 0 14px; }

/* Company Detail Layout */
.company-detail-layout {
  display: flex;
  gap: 30px;
  align-items: flex-start;
  max-width: 1240px;
  margin: 0 auto;
}

/* Задачи — лист гроссбуха: бумага с рваными краями, на широком экране с красной линией поля */
.company-detail-main {
  --ledger-pad: 26px;
  --ledger-id: 64px;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: var(--ledger-pad) var(--ledger-pad) 20px;
  clip-path: polygon(var(--torn));
  background-color: var(--paper);
  background-image:
    radial-gradient(ellipse at center, rgba(255, 250, 232, 0.42), rgba(100, 78, 36, 0.2) 100%),
    var(--paper-grain);
}

.company-detail-main .task-table { max-width: none; margin: 0; }
.company-detail-main .task-table th { border-bottom: 3px double var(--ink); padding-top: 6px; }
.company-detail-main .task-table tbody tr:hover { background: rgba(28, 25, 19, 0.05); }
.company-detail-main .task-group-toggle { border-top: 1px solid var(--rule); padding-top: 12px; }
.company-detail-main .col-id { width: var(--ledger-id); }

@media (min-width: 901px) {
  /* Колонки фиксированной ширины, чтобы линия поля шла точно по границе номера и задачи */
  .company-detail-main {
    --ledger-line: calc(var(--ledger-pad) + var(--ledger-id));
    background-image:
      linear-gradient(90deg,
        transparent var(--ledger-line),
        rgba(160, 50, 40, 0.5) var(--ledger-line),
        rgba(160, 50, 40, 0.5) calc(var(--ledger-line) + 1px),
        transparent calc(var(--ledger-line) + 1px)),
      radial-gradient(ellipse at center, rgba(255, 250, 232, 0.42), rgba(100, 78, 36, 0.2) 100%),
      var(--paper-grain);
  }
  .company-detail-main .task-table { table-layout: fixed; }
  /* «Оплачено» и «Отказались» начинаются вровень с названиями задач, справа от линии */
  .company-detail-main .task-group-toggle { padding-left: calc(var(--ledger-id) + 10px); }
}

.company-detail-aside {
  width: 270px;
  flex-shrink: 0;
}

/* История чеков — квитанция на клочке бумаги */
.aside-card {
  position: sticky;
  top: 90px;
  padding: 24px 20px 22px;
  clip-path: polygon(var(--torn));
  transform: rotate(0.5deg);
}

.aside-card .btn-primary { width: 100%; justify-content: center; }

.aside-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-dim);
  margin: 22px 0 4px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--rule);
}

.aside-empty { font-style: italic; color: var(--fg-dim); padding-top: 8px; }

.aside-history-item {
  padding: 10px 0;
  border-bottom: 1px dotted rgba(28, 25, 19, 0.45);
}
.aside-history-item:last-child { border-bottom: none; }

.aside-history-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 2px;
}
.aside-history-top span:first-child { font-style: italic; color: var(--fg-dim); }
.aside-history-top span:last-child { font: 900 18px var(--font-head); font-variant-numeric: lining-nums; }

.aside-history-item a {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid rgba(28, 25, 19, 0.4);
}
.aside-history-item a:hover { border-bottom-color: var(--ink); }
.aside-history-item a.aside-npd-link { margin-left: 14px; }

/* «Мой налог»: чеки самозанятого */
.npd-hint { font-size: 14px; font-style: italic; color: var(--fg-dim); line-height: 1.45; margin-top: 10px; }
.npd-muted { font-size: 13px; font-style: italic; color: var(--fg-faint); margin-right: 8px; }
#report-history-tbody a { word-break: break-all; }
.npd-cell { min-width: 140px; }
.npd-cell a { color: var(--accent-text); text-decoration: none; border-bottom: 1px solid var(--accent-dim); margin-right: 8px; }
.npd-cell .btn-text { display: block; padding: 4px 0; font-size: 11.5px; }
.public-report-receipt {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
  padding: 9px 14px;
  border: 1px solid var(--ink);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
  transition: background-color 0.2s, color 0.2s;
}
.public-report-receipt:hover { background: var(--ink); color: var(--paper); }
.public-report-receipt .material-icons { font-size: 17px; }

@media (max-width: 900px) {
  .company-detail-main { --ledger-pad: 12px; }
  .company-detail-layout { flex-direction: column; }
  .company-detail-aside { width: 100%; }
  .aside-card { position: static; transform: none; }
}

/* Collapsible task groups (Оплачено / Отказались) */
.task-group-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  padding: 14px 0 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-dim);
  transition: color 0.2s;
}
.task-group-toggle:hover { color: var(--accent-text); }

.task-group-toggle .toggle-icon {
  transition: transform 0.2s;
  font-size: 19px;
}

.task-group-toggle.expanded .toggle-icon { transform: rotate(90deg); }

.task-group-table { margin-top: 8px; }

/* Task Table */
.task-table {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  border-collapse: collapse;
  font-variant-numeric: lining-nums tabular-nums;
}

.task-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  padding: 0 10px 12px;
  border-bottom: 1px solid var(--rule-strong);
}

.task-table td {
  padding: 14px 10px;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}

.task-title-cell { vertical-align: top; }

.task-table tbody tr:last-child td { border-bottom: none; }
.task-table tbody tr { transition: background-color 0.15s; }
.task-table tbody tr:hover { background: rgba(168, 146, 95, 0.04); }

.col-id { width: 56px; }
.col-time { width: 104px; white-space: nowrap; }
.col-deadline { width: 96px; }
.col-status { width: 128px; }
.col-actions { width: 70px; }

.task-deadline { font-size: 15px; color: var(--fg-dim); white-space: nowrap; }
.task-deadline.overdue { color: var(--red); font-weight: 700; }

.task-id-cell { font-size: 14px; color: var(--fg-faint); }

.task-actions-cell { padding: 8px 6px !important; }
.task-actions-inner { display: flex; align-items: center; justify-content: flex-end; gap: 0; }

.task-title-cell .task-title { word-break: break-word; }
.task-title-cell .task-title.done { color: var(--fg-dim); }

.task-description {
  font-size: 15px;
  font-style: italic;
  color: var(--fg-dim);
  margin-top: 2px;
  white-space: pre-wrap;
  word-break: break-word;
}

.task-extra {
  font-size: 14.5px;
  font-style: italic;
  color: var(--fg-dim);
  margin-top: 6px;
  padding-left: 10px;
  border-left: 2px solid var(--accent-dim);
  white-space: pre-wrap;
  word-break: break-word;
}

.task-time { font-size: 15px; color: var(--fg-dim); white-space: nowrap; }

.status-badge {
  --badge: var(--st-pending);
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--badge);
  border-bottom: 1px solid currentColor;
  padding-bottom: 1px;
  cursor: pointer;
}
.status-badge[data-status="done"] { --badge: var(--st-done); }
.status-badge[data-status="paid"] { --badge: var(--st-paid); }
.status-badge[data-status="postponed"] { --badge: var(--st-postponed); }
.status-badge[data-status="declined"] { --badge: var(--st-declined); }

.report-hint {
  max-width: 1080px;
  margin: 0 auto 22px;
  font-size: 14px;
  font-style: italic;
  color: var(--fg-faint);
}

/* Public Report Screen — чек клиенту как банкнота */
#public-report-screen { min-height: 100vh; background: var(--bg); }
.public-header { display: none; }
.public-content { padding: 60px 24px 72px; max-width: 760px; margin: 0 auto; }

.public-report-card {
  position: relative;
  padding: 34px 40px 38px;
  clip-path: polygon(var(--torn));
  background: radial-gradient(ellipse at center, rgba(255, 250, 232, 0.4), rgba(100, 78, 36, 0.22) 100%), var(--paper-grain), var(--paper);
}

.paper-masthead { margin-bottom: 20px; }
.paper-masthead-title {
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--guilloche) center / 680px auto, var(--paper-band);
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
}
.paper-masthead-title .engraved { font-size: 32px; letter-spacing: 0.12em; text-transform: uppercase; }
.paper-masthead-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-dim);
}

.public-report-card h1 {
  font: 900 30px/1.15 var(--font-head);
  font-variant-numeric: lining-nums;
  text-align: center;
  margin-bottom: 6px;
}
.public-report-meta {
  display: flex;
  justify-content: center;
  gap: 20px;
  font-style: italic;
  color: var(--fg-dim);
  margin-bottom: 24px;
}

.public-report-card .task-table { border-top: 2px solid var(--ink); }
.public-report-card .task-table th { padding-top: 10px; }
.public-report-card .task-table tbody tr:hover { background: transparent; }
.public-report-card .status-badge { cursor: default; }

.public-report-summary {
  display: flex;
  justify-content: flex-end;
  align-items: baseline;
  gap: 32px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 2px solid var(--ink);
  color: var(--fg-dim);
}
.public-report-summary b { color: var(--ink); }
.public-report-summary .engraved { font-size: 42px; color: transparent; }

.not-found {
  padding: 120px 24px;
  text-align: center;
  font-style: italic;
  font-size: 20px;
  color: var(--fg-dim);
}

/* Меню статуса — клочок бумаги */
.status-menu {
  position: absolute;
  min-width: 200px;
  padding: 8px 0;
  clip-path: polygon(var(--torn));
  z-index: 400;
}
.status-menu button {
  width: 100%;
  text-align: left;
  padding: 9px 18px;
  border: none;
  background: none;
  color: var(--fg);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
}
.status-menu button:hover { background: rgba(28, 25, 19, 0.08); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.status-dot.pending { background: var(--st-pending); }
.status-dot.done { background: var(--st-done); }
.status-dot.paid { background: var(--st-paid); }
.status-dot.postponed { background: var(--st-postponed); }
.status-dot.declined { background: var(--st-declined); }

/* Add task inline form */
.add-task-bar {
  max-width: 1080px;
  margin: 0 auto 20px;
}

/* Report: сумма к оплате — номинал в гравированной прорехе */
.report-summary {
  max-width: 1080px;
  margin: 0 auto 18px;
  display: grid;
  grid-template-columns: auto auto 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 44px;
  row-gap: 22px;
}
.report-stat { display: flex; flex-direction: column; gap: 4px; }
.report-stat .label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-dim);
}
.report-stat .value { font-size: 34px; line-height: 1.1; }

.report-summary .report-stat:nth-child(3) {
  grid-column: 3;
  grid-row: 1 / span 2;
  justify-self: end;
  width: min(380px, 100%);
  height: 150px;
  align-items: center;
  justify-content: center;
  gap: 0;
  clip-path: polygon(var(--slit));
  background:
    radial-gradient(ellipse at center, rgba(255, 248, 225, 0.35), rgba(90, 70, 30, 0.35) 100%),
    var(--guilloche) center / 760px auto,
    #cfc29d;
}
.report-summary .report-stat:nth-child(3) .label { color: #2a2214; letter-spacing: 0.2em; }
.report-summary .report-stat:nth-child(3) .value {
  font-family: var(--font-head);
  font-weight: 900;
  font-size: 52px;
  line-height: 1.05;
  background: repeating-linear-gradient(0deg, #2a2214 0 1.2px, rgba(42, 34, 20, 0.55) 1.2px 2.6px);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-stroke: 0.6px #2a2214;
}
#generate-report-btn { grid-column: 1 / span 2; justify-self: start; }

.report-filters {
  max-width: 1080px;
  margin: 0 auto 26px;
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  color: var(--fg-dim);
}
.report-filters label {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
}
#report-rate {
  width: 90px;
  padding: 3px 0;
  background: transparent;
  color: var(--fg);
  border: none;
  border-bottom: 1px solid var(--rule-strong);
  font: 15px var(--font-text);
  outline: none;
}
#report-rate:focus { border-color: var(--accent); }

.report-history-header { margin-top: 44px; margin-bottom: 14px; }
.report-history-header h2 { font-size: 16px; }

/* Toast — полоска бумаги */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  padding: 14px 26px;
  clip-path: polygon(var(--torn));
  font-size: 15px;
  z-index: 500;
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar { width: 64px; }
  .sidebar .nav-text { display: none; }
  .nav-item { justify-content: center; padding: 12px 0; }
  .nav-item .material-icons { display: block; }
  .nav-divider { margin: 12px 16px; }
  .content { margin-left: 64px; padding: 24px 16px 40px; }
  .header-title { display: none; }
  .content-header h2 { letter-spacing: 0.24em; }
  /* Кнопки карточки появляются по наведению, которого на телефоне нет */
  .company-card .company-name-row { padding-right: 0; }
  .report-summary { grid-template-columns: auto auto; }
  .report-summary .report-stat:nth-child(3) { grid-column: 1 / -1; grid-row: auto; justify-self: stretch; width: auto; }
  #generate-report-btn { grid-column: 1 / -1; }
}

/* Public report — mobile */
@media (max-width: 640px) {
  .public-content { padding: 32px 10px 40px; }

  .public-report-card { padding: 26px 18px 30px; }
  .paper-masthead-title { height: 70px; }
  .paper-masthead-title .engraved { font-size: 22px; letter-spacing: 0.08em; }
  .paper-masthead-line { font-size: 9.5px; letter-spacing: 0.14em; }
  .public-report-card h1 { font-size: 23px; }

  .public-report-meta {
    flex-direction: column;
    align-items: center;
    gap: 0;
    margin-bottom: 18px;
  }

  /* Таблица превращается в карточки задач */
  .public-report-card .task-table,
  .public-report-card .task-table tbody {
    display: block;
    border: none;
  }
  .public-report-card .task-table thead { display: none; }

  .public-report-card .task-table tr {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "id     status"
      "title  title"
      "time   time";
    gap: 4px 12px;
    padding: 12px 2px;
    border-bottom: 1px dotted rgba(28, 25, 19, 0.45);
  }
  .public-report-card .task-table tr:first-child { border-top: 2px solid var(--ink); }

  .public-report-card .task-table td {
    display: block;
    padding: 0;
    border: none;
  }
  .public-report-card .task-table tbody tr:last-child td { border: none; }

  .public-report-card .task-id-cell { grid-area: id; align-self: center; }
  .public-report-card .task-title-cell { grid-area: title; }
  .public-report-card .task-time { grid-area: time; }
  .public-report-card td:last-child { grid-area: status; text-align: right; }

  /* Дедлайн на мобильных не показываем */
  .public-report-card .task-table td.task-deadline { display: none; }

  .public-report-card .task-time::before {
    content: 'schedule';
    font-family: 'Material Icons';
    font-size: 14px;
    vertical-align: -2px;
    margin-right: 4px;
    font-style: normal;
  }

  /* Итоги — колонкой, сумма крупнее */
  .public-report-summary {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  .public-report-summary span {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
  }
  .public-report-summary .engraved { font-size: 36px; }
}
