:root {
  --bg: #0a0d12;
  --surface: rgba(255, 255, 255, 0.05);
  --surface-2: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #f1f3f6;
  --muted: rgba(255, 255, 255, 0.55);
  --accent: #6aa3ff;
  --paid: #4dd699;
  --pending: #ffc940;
  --unpaid: #ff7a6e;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
}

body {
  background: #0a0d12 url('/bg.jpeg') center top / cover no-repeat fixed;
  position: relative;
}
body::before {
  content: '';
  position: fixed; inset: 0;
  background:
    linear-gradient(180deg, rgba(10,13,18,0.4) 0%, rgba(10,13,18,0.78) 60%, rgba(10,13,18,0.95) 100%);
  pointer-events: none;
  z-index: 0;
}
body > * { position: relative; z-index: 1; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px;
}

/* Frosted glass mixin */
.glass-surface {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.10);
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
}

header.bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 14px 28px;
  background: rgba(10, 13, 18, 0.45);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
}

header.bar .brand {
  font-weight: 500;
  font-size: 15px;
  letter-spacing: 0.4px;
  color: rgba(255,255,255,0.92);
}

header.bar .right {
  font-size: 14px;
  color: var(--muted);
  display: flex;
  align-items: center;
}
header.bar .right .user { color: var(--text); margin-right: 16px; font-weight: 500; }
header.bar .right a { color: rgba(255,255,255,0.6); }
header.bar .right a:hover { color: var(--text); text-decoration: none; }

.card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 16px;
  padding: 22px;
  margin-bottom: 16px;
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

.card h2 {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.2px;
}

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.summary .stat {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 14px;
  padding: 16px 18px;
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
}

.summary .stat .label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 500;
}
.summary .stat .value { font-size: 22px; font-weight: 600; margin-top: 6px; letter-spacing: 0.2px; }
.summary .stat.paid .value { color: var(--paid); }
.summary .stat.unpaid .value { color: var(--unpaid); }

.unit {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 16px;
  margin-bottom: 16px;
  overflow: hidden;
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

.unit-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.unit-head .title { font-size: 16px; font-weight: 500; letter-spacing: 0.2px; }
.unit-head .meta { font-size: 13px; color: var(--muted); margin-top: 4px; }
.unit-head .total { font-size: 18px; font-weight: 600; letter-spacing: 0.2px; }

.payments { padding: 8px 20px 16px; }

.payment-row {
  display: grid;
  grid-template-columns: 60px 1fr 140px 200px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  gap: 12px;
}

.payment-row:first-child { border-top: none; }

.payment-row .n {
  font-weight: 600;
  color: var(--muted);
}

.payment-row .amount {
  font-size: 16px;
  font-weight: 500;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge.paid { background: rgba(77, 214, 153, 0.15); color: var(--paid); border: 1px solid rgba(77, 214, 153, 0.25); }
.badge.pending { background: rgba(255, 201, 64, 0.15); color: var(--pending); border: 1px solid rgba(255, 201, 64, 0.25); }
.badge.unpaid { background: rgba(255, 122, 110, 0.12); color: var(--unpaid); border: 1px solid rgba(255, 122, 110, 0.22); }
.badge.rejected { background: rgba(255, 122, 110, 0.18); color: var(--unpaid); border: 1px solid rgba(255, 122, 110, 0.30); }
button.secondary, .cancel-upload {
  font-size: 12px;
  padding: 6px 12px;
}

button, .btn {
  background: #fff;
  color: #0a0d12;
  border: none;
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.2px;
  transition: opacity 0.15s, transform 0.05s, background 0.15s;
}
button:hover, .btn:hover { opacity: 0.92; }
button:active, .btn:active { transform: translateY(1px); }
button.secondary {
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.15);
}
button.secondary:hover { background: rgba(255,255,255,0.10); }
button.danger { background: var(--unpaid); color: #fff; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

input:not([type]),
input[type=text],
input[type=password],
input[type=file],
input[type=email],
input[type=tel],
input[type=number],
input[type=search],
input[type=url],
input[type=date],
input[type=datetime-local],
textarea {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  width: 100%;
  transition: border-color 0.15s, background 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
input::placeholder, textarea::placeholder { color: rgba(255,255,255,0.3); }
input:focus, textarea:focus {
  outline: none;
  border-color: rgba(255,255,255,0.4);
  background: rgba(0,0,0,0.35);
}

/* Chrome autofill — не давать ему перекрашивать в белый */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active,
textarea:-webkit-autofill {
  -webkit-text-fill-color: var(--text) !important;
  -webkit-box-shadow: 0 0 0 1000px rgba(20, 24, 32, 0.95) inset !important;
  box-shadow: 0 0 0 1000px rgba(20, 24, 32, 0.95) inset !important;
  caret-color: var(--text);
  transition: background-color 9999s ease-in-out 0s;
}

/* убрать спиннеры у number-инпутов */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type=number] { -moz-appearance: textfield; }

.login-box {
  max-width: 400px;
  margin: 80px auto;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  padding: 36px 32px;
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}

.login-box h1 { margin: 0 0 8px; font-size: 22px; font-weight: 500; }
.login-box p { color: var(--muted); margin: 0 0 24px; }

.login-box label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--muted); }
.login-box input { margin-bottom: 16px; }

.error { color: var(--unpaid); font-size: 13px; margin-bottom: 12px; }
.success { color: var(--paid); font-size: 13px; }

.upload-form {
  display: flex;
  align-items: center;
  gap: 8px;
}
.upload-form input[type=file] { width: auto; padding: 6px 8px; font-size: 12px; }

label.btn {
  display: inline-block;
  padding: 9px 16px;
  background: rgba(255,255,255,0.10);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}
label.btn:hover { background: rgba(255,255,255,0.18); }
.upload-status { font-size: 13px; }

.admin-table {
  width: 100%;
  border-collapse: collapse;
}
.admin-table th, .admin-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-size: 14px;
}
.admin-table th { color: var(--muted); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table button { padding: 6px 10px; font-size: 13px; }

.muted { color: var(--muted); font-size: 12px; }
.row-gap { display: flex; gap: 8px; align-items: center; }

/* ===== Language switcher ===== */
.lang-switch {
  display: inline-flex;
  gap: 2px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 2px;
}
.lang-switch button {
  background: transparent;
  color: rgba(255,255,255,0.55);
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  cursor: pointer;
}
.lang-switch button:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.lang-switch button.active {
  background: rgba(255,255,255,0.18);
  color: #fff;
}

/* ===== Чат ===== */
.chat-widget { position: fixed; bottom: 24px; right: 24px; z-index: 1000; }
.chat-toggle {
  width: 56px; height: 56px; border-radius: 50%;
  background: rgba(255,255,255,0.95); color: #0a0d12;
  border: none; cursor: pointer; font-size: 24px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center; padding: 0;
  position: relative;
  transition: transform 0.15s, background 0.15s;
}
.chat-toggle:hover { transform: scale(1.05); }
.chat-badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 20px; height: 20px;
  background: var(--unpaid); color: white;
  border-radius: 999px; font-size: 11px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 6px; font-weight: 600;
  border: 2px solid #0a0d12;
}
.chat-panel {
  position: absolute; bottom: 70px; right: 0;
  width: 380px; max-height: 580px;
  background: rgba(20, 24, 32, 0.85);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 18px;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 60px rgba(0,0,0,0.6);
  overflow: hidden;
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
}
.chat-header {
  padding: 14px 18px;
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex; justify-content: space-between; align-items: center;
}
.tg-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  margin-bottom: 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(0,136,204,0.18), rgba(0,136,204,0.08));
  border: 1px solid rgba(0,136,204,0.3);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
}
.tg-banner-icon {
  font-size: 28px;
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 136, 204, 0.25);
  color: #6cb6f5;
  border-radius: 12px;
  flex-shrink: 0;
}
.tg-banner-body { flex: 1; min-width: 0; }
.tg-banner-title { font-size: 15px; font-weight: 500; margin-bottom: 2px; }
.tg-banner-sub { font-size: 13px; color: var(--muted); line-height: 1.4; }
.tg-banner-btn {
  background: #6cb6f5;
  color: #0a0d12;
  padding: 10px 18px;
  flex-shrink: 0;
}
.tg-banner-btn:hover { background: #88c4f8; }

@media (max-width: 640px) {
  .tg-banner { flex-direction: column; align-items: flex-start; }
  .tg-banner-btn { width: 100%; }
}

.tg-btn {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 14px;
  background: rgba(0, 136, 204, 0.18);
  color: #6cb6f5;
  border: 1px solid rgba(0, 136, 204, 0.3);
  cursor: pointer;
  font-weight: 500;
  line-height: 1.2;
}
.tg-btn:hover { background: rgba(0, 136, 204, 0.28); }
.tg-btn.linked {
  background: rgba(77, 214, 153, 0.16);
  color: var(--paid);
  border-color: rgba(77, 214, 153, 0.3);
}
.tg-btn.linked:hover { background: rgba(77, 214, 153, 0.26); }

.chat-close {
  background: transparent; color: var(--muted);
  border: none; font-size: 22px; cursor: pointer; padding: 0 4px;
  line-height: 1;
}
.chat-close:hover { color: var(--text); }
.chat-messages {
  flex: 1;
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 400px;
}
.chat-empty { color: var(--muted); text-align: center; padding: 24px 0; font-size: 13px; }
.msg { display: flex; flex-direction: column; max-width: 82%; }
.msg.investor { align-self: flex-end; align-items: flex-end; }
.msg.admin { align-self: flex-start; align-items: flex-start; }
.msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
}
.msg.investor .msg-bubble { background: rgba(255,255,255,0.95); color: #0a0d12; border-bottom-right-radius: 4px; }
.msg.admin .msg-bubble { background: rgba(255,255,255,0.10); color: var(--text); border: 1px solid rgba(255,255,255,0.08); border-bottom-left-radius: 4px; }
.msg-time { font-size: 10px; color: var(--muted); margin-top: 4px; padding: 0 4px; display: inline-flex; gap: 4px; align-items: center; }
.msg-orig { font-size: 9px; color: rgba(255,255,255,0.5); cursor: help; }
.msg-orig:hover { color: var(--text); }
.chat-form {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding: 10px;
  display: flex; flex-direction: column; gap: 8px;
  background: rgba(255,255,255,0.02);
}
.chat-input-row { display: flex; gap: 6px; align-items: stretch; }
.chat-form textarea {
  flex: 1;
  background: rgba(0,0,0,0.3);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 10px;
  padding: 10px 12px;
  resize: none;
  font: inherit; font-size: 13px;
}
.chat-form textarea:focus {
  outline: none;
  border-color: rgba(255,255,255,0.3);
  background: rgba(0,0,0,0.4);
}
.chat-form button { padding: 0 16px; border-radius: 10px; }
.chat-attach-btn {
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 10px;
  cursor: pointer;
  font-size: 18px;
  padding: 0 12px;
  user-select: none;
  transition: background 0.1s;
}
.chat-attach-btn:hover { background: rgba(255,255,255,0.12); }

.attach-preview {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 4px;
  max-height: 120px;
  overflow-y: auto;
}
.attach-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  max-width: 100%;
}
.attach-chip .attach-name {
  max-width: 160px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.attach-chip .attach-size { color: var(--muted); font-size: 11px; }
.attach-chip .attach-remove {
  background: transparent; color: var(--muted); border: none;
  cursor: pointer; padding: 0 2px; font-size: 16px; line-height: 1;
}
.attach-chip .attach-remove:hover { color: var(--unpaid); }

/* Attachments в сообщениях */
.msg-attachments {
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 4px;
}
.msg-attach-img {
  display: block;
  max-width: 240px;
  border-radius: 10px;
  overflow: hidden;
  text-decoration: none;
}
.msg-attach-img img {
  display: block;
  max-width: 100%;
  max-height: 240px;
  object-fit: cover;
  border-radius: 10px;
}
.msg-attach-file {
  display: flex; gap: 10px; align-items: center;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  max-width: 280px;
  transition: background 0.1s;
}
.msg-attach-file:hover { background: var(--bg); text-decoration: none; }
.msg-attach-file .file-icon { font-size: 22px; }
.msg-attach-file .file-meta { display: flex; flex-direction: column; min-width: 0; }
.msg-attach-file .file-name {
  font-size: 13px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.msg-attach-file .file-size { font-size: 11px; color: var(--muted); }
.msg.investor .msg-attach-file { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.15); color: white; }
.msg.investor .msg-attach-file:hover { background: rgba(255,255,255,0.15); }
.msg.investor .msg-attach-file .file-size { color: rgba(255,255,255,0.7); }

@media (max-width: 720px) {
  .summary { grid-template-columns: repeat(2, 1fr); }
  .payment-row { grid-template-columns: 40px 1fr 100px; }
  .payment-row .actions { grid-column: 1 / -1; margin-top: 6px; }
}
