/* @llm-section:
purpose: базовая палитра и переменные псевдо-3D интерфейса
invariant: интерфейс остаётся монохромным, цветовые акценты используются только для статусов
*/
:root {
  --bg: #9fa3a6;
  --panel: #c4c7c9;
  --panel-dark: #aeb2b5;
  --line-light: #f0f1f2;
  --line-dark: #72777b;
  --text: #17191b;
  --muted: #555b60;
  --shadow: rgba(22, 24, 26, .35);
  --inset: rgba(255, 255, 255, .62);
  --radius: 10px;
  --accent-ok: #5d7569;
  --accent-bad: #8b5f5f;
  --accent-warn: #817556;
}

/* Базовая раскладка страницы */
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #b2b5b8 0%, var(--bg) 100%);
}
button, input, textarea { font: inherit; }
.hidden { display: none !important; }
.shell {
  width: min(1040px, calc(100vw - 24px));
  margin: 14px auto;
}

/* Общие рельефные поверхности */
.auth-card,
.app-card,
.panel-card {
  border-radius: var(--radius);
  border: 1px solid var(--line-dark);
  background: linear-gradient(180deg, #d4d7d9 0%, var(--panel) 48%, #b6babd 100%);
  box-shadow: 0 10px 24px var(--shadow), inset 0 1px 0 var(--line-light), inset 0 -1px 0 rgba(0,0,0,.18);
}
.auth-card {
  max-width: 380px;
  margin: 8vh auto 0;
  padding: 22px;
  text-align: center;
}
.auth-card h1, .brand {
  margin: 0;
  letter-spacing: .04em;
  font-size: 24px;
  font-weight: 700;
}
.app-card { padding: 12px; }
.panel-card { padding: 12px; margin-top: 12px; }

/* Верхняя панель и вкладки */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px 12px;
}
/* Заголовок приложения с иконкой */
/* @llm-section:
purpose: keeps the app logo visually bound to the title without changing the topbar height
invariant: logo scales by header height and title remains left-aligned
*/
.brand {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
}
.brand-icon {
  width: 40px;
  height: 40px;
  object-fit: contain;
  flex: 0 0 auto;
}
.service-status { display: flex; gap: 8px; align-items: center; }
.badge,
.session-timer {
  min-width: 72px;
  padding: 5px 9px;
  border-radius: 7px;
  border: 1px solid var(--line-dark);
  background: linear-gradient(180deg, #cfd2d4, #b3b7ba);
  box-shadow: inset 0 1px 0 var(--inset), inset 0 -1px 2px rgba(0,0,0,.16);
  text-align: center;
  font-size: 13px;
}
.badge.online { color: #102016; background: linear-gradient(180deg, #c3cec7, #9dac9f); }
.badge.offline { color: #2c1212; background: linear-gradient(180deg, #d3c0c0, #ad9696); }
.badge.checking { color: #2a2313; background: linear-gradient(180deg, #d1c9b5, #b0a686); }
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 4px;
}
.tab,
.primary-3d,
.key-button,
.icon-button,
.file-upload-button {
  border: 1px solid #666b6f;
  color: var(--text);
  background: linear-gradient(180deg, #e0e2e4 0%, #bec2c5 52%, #a7abae 100%);
  box-shadow: 0 3px 6px rgba(0,0,0,.24), inset 0 1px 0 rgba(255,255,255,.75), inset 0 -1px 1px rgba(0,0,0,.22);
  cursor: pointer;
  user-select: none;
}
.tab {
  flex: 1 1 120px;
  padding: 9px 10px;
  border-radius: 8px;
  font-weight: 700;
}
.tab.active {
  background: linear-gradient(180deg, #b8bdc0, #969da1);
  box-shadow: inset 0 3px 6px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.4);
}
.tab:active,
.primary-3d:active,
.key-button:active,
.icon-button:active,
.file-upload-button:active {
  transform: translateY(1px);
  box-shadow: inset 0 3px 7px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.35);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Панели обмена */
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.panel-head h2 {
  margin: 0;
  font-size: 17px;
}
.icon-row, .item-actions { display: flex; gap: 7px; align-items: center; }
.icon-button {
  width: 40px;
  height: 36px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-button svg,
#upload-icon svg {
  width: 20px;
  height: 20px;
  fill: #202326;
}
.icon-button.danger svg { fill: #442525; }
/* Состояние недоступной кнопки отмены */
.icon-button:disabled {
  cursor: default;
  opacity: .45;
  transform: none;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.18), inset 0 1px 0 rgba(255,255,255,.38);
}
.icon-button:disabled svg { fill: #5b6064; }
textarea {
  width: 100%;
  min-height: 28vh;
  padding: 12px;
  resize: vertical;
  border-radius: 8px;
  border: 1px solid #6c7175;
  color: #111;
  background: linear-gradient(180deg, #e2e4e5, #d2d5d7);
  box-shadow: inset 0 3px 9px rgba(0,0,0,.24), inset 0 1px 0 rgba(255,255,255,.7);
  outline: none;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
}
textarea[readonly] { background: linear-gradient(180deg, #d4d7d9, #c2c6c8); color: #24272a; }
textarea:focus {
  border-color: #4f565b;
  box-shadow: inset 0 3px 9px rgba(0,0,0,.25), 0 0 0 2px rgba(255,255,255,.28);
}
.flash { animation: server-flash .7s ease-out; }
@keyframes server-flash {
  0% { box-shadow: 0 10px 24px var(--shadow), 0 0 0 4px rgba(255,255,255,.52), inset 0 1px 0 var(--line-light); }
  100% { box-shadow: 0 10px 24px var(--shadow), inset 0 1px 0 var(--line-light), inset 0 -1px 0 rgba(0,0,0,.18); }
}
.status-line {
  min-height: 22px;
  padding: 7px 2px 0;
  color: var(--muted);
  font-size: 14px;
}

/* Экранная цифровая клавиатура входа */
.pin-display {
  height: 46px;
  margin: 18px 0 12px;
  border-radius: 8px;
  border: 1px solid #686e72;
  background: linear-gradient(180deg, #e4e6e7, #ccd0d2);
  box-shadow: inset 0 3px 8px rgba(0,0,0,.24), inset 0 1px 0 rgba(255,255,255,.7);
  line-height: 46px;
  letter-spacing: .25em;
  font-size: 22px;
}
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 14px 0;
}
.key-button {
  height: 48px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 19px;
}
.primary-3d {
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 700;
}
.primary-3d.compact { min-height: 34px; padding: 6px 10px; }

/* Кнопки управления сессиями */
.session-actions {
  display: flex;
  gap: 7px;
  align-items: center;
  flex-wrap: wrap;
}
.primary-3d.logout { width: 100%; margin-top: 10px; }
.remember-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: var(--muted);
}

/* Списки истории, файлов и сессий */
.list-card { min-height: 62vh; }
.scroll-list {
  max-height: calc(100vh - 220px);
  overflow-y: auto;
  padding-right: 4px;
}
.list-item {
  position: relative;
  margin: 0 0 10px;
  padding: 11px;
  border-radius: 8px;
  border: 1px solid #74797d;
  background: linear-gradient(180deg, #d0d3d5, #b8bcbe);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.58), 0 3px 7px rgba(0,0,0,.18);
}
.list-item pre {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 8px 0 10px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 14px;
}
.item-date,
.item-meta {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}
.item-title { font-weight: 700; word-break: break-word; }
.empty { padding: 16px; color: var(--muted); text-align: center; }
.file-upload-button {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  padding: 7px 10px;
  border-radius: 8px;
  font-weight: 700;
}
.file-upload-button input { display: none; }
.sessions-list .ua { word-break: break-word; }



/* Панели действий справа от списков */
/* @llm-section:
purpose: moves selected-row actions into a right vertical panel without changing base button styling
invariant: side-actions-center actions target only the selected row; file upload remains an independent top action
*/
.side-list-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: stretch;
}
.list-content {
  min-width: 0;
}
.side-actions {
  min-width: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.side-actions-center {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: auto;
  margin-bottom: auto;
}
.side-upload-button {
  width: 40px;
  height: 36px;
  padding: 0;
  justify-content: center;
}
.list-item.is-selected {
  outline: 2px solid #f4f5f6;
  outline-offset: -3px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.68), 0 3px 7px rgba(0,0,0,.18), 0 0 0 1px rgba(0,0,0,.32);
}

/* Блок смены PIN */
.pin-change-grid {
  display: grid;
  gap: 10px;
  max-width: 420px;
}
.pin-change-grid label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 14px;
}
.pin-change-grid input {
  height: 38px;
  border-radius: 8px;
  border: 1px solid #6c7175;
  padding: 7px 10px;
  background: linear-gradient(180deg, #e4e6e7, #ccd0d2);
  box-shadow: inset 0 3px 8px rgba(0,0,0,.22), inset 0 1px 0 rgba(255,255,255,.7);
}

/* Адаптация под маленькие экраны */
@media (max-width: 640px) {
  .shell { width: calc(100vw - 12px); margin: 6px auto; }
  .app-card { padding: 7px; }
  .topbar, .panel-head { align-items: stretch; flex-direction: column; }
  .brand { align-self: flex-start; }
  .icon-row { flex-wrap: wrap; }
  .icon-button { width: 44px; height: 40px; }
  .side-upload-button { width: 44px; height: 40px; }
  .side-list-layout { gap: 7px; }
  .session-actions { align-items: stretch; }
  textarea { min-height: 24vh; font-size: 15px; }
  .scroll-list { max-height: calc(100vh - 190px); }
  .auth-card { margin-top: 4vh; }
}
