:root {
  --bg-main: #0a0d14;
  --bg-card: #111622;
  --bg-elevated: #182030;
  --bg-input: #0e131d;
  --border: #212c40;
  --border-focus: #3b82f6;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent-blue: #3b82f6;
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-purple: #8b5cf6;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: #26344d #0a0d14;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ── Typography & Helpers ── */
h1, h2, h3, h4 { font-weight: 600; color: #fff; }
a { color: var(--accent-cyan); text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; outline: none; }
input, select, textarea { font-family: inherit; border: 1px solid var(--border); background: var(--bg-input); color: var(--text-main); border-radius: var(--radius-sm); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--border-focus); box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2); }

/* ── Auth Screen ── */
#auth-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 30%, #151e33 0%, #080b12 100%);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6), 0 0 40px rgba(6, 182, 212, 0.1);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 440px;
  padding: 36px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.auth-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, #3b82f6, #06b6d4, #10b981);
}

.auth-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-family: var(--font-mono);
  background: rgba(6, 182, 212, 0.12);
  color: var(--accent-cyan);
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 16px;
  border: 1px solid rgba(6, 182, 212, 0.25);
}

.auth-title { font-size: 24px; margin-bottom: 8px; }
.auth-desc { font-size: 14px; color: var(--text-muted); margin-bottom: 24px; line-height: 1.5; }

.form-group { text-align: left; margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; }
.form-group input { width: 100%; padding: 12px 14px; font-size: 15px; border-radius: var(--radius-sm); }
.pin-input { font-family: var(--font-mono); letter-spacing: 4px; text-align: center; font-size: 20px !important; }

.btn-primary {
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, #2563eb, #0891b2);
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}
.btn-primary:hover { opacity: 0.95; transform: translateY(-1px); }

/* ── App Layout ── */
#app-layout { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

header.top-navbar {
  height: 58px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  flex-shrink: 0;
  z-index: 50;
}

.brand-section { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 17px;
  color: #fff;
}
.brand-text { display: flex; flex-direction: column; }
.brand-title { font-size: 14px; font-weight: 700; letter-spacing: 0.5px; }
.brand-sub { font-size: 11px; color: var(--text-dim); font-family: var(--font-mono); }

.nav-tabs { display: flex; align-items: center; gap: 6px; }
.tab-btn {
  padding: 8px 14px;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 7px;
  transition: all 0.15s;
}
.tab-btn:hover { background: var(--bg-elevated); color: var(--text-main); }
.tab-btn.active {
  background: var(--bg-elevated);
  color: #fff;
  border-bottom: 2px solid var(--accent-cyan);
}

.header-actions { display: flex; align-items: center; gap: 12px; }
.status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-family: var(--font-mono);
  background: var(--bg-main);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
}
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot.online { background: var(--accent-emerald); box-shadow: 0 0 8px rgba(16, 185, 129, 0.6); }
.dot.offline { background: var(--text-dim); }

.btn-icon {
  background: var(--bg-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}
.btn-icon:hover { color: #fff; border-color: var(--border-focus); }

/* ── Content Viewports ── */
main.main-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--bg-main);
}

.view-pane {
  display: none;
  width: 100%;
  height: 100%;
  overflow-y: auto;
}
.view-pane.active { display: flex; flex-direction: column; }

/* ── Terminal Viewport ── */
.terminal-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #000;
  position: relative;
}

.terminal-toolbar {
  height: 44px;
  background: #0c1017;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
}

.term-left { display: flex; align-items: center; gap: 10px; }
.term-pills { display: flex; background: var(--bg-input); border-radius: var(--radius-sm); padding: 3px; border: 1px solid var(--border); }
.term-pill {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
}
.term-pill.active { background: var(--accent-blue); color: #fff; }

.term-right { display: flex; align-items: center; gap: 8px; }

#xterm-container {
  flex: 1;
  width: 100%;
  height: 100%;
  padding: 8px;
  background: #000;
  overflow: hidden;
}

/* ── Data Exchange View ── */
.data-exchange-container {
  max-width: 1300px;
  margin: 0 auto;
  padding: 24px;
  width: 100%;
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 24px;
}

@media (max-width: 900px) {
  .data-exchange-container { grid-template-columns: 1fr; }
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
}

.upload-dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 30px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: rgba(14, 19, 29, 0.5);
}
.upload-dropzone:hover, .upload-dropzone.dragover {
  border-color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.05);
}
.drop-icon { font-size: 38px; margin-bottom: 10px; }

.file-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 14px;
}
.file-table th {
  text-align: left;
  padding: 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
  font-weight: 600;
}
.file-table td {
  padding: 12px 10px;
  border-bottom: 1px solid rgba(33, 44, 64, 0.5);
  color: var(--text-main);
}
.file-row:hover td { background: var(--bg-elevated); }

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  font-family: var(--font-mono);
}
.badge-inbox { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.badge-wygenerowane { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.badge-fivem { background: rgba(139, 92, 246, 0.15); color: #a78bfa; }
.badge-szkola { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }

/* ── Telegram Page ── */
.telegram-page-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 30px 20px;
  width: 100%;
}

.guide-step {
  display: flex;
  gap: 16px;
  margin-bottom: 18px;
  align-items: flex-start;
}
.step-num {
  width: 32px;
  height: 32px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: var(--accent-cyan);
  flex-shrink: 0;
}

/* ── Knowledge & Settings View ── */
.knowledge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
  margin-top: 18px;
}
.doc-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  transition: all 0.2s;
  cursor: pointer;
}
.doc-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-cyan);
}

/* ── Modals ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 20px;
}
.modal-backdrop.active { display: flex; }
.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 650px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
  overflow: hidden;
}
.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-body {
  padding: 24px;
  overflow-y: auto;
  line-height: 1.6;
}
.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* ── Toast Notifications ── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 11000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  animation: slideIn 0.2s ease-out;
}
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
