/* ---------- Логин ---------- */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-card { width: 100%; max-width: 400px; padding: 32px; }
.login-card .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; margin-bottom: 18px; }
.login-card h1 { font-size: 20px; margin-bottom: 20px; }
.brand .logo {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center; font-size: 24px;
}

/* ---------- Каркас приложения ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; flex-shrink: 0; background: #fff; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 20px 14px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; padding: 0 8px 18px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  text-align: left; font: inherit; font-weight: 500; font-size: 14.5px;
  padding: 10px 12px; border: none; background: none; border-radius: var(--radius-sm);
  cursor: pointer; color: var(--text); transition: background .12s;
}
.nav-item:hover { background: var(--bg); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 14px; }
.user-box { margin-bottom: 10px; padding: 0 8px; }
.user-name { font-weight: 600; }
.user-role { font-size: 13px; text-transform: capitalize; }

.content { flex: 1; padding: 28px 32px; max-width: 1100px; }
.tab-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.tab-head h1 { font-size: 22px; margin: 0; }

/* ---------- Фильтры ---------- */
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px; margin-bottom: 16px; }
.seg { display: inline-flex; background: var(--bg); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.seg-btn {
  font: inherit; font-size: 13.5px; font-weight: 500; border: none; background: none; cursor: pointer;
  padding: 6px 12px; border-radius: 6px; color: var(--text-muted);
}
.seg-btn.active { background: #fff; color: var(--text); box-shadow: var(--shadow); font-weight: 600; }
.filters input[type="date"] { width: 145px; flex: 0 0 auto; }
.filters input[type="text"] { flex: 0 1 auto; }
.filter-dates { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }

/* Комментарий поддержки в карточке заявки */
.support-box { margin-top: 12px; border-top: 1px dashed var(--border); padding-top: 10px; }
.support-label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 5px; font-weight: 600; }
.support-row { display: flex; gap: 8px; align-items: center; }
.support-row .support-input { flex: 1; }

/* Цепочка комментариев */
.cmt-list { margin-bottom: 8px; }
.cmt { background: var(--bg); border-radius: 7px; padding: 7px 11px; margin-bottom: 6px; }
.cmt-text { font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.cmt-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }
.cmt-earlier { margin-bottom: 6px; }
.cmt-earlier summary { cursor: pointer; color: var(--accent); font-size: 13px; padding: 3px 0; user-select: none; }
.cmt-earlier summary:hover { text-decoration: underline; }
.cmt-earlier[open] summary { margin-bottom: 6px; }

/* ---------- Карточка заявки ---------- */
.ticket {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.ticket-top { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.ticket-id { font-weight: 700; color: var(--text-muted); }
.ticket-time { color: var(--text-muted); font-size: 13px; }
.ticket-grid { display: grid; grid-template-columns: 130px 1fr; gap: 4px 14px; font-size: 14px; }
.ticket-grid .k { color: var(--text-muted); }
.ticket-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; align-items: center; }
.ticket-thumb { margin-top: 10px; }
.ticket-thumb img { max-height: 120px; border-radius: var(--radius-sm); border: 1px solid var(--border); cursor: pointer; }
.handled-note { font-size: 13px; color: var(--text-muted); margin-left: auto; }

/* ---------- Таблицы списков ---------- */
.list-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.list-table th, .list-table td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 14px; }
.list-table th { background: #fafbfd; font-weight: 600; color: var(--text-muted); font-size: 13px; }
.list-table tr:last-child td { border-bottom: none; }
.list-table .actions { display: flex; gap: 6px; justify-content: flex-end; }
.inactive-row { opacity: .55; }
.list-table tr.clickable { cursor: pointer; }
.list-table tr.clickable:hover td { background: var(--accent-soft); }

.count-badge { font-size: 14px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 2px 11px; border-radius: 999px; vertical-align: middle; margin-left: 6px; }

/* Карточка торговой точки */
.tt-card-grid { display: grid; grid-template-columns: 160px 1fr; gap: 9px 14px; font-size: 14px; margin: 6px 0 18px; }
.tt-card-grid .k { color: var(--text-muted); }
.tt-card-grid .v { word-break: break-word; }
.tt-card-grid .v.empty { color: var(--border-strong); }
.tt-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.tt-card-head .num { font-size: 22px; font-weight: 700; }

/* ---------- Статистика ---------- */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat-card .num { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.stat-card .lbl { color: var(--text-muted); font-size: 13px; margin-top: 2px; }
.stat-card.accent .num { color: var(--accent); }
.stat-card.green .num { color: var(--green); }
.stat-card.orange .num { color: var(--orange); }
.stat-card.red .num { color: var(--red); }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 820px) { .stat-grid { grid-template-columns: 1fr; } }
.panel { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.panel h3 { font-size: 15px; margin-bottom: 14px; }
.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; margin-bottom: 9px; font-size: 13.5px; }
.bar-track { grid-column: 1 / -1; height: 7px; background: var(--bg); border-radius: 5px; overflow: hidden; margin-top: -4px; margin-bottom: 4px; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 5px; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Мини-график по дням */
.chart { display: flex; align-items: flex-end; gap: 5px; height: 120px; padding-top: 10px; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.chart .col .bar { width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; transition: height .2s; }
.chart .col .cap { font-size: 10px; color: var(--text-muted); }
.chart .col .val { font-size: 11px; font-weight: 600; }

/* ---------- Модалка ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20, 28, 40, .45);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 90;
}
.modal { width: 100%; max-width: 460px; padding: 24px; }
.modal h2 { font-size: 19px; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }

/* Доступы */
.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 13px; }
.pw-mask { font-family: ui-monospace, Consolas, monospace; letter-spacing: 1px; }
.copy-btn, .reveal-btn {
  border: none; background: none; cursor: pointer; font-size: 14px;
  padding: 1px 4px; border-radius: 5px; color: var(--text-muted); line-height: 1;
}
.copy-btn:hover, .reveal-btn:hover { background: var(--accent-soft); color: var(--accent); }
.cred-note { font-size: 12.5px; color: var(--text-muted); max-width: 340px; white-space: pre-wrap; word-break: break-word; }

/* Таблица доступов: без переносов, кнопки ровно по центру строки */
.cred-table td { white-space: nowrap; vertical-align: middle; }
.cred-table .cred-note { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cred-table .actions { display: table-cell; vertical-align: middle; text-align: right; white-space: nowrap; }
.cred-table .actions .btn { padding: 4px 8px; vertical-align: middle; }
.cred-table .actions .btn + .btn { margin-left: 4px; }

@media (max-width: 720px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot { border: none; padding: 0; display: flex; gap: 10px; align-items: center; }
  .content { padding: 18px; }
  .ticket-grid { grid-template-columns: 1fr; }
}
