:root {
  --ink: #17221d;
  --muted: #69746f;
  --canvas: #f3f5f2;
  --surface: #ffffff;
  --line: #dfe5e1;
  --forest: #123d2c;
  --forest-2: #1f5b43;
  --mint: #dff5e8;
  --green: #168454;
  --amber: #b66a0b;
  --red: #c43d3d;
  --blue: #2f6fbd;
  --shadow: 0 12px 30px rgba(21, 48, 36, .07);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body { margin: 0; color: var(--ink); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
button, a, select, input { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }

.app-body { background: var(--canvas); }
.app-layout { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 28px 18px 18px; display: flex; flex-direction: column; color: #f5fbf8; background: var(--forest); }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 28px; letter-spacing: .02em; }
.brand > span:last-child { display: flex; flex-direction: column; line-height: 1.05; }
.brand small { color: #95b3a5; font-size: 10px; letter-spacing: .28em; margin-top: 5px; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 13px; color: var(--forest); background: #b9ebce; font-size: 14px; font-weight: 900; letter-spacing: -.04em; }
.brand-mark--large { width: 64px; height: 64px; border-radius: 20px; font-size: 19px; box-shadow: 0 12px 28px rgba(0,0,0,.18); }
.nav { display: grid; gap: 7px; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 12px 14px; color: #bdcec6; border-radius: 12px; font-size: 14px; font-weight: 650; transition: .18s ease; }
.nav-link span { width: 22px; text-align: center; font-size: 18px; }
.nav-link:hover, .nav-link.is-active { color: #fff; background: rgba(255,255,255,.11); }
.nav-link.is-active { box-shadow: inset 3px 0 #8bddae; }
.sidebar-note { margin-top: auto; display: flex; gap: 10px; padding: 15px; border: 1px solid rgba(255,255,255,.1); border-radius: 14px; background: rgba(0,0,0,.09); }
.sidebar-note p { margin: 0; color: #b6c9c0; font-size: 11px; line-height: 1.5; }
.sidebar-note b { color: #eff8f3; }
.live-dot { width: 8px; height: 8px; margin-top: 4px; flex: 0 0 auto; border-radius: 50%; background: #58dc91; box-shadow: 0 0 0 5px rgba(88,220,145,.12); }
.user-card { margin-top: 13px; display: grid; grid-template-columns: 36px 1fr 32px; gap: 10px; align-items: center; padding: 11px; border-radius: 14px; background: rgba(255,255,255,.07); }
.avatar { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: #dff5e8; color: var(--forest); font-weight: 800; }
.user-card b, .user-card small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-card b { font-size: 12px; }
.user-card small { color: #99b1a6; font-size: 10px; text-transform: capitalize; margin-top: 3px; }
.icon-button { border: 0; width: 32px; height: 32px; border-radius: 9px; color: #d7e5de; background: transparent; cursor: pointer; }
.icon-button:hover { background: rgba(255,255,255,.1); }

.content { min-width: 0; padding: 38px clamp(22px, 4vw, 58px) 60px; }
.page-header { display: flex; justify-content: space-between; gap: 24px; align-items: flex-end; margin-bottom: 26px; }
.eyebrow { margin: 0 0 8px; color: var(--green); font-size: 11px; font-weight: 850; letter-spacing: .16em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(28px, 3.2vw, 42px); letter-spacing: -.045em; line-height: 1.05; }
.subtitle { margin: 10px 0 0; color: var(--muted); font-size: 14px; }
.button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 16px; border: 1px solid transparent; border-radius: 11px; cursor: pointer; font-weight: 750; font-size: 13px; transition: transform .14s ease, box-shadow .14s ease, background .14s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .58; cursor: wait; transform: none; }
.button--primary { color: #fff; background: var(--forest-2); box-shadow: 0 7px 18px rgba(20, 75, 51, .15); }
.button--primary:hover { background: var(--forest); }
.button--secondary { color: var(--ink); border-color: var(--line); background: #fff; }
.button--small { min-height: 36px; padding-inline: 12px; }
.export-button { min-width: 160px; }

.stats-grid { display: grid; grid-template-columns: repeat(5, minmax(135px, 1fr)); gap: 13px; margin-bottom: 18px; }
.stat-card { min-width: 0; display: flex; align-items: center; gap: 13px; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: 0 6px 18px rgba(34,55,44,.035); }
.stat-card small, .stat-card strong { display: block; }
.stat-card small { color: var(--muted); font-size: 11px; white-space: nowrap; }
.stat-card strong { margin-top: 3px; font-size: 25px; letter-spacing: -.04em; }
.stat-icon { width: 36px; height: 36px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 11px; font-weight: 900; }
.stat-card--total .stat-icon { color: var(--forest); background: #edf1ee; }
.stat-card--success .stat-icon { color: var(--green); background: #e1f6e9; }
.stat-card--work .stat-icon { color: var(--blue); background: #e8f0fb; }
.stat-card--danger .stat-icon { color: var(--red); background: #fbe9e8; }
.stat-card--overdue .stat-icon { color: var(--amber); background: #fff0d9; }

.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.filter-panel { margin-bottom: 18px; padding: 18px; }
.filters { display: grid; grid-template-columns: minmax(210px, 1.35fr) repeat(3, minmax(145px, 1fr)) auto; gap: 12px; align-items: end; }
.filters label { min-width: 0; }
.field-label { display: block; margin: 0 0 7px 2px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
input, select { width: 100%; height: 42px; border: 1px solid #d8dfdb; border-radius: 10px; outline: none; color: var(--ink); background: #fbfcfb; }
input { padding: 0 12px; }
select { padding: 0 34px 0 11px; cursor: pointer; }
input:focus, select:focus { border-color: #65a284; box-shadow: 0 0 0 3px rgba(54,135,94,.1); background: #fff; }
.input-with-icon { position: relative; display: block; }
.input-with-icon > span { position: absolute; left: 13px; top: 9px; color: #7c8882; font-size: 19px; }
.input-with-icon input { padding-left: 38px; }
.filter-button { min-width: 96px; }

.reports-panel { overflow: hidden; }
.table-toolbar { min-height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 17px 20px; border-bottom: 1px solid var(--line); }
.table-toolbar h2 { margin: 0; font-size: 18px; letter-spacing: -.02em; }
.table-toolbar p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.bulk-controls { display: flex; gap: 10px; align-items: center; }
.bulk-controls > span { color: var(--muted); font-size: 12px; font-weight: 700; }
.bulk-controls select { width: 150px; height: 36px; font-size: 12px; }
.is-hidden { display: none !important; }
.table-scroll { overflow-x: auto; }
.reports-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.reports-table th { padding: 11px 12px; text-align: left; color: #7a8580; background: #f8faf8; border-bottom: 1px solid var(--line); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.reports-table td { padding: 15px 12px; vertical-align: middle; border-bottom: 1px solid #edf0ee; font-size: 12px; }
.reports-table tbody tr { transition: background .12s ease; }
.reports-table tbody tr:hover { background: #fbfdfb; }
.reports-table tbody tr.is-selected { background: #f0f8f3; }
.reports-table tbody tr:last-child td { border-bottom: 0; }
.reports-table th:nth-child(2) { width: 20%; }
.reports-table th:nth-child(3) { width: 26%; }
.reports-table th:nth-child(4) { width: 13%; }
.reports-table th:nth-child(5) { width: 12%; }
.reports-table th:nth-child(6) { width: 245px; }
.checkbox-cell { width: 44px !important; text-align: center !important; }
.checkbox-cell input { width: 16px; height: 16px; accent-color: var(--green); cursor: pointer; }
.org-name, .report-name { display: block; line-height: 1.35; }
.reports-table small { display: block; margin-top: 5px; color: var(--muted); line-height: 1.35; }
.report-code { display: inline-block; margin-bottom: 5px; padding: 3px 6px; color: #456054; background: #edf2ef; border-radius: 6px; font-size: 9px; font-weight: 850; letter-spacing: .06em; }
.deadline.is-late { color: var(--red); font-weight: 700; }
.status-badge { display: inline-flex; align-items: center; min-height: 28px; padding: 5px 9px; border-radius: 999px; font-size: 10px; font-weight: 800; white-space: nowrap; }
.status--accepted { color: #12663f; background: #ddf4e6; }
.status--submitted, .status--review { color: #275e9c; background: #e4eefb; }
.status--not_submitted, .status--no_deadline { color: #5d6762; background: #edf0ee; }
.status--overdue, .status--rejected, .status--need_info { color: #a72e2e; background: #fbe5e4; }
.status--not_required, .status--cancelled { color: #7b6a3a; background: #f4efdf; }
.row-actions { display: flex; align-items: center; gap: 6px; }
.quick-action { min-height: 34px; padding: 0 10px; border-radius: 9px; background: #fff; cursor: pointer; font-size: 10px; font-weight: 850; white-space: nowrap; }
.quick-action--yes { color: #157348; border: 1px solid #9bd2b4; }
.quick-action--yes:hover { color: #fff; background: var(--green); border-color: var(--green); }
.quick-action--no { color: #ad3535; border: 1px solid #e4abab; }
.quick-action--no:hover { color: #fff; background: var(--red); border-color: var(--red); }
.more-status { width: 75px; height: 34px; padding-left: 7px; font-size: 10px; }
.empty-state { min-height: 320px; display: grid; place-content: center; text-align: center; padding: 40px; }
.empty-state > span { color: #a8b5ae; font-size: 46px; }
.empty-state h3 { margin: 12px 0 5px; }
.empty-state p { margin: 0; color: var(--muted); font-size: 13px; }
.pagination { min-height: 68px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 15px; padding: 13px 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.pagination > :last-child { justify-self: end; }

.toast { position: fixed; z-index: 50; right: 24px; bottom: 24px; max-width: min(390px, calc(100vw - 32px)); padding: 13px 16px; color: #fff; background: var(--forest); border-radius: 12px; box-shadow: 0 16px 40px rgba(8,38,24,.25); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; font-size: 12px; font-weight: 700; }
.toast.is-visible { opacity: 1; transform: none; }
.toast.is-error { background: #9f3030; }

/* Авторизация */
.login-body { min-height: 100vh; color: #fff; background: var(--forest); }
.login-body::before { content: ""; position: fixed; inset: 0; pointer-events: none; background: radial-gradient(circle at 18% 20%, rgba(103,196,145,.17), transparent 30%), linear-gradient(135deg, rgba(255,255,255,.03), transparent 45%); }
.login-shell { position: relative; min-height: 100vh; width: min(1060px, calc(100% - 40px)); margin: auto; display: grid; grid-template-columns: 1.15fr .85fr; align-items: center; gap: clamp(42px, 8vw, 100px); padding: 60px 0; }
.login-brand h1 { max-width: 620px; margin: 18px 0 20px; font-size: clamp(42px, 6vw, 72px); letter-spacing: -.06em; }
.login-brand .eyebrow { margin-top: 25px; color: #8fd9ad; }
.login-lead { max-width: 530px; margin: 0; color: #bad0c5; font-size: 17px; line-height: 1.65; }
.login-points { max-width: 540px; display: grid; gap: 13px; margin-top: 36px; }
.login-points > div { display: grid; grid-template-columns: 40px 1fr; gap: 13px; align-items: start; }
.login-points span { color: #7fd09f; font-size: 11px; font-weight: 900; letter-spacing: .1em; }
.login-points p { margin: 0; color: #9fb9ad; font-size: 12px; line-height: 1.5; }
.login-points b { color: #eef7f2; }
.login-card { padding: clamp(28px, 4vw, 42px); color: var(--ink); background: #fff; border-radius: 24px; box-shadow: 0 30px 80px rgba(0,0,0,.24); }
.secure-pill { display: inline-flex; padding: 6px 9px; color: #136d43; background: #e2f5e9; border-radius: 999px; font-size: 9px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.login-card h2 { margin: 19px 0 9px; font-size: 28px; letter-spacing: -.04em; }
.login-card__top > p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.telegram-only { display: flex; align-items: center; gap: 13px; margin: 27px 0 20px; padding: 15px; border: 1px solid #d7e8de; border-radius: 13px; background: #f3faf6; }
.telegram-only__icon { width: 42px; height: 42px; display: grid; place-items: center; flex: 0 0 auto; color: #fff; background: #2788c7; border-radius: 50%; font-size: 11px; font-weight: 900; }
.telegram-only b { display: block; font-size: 12px; }
.telegram-only p { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.telegram-only a { color: #1776af; font-weight: 800; }
.login-note { margin: 0; padding-top: 18px; border-top: 1px solid var(--line); color: #829087; text-align: center; font-size: 10px; line-height: 1.5; }
.alert { margin-top: 18px; padding: 11px 13px; border-radius: 10px; font-size: 11px; line-height: 1.45; }
.alert--error { color: #932e2e; border: 1px solid #f0c6c4; background: #fcebea; }
.login-progress { margin: 24px 0 10px; display: flex; justify-content: center; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.spinner { width: 17px; height: 17px; border: 2px solid #d5dfd9; border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.dev-login { margin: 18px 0; padding: 13px; text-align: center; background: #f5f7f5; border-radius: 11px; }
.dev-login p { margin: 0 0 9px; color: var(--muted); font-size: 10px; }

@media (max-width: 1180px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-button { width: 100%; }
  .reports-table { min-width: 1020px; }
}

@media (max-width: 780px) {
  .app-layout { display: block; }
  .sidebar { position: static; width: auto; height: auto; padding: 14px 16px; flex-direction: row; align-items: center; gap: 12px; }
  .brand { padding: 0; }
  .brand > span:last-child, .sidebar-note { display: none; }
  .nav { display: flex; flex: 1; }
  .nav-link { padding: 9px 10px; font-size: 11px; }
  .nav-link span { width: auto; }
  .user-card { margin: 0; padding: 7px; background: transparent; grid-template-columns: 32px 32px; }
  .user-card .avatar { width: 32px; height: 32px; }
  .user-card > div:nth-child(2) { display: none; }
  .content { padding: 24px 14px 45px; }
  .page-header { align-items: center; }
  .page-header h1 { font-size: 29px; }
  .export-button { min-width: 44px; width: 44px; padding: 0; font-size: 0; }
  .export-button span { font-size: 18px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-card { padding: 13px; }
  .stat-card--total { grid-column: span 2; }
  .filters { grid-template-columns: 1fr; }
  .table-toolbar { align-items: flex-start; flex-direction: column; }
  .bulk-controls { width: 100%; flex-wrap: wrap; }
  .bulk-controls > span { width: 100%; }
  .bulk-controls select { flex: 1; }
  .table-scroll { overflow: visible; }
  .reports-table, .reports-table tbody { display: block; }
  .reports-table thead { display: none; }
  .reports-table { min-width: 0; }
  .reports-table tr { position: relative; display: grid; grid-template-columns: 1fr 1fr; padding: 18px 14px; border-bottom: 1px solid var(--line); }
  .reports-table td { display: block; padding: 8px; border: 0; }
  .reports-table td::before { content: attr(data-label); display: block; margin-bottom: 6px; color: #8b9690; font-size: 8px; font-weight: 850; letter-spacing: .09em; text-transform: uppercase; }
  .reports-table .checkbox-cell { position: absolute; z-index: 2; top: 11px; right: 11px; width: auto !important; padding: 0; }
  .reports-table td:nth-child(2), .reports-table .row-actions { grid-column: 1 / -1; }
  .row-actions { display: grid !important; grid-template-columns: 1fr 1fr auto; }
  .quick-action { min-height: 40px; font-size: 11px; }
  .more-status { height: 40px; width: 76px; }
  .pagination { padding-inline: 14px; }
  .login-shell { width: min(520px, calc(100% - 28px)); display: block; padding: 36px 0; }
  .login-brand { text-align: center; }
  .login-brand .brand-mark { margin: auto; }
  .login-brand h1 { font-size: 39px; }
  .login-lead { font-size: 14px; }
  .login-points { display: none; }
  .login-card { margin-top: 34px; }
}

@media (max-width: 430px) {
  .sidebar { gap: 6px; }
  .nav-link { gap: 6px; }
  .nav-link:nth-child(2) { display: none; }
  .stats-grid { gap: 9px; }
  .stat-card { gap: 9px; }
  .stat-card small { font-size: 9px; }
  .stat-card strong { font-size: 21px; }
  .page-header { gap: 10px; }
  .reports-table tr { grid-template-columns: 1fr; }
  .reports-table td, .reports-table td:nth-child(2), .reports-table .row-actions { grid-column: 1; }
  .row-actions { grid-template-columns: 1fr 1fr; }
  .more-status { width: 100%; grid-column: 1 / -1; }
}
