:root {
  --bg: #060a08;
  --bg-panel: #0c1310;
  --bg-card: #101a15;
  --border: #1c2b23;
  --text: #e7f3ec;
  --text-dim: #8fa79a;
  --accent: #34d399;
  --accent-dim: #1f6b4c;
  --danger: #ef6d6d;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(circle at 72% 35%, #0d1a13 0%, #060a08 60%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px; font-weight: 700; padding: 0 8px 20px;
  border: none; background: none; color: var(--text); cursor: pointer; font-size: 15px;
}
.sidebar-logo-icon {
  width: 28px; height: 28px; border-radius: 8px; background: var(--accent);
  color: #04120b; display: flex; align-items: center; justify-content: center; font-weight: 800;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px; border: none; background: none; color: var(--text-dim);
  text-align: left; width: 100%; font-size: 14px; margin-bottom: 2px;
}
.nav-item:hover { background: #12201a; color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: #d9fbe9; }
.nav-icon { display: inline-flex; flex-shrink: 0; }
.nav-icon svg { display: block; }
.sidebar-footer--desktop { margin-top: auto; padding: 0 8px; }
.sidebar-footer--mobile { display: none; }
.logout-btn { background: none; border: none; color: var(--text-dim); font-size: 13px; padding: 8px; }
.logout-btn:hover { color: var(--danger); }

.main { flex: 1; padding: 28px 40px 60px; max-width: 1400px; }
.main-date { font-size: 12px; letter-spacing: 0.08em; color: var(--text-dim); text-transform: uppercase; }
.main-title { font-size: 32px; font-weight: 700; margin: 4px 0 22px; }

.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 12px;
}
.card-hero {
  background: linear-gradient(135deg, #12261c, #0c1712); border-radius: var(--radius);
  padding: 22px; margin-bottom: 20px; border: 1px solid var(--border);
}
.card-hero-eyebrow { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-dim); }
.card-hero-title { font-size: 22px; font-weight: 700; margin-top: 8px; line-height: 1.4; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat-value { font-size: 22px; font-weight: 700; }
.stat-label { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) {
  .grid-2 { grid-template-columns: 1fr; }
  .app-shell { flex-direction: column; }
  .main { padding: 16px 16px 100px; max-width: 100%; }
  /* Нижнє меню — 5 основних вкладок (без "Огляд"/"Контент", як в оригіналі),
     з піднятою круглою іконкою "Мозок" по центру. */
  .sidebar {
    position: fixed; left: 10px; right: 10px; bottom: 10px; top: auto; width: auto; height: auto;
    flex-direction: row; justify-content: space-around; align-items: flex-end;
    padding: 8px 4px calc(6px + env(safe-area-inset-bottom));
    border: 1px solid var(--border); border-radius: 22px;
    background: rgba(12, 19, 16, 0.9);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    z-index: 20;
  }
  .sidebar-logo { display: none; }
  .nav-item--desktop-only { display: none; }
  .nav-item {
    flex-direction: column; justify-content: center; align-items: center;
    gap: 3px; width: auto; flex: 1; min-width: 0;
    padding: 4px 2px; font-size: 10px; text-align: center; margin-bottom: 0;
    white-space: nowrap; overflow: visible; text-overflow: ellipsis;
  }
  .nav-item span { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .nav-item .nav-icon svg { width: 21px; height: 21px; }
  .nav-item--center {
    margin-top: -22px;
  }
  .nav-item--center .nav-icon {
    width: 46px; height: 46px; border-radius: 50%;
    background: var(--accent-dim); border: 3px solid var(--bg);
    align-items: center; justify-content: center;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  }
  .nav-item--center.active .nav-icon { background: var(--accent); color: #04120b; }
  .nav-item--center .nav-icon svg { width: 22px; height: 22px; }
  .sidebar-footer--desktop { display: none; }
  .sidebar-footer--mobile {
    display: block; position: fixed; top: 10px; right: 12px; z-index: 21;
  }
  .logout-btn {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 999px;
  }
}

.list-item {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 10px;
}
.list-item-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; }
.badge {
  display: inline-block; background: var(--accent-dim); color: #d9fbe9; font-size: 11px;
  padding: 3px 9px; border-radius: 999px; font-weight: 600;
}
.muted { color: var(--text-dim); font-size: 12px; }
.list-item-text { white-space: pre-wrap; word-break: break-word; margin: 6px 0; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

.btn {
  border: 1px solid var(--border); background: #131f19; color: var(--text);
  border-radius: 9px; padding: 7px 13px; font-size: 13px;
}
.btn:hover { border-color: var(--accent-dim); }
.btn--primary { background: var(--accent); color: #04120b; border-color: var(--accent); font-weight: 700; }
.btn--primary:hover { filter: brightness(1.06); }
.btn--danger { color: var(--danger); border-color: #4a2626; }
.btn--ghost { background: none; }
.btn:disabled { opacity: .5; cursor: default; }

.tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.tab { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--bg-card); color: var(--text-dim); font-size: 13px; }
.tab.active { background: var(--accent); color: #04120b; border-color: var(--accent); font-weight: 700; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 12px; color: var(--text-dim); }
input[type="text"], input[type="password"], input[type="number"], input[type="date"], input[type="search"], textarea, select {
  background: #0a1310; border: 1px solid var(--border); border-radius: 9px; padding: 9px 12px; color: var(--text);
  width: 100%;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }

.empty-state { color: var(--text-dim); padding: 24px 4px; font-size: 14px; }
.loading { color: var(--text-dim); padding: 24px 4px; }

.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-form { width: 280px; display: flex; flex-direction: column; gap: 14px; text-align: center; }
.login-title { font-size: 28px; font-weight: 800; }
.login-subtitle { color: var(--text-dim); font-size: 13px; margin-bottom: 8px; }
.login-input { text-align: center; letter-spacing: 0.3em; font-size: 20px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #101a15; border: 1px solid var(--accent-dim); color: var(--text);
  padding: 10px 18px; border-radius: 10px; font-size: 13px; opacity: 0; pointer-events: none; transition: all .2s;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast--error { border-color: #6b2b2b; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(3, 8, 6, .72); display: flex;
  align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 40; overflow-y: auto;
}
.modal { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; width: 100%; max-width: 560px; }
.modal-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-close {
  background: none; border: none; color: var(--text-dim); font-size: 24px;
  width: 40px; height: 40px; border-radius: 10px; line-height: 1;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.modal-close:hover { background: #16221c; color: var(--text); }

.hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.hub-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; text-align: left; }
.hub-card:hover { border-color: var(--accent-dim); }
.hub-card-icon { font-size: 20px; margin-bottom: 8px; }
.hub-card-title { font-weight: 700; margin-bottom: 4px; }
.hub-card-desc { color: var(--text-dim); font-size: 12px; }

.chat-log { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; max-height: 50vh; overflow-y: auto; }
.chat-bubble { padding: 10px 14px; border-radius: 12px; max-width: 85%; white-space: pre-wrap; }
.chat-bubble--q { align-self: flex-end; background: var(--accent-dim); color: #d9fbe9; }
.chat-bubble--a { align-self: flex-start; background: var(--bg-card); border: 1px solid var(--border); }
