:root {
  font-family: Aptos, Inter, "Segoe UI", sans-serif;
  color-scheme: light;
  accent-color: var(--accent);
  --canvas: #ECE7DD;
  --shell: rgba(246, 242, 234, 0.98);
  --panel: #FFFDF8;
  --panel-strong: #FFFDF8;
  --panel-muted: #F6F1E7;
  --line: #DED3C2;
  --line-strong: #C9A24C;
  --text: #201D18;
  --text-muted: #63594C;
  --text-faint: #968A78;
  --accent: #9B7438;
  --accent-soft: #EFE2C8;
  --accent-hover: #B78D34;
  --success: #667B58;
  --warning: #A36F2E;
  --danger: #A65B53;
  --btn-text: #111111;
  --btn-fill: linear-gradient(180deg, #C9A24C, #B78D34);
  --radius-card: 22px;
  --radius-panel: 18px;
  --radius-btn: 20px;
  --radius-badge: 999px;
  --shadow-soft: 0 16px 34px rgba(62, 49, 31, 0.12);
  --topbar-bg: linear-gradient(180deg, rgba(255, 252, 245, 0.98), rgba(244, 238, 228, 0.94));
  --dock-fade: linear-gradient(180deg, transparent, rgba(246, 241, 231, 0.96) 28%);
  --background-app:
    radial-gradient(circle at top left, rgba(184, 142, 76, 0.18), rgba(184, 142, 76, 0) 24%),
    radial-gradient(circle at top center, rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0) 22%),
    linear-gradient(180deg, #F6F1E8 0%, #EFE8DC 48%, #E8DFD1 100%);
  --focus-ring: 0 0 0 3px rgba(183, 141, 52, 0.12);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #090909;
  --shell: rgba(14, 13, 12, 0.98);
  --panel: rgba(24, 23, 21, 0.94);
  --panel-strong: rgba(22, 21, 19, 0.98);
  --panel-muted: rgba(28, 26, 24, 0.97);
  --line: rgba(152, 146, 136, 0.38);
  --line-strong: rgba(178, 170, 156, 0.52);
  --text: #F2EDE4;
  --text-muted: #B3A693;
  --text-faint: #796D5F;
  --accent: #C29A57;
  --accent-soft: rgba(194, 154, 87, 0.12);
  --accent-hover: #D4AE6A;
  --success: #93A783;
  --warning: #C19860;
  --danger: #C47B72;
  --btn-text: #0D0F14;
  --btn-fill: #C29A57;
  --shadow-soft: 0 18px 42px rgba(0, 0, 0, 0.38);
  --topbar-bg: linear-gradient(180deg, rgba(17, 16, 15, 0.98), rgba(11, 11, 11, 0.92));
  --dock-fade: linear-gradient(180deg, transparent, rgba(9, 9, 9, 0.96) 28%);
  --background-app:
    radial-gradient(circle at top left, rgba(194, 154, 87, 0.1), rgba(194, 154, 87, 0) 22%),
    radial-gradient(circle at top center, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0) 18%),
    linear-gradient(180deg, #090909 0%, #0D0C0B 42%, #11100F 100%);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

html {
  background-color: var(--canvas);
  background-image: var(--background-app);
  background-attachment: fixed;
  scroll-padding-bottom: 110px;
}

body {
  font-family: Aptos, Inter, "Segoe UI", sans-serif;
  font-weight: 400;
  color: var(--text);
  background: transparent;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .hero h1, .add-title, .login h1, .empty h2, .stat b, .phone {
  font-family: Manrope, Aptos, Inter, "Segoe UI", sans-serif;
  font-weight: 700;
}

a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button, summary { cursor: pointer; }

input::placeholder,
textarea::placeholder {
  color: var(--text-faint);
}

::selection {
  background: rgba(194, 154, 87, 0.22);
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--canvas); }
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: var(--radius-badge);
}

:where(button, summary, [role="button"], input, select, textarea, a[href]):focus-visible {
  outline: none;
  border-color: var(--line-strong);
  box-shadow: var(--focus-ring);
}

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(16px);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--line);
}
.top-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
}
.top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  min-height: 72px;
}
.brand {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  text-decoration: none;
  color: inherit;
}
.brand-logo {
  display: block;
  height: 40px;
  width: auto;
  max-width: 200px;
  object-fit: contain;
  object-position: left center;
  background: transparent;
  border: 0;
}
html[data-theme="light"] .brand-logo--dark,
html:not([data-theme]) .brand-logo--dark,
html[data-theme="dark"] .brand-logo--light { display: none !important; }
.kicker {
  display: block;
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.theme-switch {
  display: inline-flex;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--panel-muted);
  border-radius: var(--radius-badge);
  padding: 3px;
  gap: 2px;
}
.theme-opt {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-badge);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.theme-opt.is-on {
  background: var(--panel-strong);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line);
}
.theme-opt:hover:not(.is-on) { color: var(--text); }
.login-tools {
  position: absolute;
  top: 18px;
  right: 18px;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex: 0 1 auto;
}
.nav {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: nowrap;
}
.nav a, .ghost-nav {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.nav a:hover, .ghost-nav:hover {
  background: var(--panel-muted);
  color: var(--text);
}
.nav a.is-on {
  background: var(--accent-soft);
  color: var(--text);
  box-shadow: none;
}

.shell {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 18px 120px;
}
.shell-director { max-width: 960px; }

.hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  margin: 8px 0 22px;
  animation: rise 0.5s ease both;
}
.hero h1 {
  margin: 6px 0 0;
  font-size: clamp(44px, 9vw, 64px);
  line-height: 0.9;
  letter-spacing: -0.05em;
}
.hero p { margin: 8px 0 0; color: var(--text-muted); font-weight: 400; }
.hero-side { text-align: right; color: var(--text-muted); font-size: 13px; font-weight: 400; }
.hero-side a { font-weight: 600; }
.count-live { color: var(--warning); }
.count-ok { color: var(--success); }

.flash, .err, .note {
  padding: 12px 14px;
  border-radius: var(--radius-panel);
  margin-bottom: 14px;
  border: 1px solid var(--line);
  animation: rise 0.4s ease both;
}
.flash {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(194, 154, 87, 0.35);
}
.err {
  background: rgba(196, 123, 114, 0.14);
  color: var(--danger);
  border-color: rgba(196, 123, 114, 0.35);
}
.note {
  background: rgba(147, 167, 131, 0.14);
  color: var(--success);
  border-color: rgba(147, 167, 131, 0.35);
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 16px 16px 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-soft);
  animation: rise 0.45s ease both;
}
.card:hover { box-shadow: var(--shadow-soft); }
.card-static:hover { box-shadow: var(--shadow-soft); }
.card-priority { border-left: 4px solid var(--accent); }
.card-hot {
  background:
    linear-gradient(180deg, rgba(194, 154, 87, 0.1), rgba(194, 154, 87, 0) 42%),
    var(--panel);
}
.card-done { opacity: 0.72; }

.meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}
.phone {
  font-size: 1.45rem;
  letter-spacing: -0.03em;
  color: inherit;
  text-decoration: none;
}
.phone:hover { color: var(--accent-hover); }
.phone-private {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.phone-private-number {
  display: inline-block;
  width: min(210px, 55vw);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.phone-private [hidden] { display: none !important; }
.phone-reveal {
  display: inline-grid;
  place-items: center;
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
}
.phone-reveal:hover,
.phone-reveal[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent);
}
.phone-reveal svg { width: 17px; height: 17px; }
.wait {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: var(--radius-badge);
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(194, 154, 87, 0.35);
  white-space: nowrap;
}
.wait-hot {
  background: rgba(193, 152, 96, 0.14);
  color: var(--warning);
  border-color: rgba(193, 152, 96, 0.35);
}
.tags { display: flex; gap: 6px; margin: 8px 0 0; flex-wrap: wrap; }
.tag {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: var(--radius-badge);
  background: var(--panel-muted);
  color: var(--text-muted);
  border: 1px solid var(--line);
}
.tag-priority { background: var(--accent-soft); color: var(--accent); border-color: rgba(194, 154, 87, 0.35); }
.tag-handed {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--line-strong);
}
.vk-state { display: inline-block; margin-top: 8px; }
.vk-state[data-vk-state="connected"] { color: var(--success); border-color: var(--success); }
.vk-state[data-vk-state="error"] { color: var(--danger); border-color: var(--danger); }

.btns {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}
.btns form { margin: 0; }

.btns button, .btn, button.primary, button.secondary, button.ghost {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-btn);
  padding: 13px 10px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.16s ease, background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}
button.primary {
  background: var(--btn-fill);
  border-color: var(--line-strong);
  color: var(--btn-text);
}
button.primary:hover { opacity: 0.9; }
button.secondary, button.ghost {
  background: var(--panel);
  color: var(--text);
  border-color: var(--line);
}
button.secondary:hover, button.ghost:hover {
  border-color: var(--line-strong);
  background: var(--panel-strong);
}
button:active { transform: none; }

.add { display: grid; gap: 10px; }
.add-title {
  display: flex;
  align-items: center;
  margin: 0 0 4px;
  letter-spacing: -0.02em;
}
.add p { margin: 0 0 10px; color: var(--text-muted); font-size: 14px; }
select option {
  background: var(--canvas);
  color: var(--text);
}

.add input, .add select, textarea, .field, .login input, .date-bar input {
  width: 100%;
  padding: 13px 14px;
  border-radius: var(--radius-panel);
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--text);
}
.add input:focus, .add select:focus, textarea:focus, .field:focus,
.login input:focus, .date-bar input:focus {
  outline: none;
  border-color: var(--line-strong);
  box-shadow: var(--focus-ring);
}
.row2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 8px; }

.dock {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: 12px 18px 18px;
  background: var(--dock-fade);
}
.dock form, .dock > button { max-width: 640px; margin: 0 auto; display: block; }
.dock button { width: 100%; padding: 16px; border-radius: var(--radius-btn); font-size: 16px; }

.empty {
  text-align: center;
  padding: 42px 16px;
  color: var(--text-muted);
}
.empty-orb {
  width: 72px; height: 72px; margin: 0 auto 12px;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 1px solid rgba(194, 154, 87, 0.35);
  box-shadow: inset 0 0 0 8px var(--panel-strong);
}
.empty h2 { margin: 0 0 6px; color: var(--text); }

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 8px 0 20px;
}
.stats-director { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 16px;
  box-shadow: var(--shadow-soft);
  animation: rise 0.45s ease both;
}
.stat b { display: block; font-size: 2rem; letter-spacing: -0.05em; }
.stat span { display: block; color: var(--text); font-size: 14px; font-weight: 700; }
.stat small { display: block; margin-top: 6px; color: var(--text-muted); font-size: 12px; line-height: 1.35; }
.stat-ok b { color: var(--success); }
.stat-warn b { color: var(--warning); }

.page-title {
  margin: 6px 0 14px;
  font-size: clamp(30px, 7vw, 42px);
  line-height: 1.05;
  letter-spacing: -0.045em;
}
.section-title {
  margin: 24px 0 10px;
  font-size: 1rem;
  letter-spacing: -0.01em;
}
.handoff-summary {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin: 0 0 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--panel-muted);
}
.handoff-summary strong { font-size: 14px; }
.handoff-summary span { color: var(--text-muted); font-size: 13px; text-align: right; }

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.table th, .table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.table th {
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: var(--accent-soft);
}
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--accent-soft); }

.check {
  display: flex;
  gap: 10px;
  align-items: center;
  font-weight: 600;
  padding: 12px;
  border-radius: var(--radius-panel);
  background: var(--panel-muted);
  border: 1px solid var(--line);
}
.check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
}
.login {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 28px 24px 24px;
  box-shadow: var(--shadow-soft);
  animation: rise 0.5s ease both;
}
.login .brand-logo {
  height: 40px;
  width: auto;
  max-width: min(200px, 48vw);
  display: block;
}
.login h1 { margin: 16px 0 4px; letter-spacing: -0.04em; }
.login p { color: var(--text-muted); margin: 0 0 18px; }
.login label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 12px 0 6px;
}
.login button { margin-top: 16px; width: 100%; padding: 14px; }
.role-choice {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 16px 0 14px;
}
.role-option {
  position: relative;
  display: flex !important;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin: 0 !important;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--panel-muted);
  color: var(--text-muted) !important;
  font-size: 14px !important;
  letter-spacing: 0 !important;
  text-transform: none !important;
  line-height: 1;
  cursor: pointer;
  user-select: none;
}
.role-option:has(input:checked) {
  border-color: var(--line-strong);
  background: var(--accent-soft);
  color: var(--text) !important;
}
.role-option input {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100%;
  padding: 0;
  opacity: 0;
  cursor: pointer;
}
.role-option span {
  display: block;
  width: 100%;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.login-back {
  display: block;
  margin-top: 14px;
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
}
.login-back:hover { color: var(--accent); }

.date-bar { display: flex; gap: 8px; margin: 0 0 8px; }
.date-bar input, .date-bar button {
  border-radius: var(--radius-panel);
  border: 1px solid var(--line);
  background: var(--panel-strong);
  padding: 8px 10px;
  color: var(--text);
}
.date-bar button {
  background: var(--panel);
  font-weight: 600;
  cursor: pointer;
}
.date-bar button:hover {
  border-color: var(--line-strong);
  background: var(--panel-muted);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.hint {
  margin: 6px 0 12px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 400;
}
.field-label {
  display: block;
  margin: 0 0 6px;
  font-weight: 600;
}
.handoff {
  list-style: none;
  margin: 0;
  padding: 0;
}
.handoff li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}
.handoff li:last-child { border-bottom: 0; }
.step-n {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--btn-text);
  font-size: 13px;
  font-weight: 700;
  margin-right: 8px;
}
.memo {
  margin-top: 16px;
  padding: 16px;
  border-radius: var(--radius-card);
  background: var(--accent-soft);
  border: 1px solid rgba(194, 154, 87, 0.35);
}
.memo p { margin: 0; }
.shell-close { padding-bottom: 120px; }
textarea {
  min-height: 110px;
  resize: vertical;
}
.handoff .wait { flex-shrink: 0; }
.filter-link { margin-top: 8px; }

.month-report {
  margin-top: 36px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}
.month-report-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}
.month-report .section-title { margin: 4px 0 0; }
.month-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}
.month-legend span { display: inline-flex; align-items: center; gap: 6px; }
.month-legend i { width: 10px; height: 10px; border-radius: 3px; }
.legend-closed, .month-bar-closed { background: var(--success); }
.legend-open, .month-bar-open { background: var(--warning); }
.month-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 22px 0 20px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.month-summary > div {
  min-width: 0;
  padding: 14px 16px;
  border-right: 1px solid var(--line);
}
.month-summary > div:first-child { padding-left: 0; }
.month-summary > div:last-child { padding-right: 0; border-right: 0; }
.month-summary b {
  display: block;
  font-family: Manrope, Aptos, Inter, "Segoe UI", sans-serif;
  font-size: 1.35rem;
}
.month-summary span { color: var(--text-muted); font-size: 12px; }
.month-chart-scroll { overflow-x: auto; padding-bottom: 6px; }
.month-chart {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(18px, 1fr);
  gap: 7px;
  min-width: 760px;
  height: 220px;
  padding: 0 2px;
  border-bottom: 1px solid var(--line);
}
.month-day {
  display: grid;
  grid-template-rows: 20px 174px 25px;
  align-items: end;
  min-width: 0;
  text-align: center;
}
.month-total { color: var(--text-muted); font-size: 10px; line-height: 20px; }
.month-bar-slot { display: flex; align-items: flex-end; justify-content: center; height: 174px; }
.month-bar {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  width: 14px;
  height: var(--bar-height);
  min-height: 0;
  overflow: hidden;
  border-radius: 4px 4px 0 0;
  background: var(--panel-muted);
}
.month-bar > span { display: block; flex: 0 0 var(--segment); width: 100%; }
.month-day-label { color: var(--text-faint); font-size: 10px; line-height: 25px; }

@media (max-width: 720px) {
  .top-inner { padding: 10px 16px 12px; }
  .top-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    min-height: 0;
  }
  .top-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }
  .brand-logo { height: 34px; max-width: 168px; }
}
@media (max-width: 520px) {
  .btns { grid-template-columns: 1fr; }
  .row2 { grid-template-columns: 1fr; }
  .handoff li { flex-direction: column; align-items: flex-start; }
  .stats-director { grid-template-columns: 1fr; }
  .handoff-summary { align-items: flex-start; flex-direction: column; gap: 4px; }
  .handoff-summary span { text-align: left; }
  .add button { scroll-margin-bottom: 110px; }
  .month-report-head { align-items: flex-start; flex-direction: column; }
  .month-legend { justify-content: flex-start; }
  .month-summary { grid-template-columns: 1fr 1fr; }
  .month-summary > div { padding: 12px 10px; border-bottom: 1px solid var(--line); }
  .month-summary > div:nth-child(2) { border-right: 0; }
  .month-summary > div:nth-child(3),
  .month-summary > div:nth-child(4) { border-bottom: 0; }
  .month-summary > div:first-child { padding-left: 10px; }
  .month-summary > div:last-child { padding-right: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
