/* ===================== ЛИЧНЫЙ АССИСТЕНТ — стили ===================== */

:root {
  --bg: #080d1a;
  --bg-soft: #0d1426;
  --panel: #111a30;
  --panel-2: #16203a;
  --line: rgba(255, 255, 255, 0.075);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #e9edf9;
  --muted: #8e9ab5;
  --accent: #6c8cff;
  --accent-2: #9a7bff;
  --green: #35d39a;
  --red: #ff6b81;
  --amber: #ffb84d;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(108, 140, 255, 0.16), transparent 60%),
    radial-gradient(700px 400px at 100% 0%, rgba(154, 123, 255, 0.12), transparent 55%);
  pointer-events: none;
  z-index: 0;
}

button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mt { margin-top: 12px; }
.hidden, [hidden] { display: none !important; }
.grow { flex: 1; }

/* ------------------------------ вход ------------------------------ */
.login-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 50;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 34px 28px;
  box-shadow: var(--shadow);
  text-align: center;
  animation: rise 0.35s ease;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.login-logo {
  width: 58px;
  height: 58px;
  margin: 0 auto 16px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 10px 30px rgba(108, 140, 255, 0.35);
}
.login-logo svg { width: 30px; height: 30px; stroke-linecap: round; stroke-linejoin: round; }
.login-card h1 { font-size: 22px; margin-bottom: 6px; }
.login-card p { margin: 0 0 22px; }
.login-card input {
  width: 100%;
  padding: 13px 16px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: rgba(0, 0, 0, 0.25);
  outline: none;
  margin-bottom: 12px;
  transition: border-color 0.15s;
}
.login-card input:focus { border-color: var(--accent); }
.login-error { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 10px; }

/* ------------------------------ каркас ------------------------------ */
.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 250px 1fr;
  height: 100vh;
  height: 100dvh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px 16px;
  border-right: 1px solid var(--line);
  background: rgba(11, 17, 32, 0.72);
  backdrop-filter: blur(18px);
}

.brand { display: flex; align-items: center; gap: 11px; padding: 0 6px; }
.brand-mark {
  width: 40px; height: 40px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-weight: 800; font-size: 14px; letter-spacing: 0.02em;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 8px 22px rgba(108, 140, 255, 0.35);
}
.brand-title { font-weight: 650; font-size: 15px; }
.brand-sub { font-size: 12px; color: var(--muted); }

.side-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  font-size: 14.5px;
  transition: background 0.15s, color 0.15s;
}
.nav-item svg {
  width: 19px; height: 19px;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
  flex: 0 0 auto;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(108, 140, 255, 0.18), rgba(108, 140, 255, 0.04));
  color: #fff;
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0; top: 22%; bottom: 22%;
  width: 3px;
  border-radius: 3px;
  background: var(--accent);
}

.side-foot { margin-top: auto; padding: 0 6px; }
.status-dot { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.status-dot i {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 3px rgba(255, 184, 77, 0.15);
}
.status-dot.ok i { background: var(--green); box-shadow: 0 0 0 3px rgba(53, 211, 154, 0.15); }
.status-dot.err i { background: var(--red); box-shadow: 0 0 0 3px rgba(255, 107, 129, 0.15); }

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 28px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 13, 26, 0.6);
  backdrop-filter: blur(12px);
}
.topbar h2 { font-size: 20px; }
.topbar p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.views { flex: 1; overflow-y: auto; padding: 20px 28px 28px; scrollbar-width: thin; }
.view { max-width: 980px; margin: 0 auto; animation: fade 0.2s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.tabbar { display: none; }

/* ------------------------------ элементы ------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: 11px;
  border: 1px solid transparent;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-weight: 550;
  transition: transform 0.08s, filter 0.15s, background 0.15s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: scale(0.98); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 8px 22px rgba(108, 140, 255, 0.28);
}
.btn.ghost { background: rgba(255, 255, 255, 0.05); border-color: var(--line-strong); }
.btn.small { padding: 7px 12px; font-size: 13.5px; }
.btn.block { width: 100%; padding: 13px; border-radius: 12px; }
.btn.danger { background: rgba(255, 107, 129, 0.14); color: #ffb3be; border-color: rgba(255, 107, 129, 0.3); }
.btn:disabled { opacity: 0.5; cursor: default; }
.icon-btn {
  width: 34px; height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: grid; place-items: center;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.toolbar-right { display: flex; align-items: center; gap: 8px; }

.chips { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }
.chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}
.chip:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.25); }
.chip.active {
  background: rgba(108, 140, 255, 0.16);
  border-color: rgba(108, 140, 255, 0.5);
  color: #cdd8ff;
}

.switch { display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; color: var(--muted); cursor: pointer; user-select: none; }
.switch input { accent-color: var(--accent); width: 15px; height: 15px; }

.search-row { margin-bottom: 12px; }
.search-row input, .view input[type="search"] {
  width: 100%;
  padding: 10px 14px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  outline: none;
}
.search-row input:focus, .view input[type="search"]:focus { border-color: var(--accent); }

.list { display: flex; flex-direction: column; gap: 8px; }

.alert {
  padding: 11px 14px;
  margin-bottom: 12px;
  border-radius: 11px;
  border: 1px solid rgba(255, 184, 77, 0.35);
  background: rgba(255, 184, 77, 0.09);
  color: #ffd79a;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}
.alert.danger {
  border-color: rgba(255, 107, 129, 0.4);
  background: rgba(255, 107, 129, 0.1);
  color: #ffb3be;
}

.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  transition: border-color 0.15s, transform 0.08s;
}
.card.clickable { cursor: pointer; }
.card.clickable:hover { border-color: var(--line-strong); background: rgba(255, 255, 255, 0.055); }
.card-title { font-weight: 600; font-size: 14.5px; }
.card-meta { color: var(--muted); font-size: 12.5px; margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.card-snippet { color: #b9c2d8; font-size: 13.5px; margin-top: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.empty {
  padding: 46px 20px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}

.badge {
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  text-align: center;
}
.nav-item .badge { margin-left: auto; }

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: 0 0 auto; }
.dot.unread { background: var(--accent); box-shadow: 0 0 0 3px rgba(108, 140, 255, 0.18); }

/* ------------------------------ чат ------------------------------ */
.view[data-view="chat"] { height: 100%; display: flex; flex-direction: column; max-width: 820px; }
.chat-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 6px 2px 18px;
  min-height: 200px;
}
.chat-empty { margin: auto; text-align: center; max-width: 480px; padding: 20px; }
.chat-empty-icon {
  width: 54px; height: 54px; margin: 0 auto 14px;
  border-radius: 16px;
  display: grid; place-items: center;
  font-size: 24px;
  background: linear-gradient(135deg, rgba(108, 140, 255, 0.25), rgba(154, 123, 255, 0.18));
  border: 1px solid rgba(108, 140, 255, 0.3);
}
.chat-empty h3 { margin-bottom: 8px; }
.chat-empty p { font-size: 13.5px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; }

.msg { display: flex; }
.msg .bubble {
  max-width: 82%;
  padding: 11px 14px;
  border-radius: 15px;
  font-size: 14.5px;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.user { justify-content: flex-end; }
.msg.user .bubble {
  background: linear-gradient(135deg, #4f6fe8, #6c5ce7);
  color: #fff;
  border-bottom-right-radius: 5px;
}
.msg.assistant .bubble {
  background: var(--panel);
  border: 1px solid var(--line);
  border-bottom-left-radius: 5px;
}
.msg.system .bubble { background: transparent; color: var(--muted); font-size: 13px; }
.msg .time { font-size: 11px; color: var(--muted); margin-top: 4px; }
.typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.typing i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--muted);
  animation: blink 1.2s infinite;
}
.typing i:nth-child(2) { animation-delay: 0.2s; }
.typing i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.25; } 30% { opacity: 1; } }

.composer {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: rgba(17, 26, 48, 0.9);
  backdrop-filter: blur(10px);
}
.composer textarea {
  flex: 1;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  padding: 8px 6px;
  max-height: 140px;
  font-size: 14.5px;
}
.send-btn {
  width: 40px; height: 40px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  cursor: pointer;
  display: grid; place-items: center;
}
.send-btn svg { width: 19px; height: 19px; fill: currentColor; }
.send-btn:disabled { opacity: 0.45; }

/* ------------------------------ задачи ------------------------------ */
.task-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.03);
}
.task-check {
  width: 21px; height: 21px;
  margin-top: 1px;
  border-radius: 50%;
  border: 1.7px solid var(--muted);
  background: transparent;
  cursor: pointer;
  flex: 0 0 auto;
  display: grid; place-items: center;
  color: transparent;
  font-size: 12px;
  transition: all 0.15s;
}
.task-check:hover { border-color: var(--accent); }
.task-check.done { background: var(--green); border-color: var(--green); color: #06231a; }
.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 14.5px; font-weight: 550; }
.task-row.done .task-title { text-decoration: line-through; color: var(--muted); font-weight: 400; }
.task-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; font-size: 12px; color: var(--muted); }
.tag {
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  font-size: 11.5px;
}
.tag.red { background: rgba(255, 107, 129, 0.16); color: #ff9aa7; }
.tag.amber { background: rgba(255, 184, 77, 0.16); color: #ffcd85; }
.tag.blue { background: rgba(108, 140, 255, 0.16); color: #b4c4ff; }
.tag.green { background: rgba(53, 211, 154, 0.15); color: #8ce9c4; }

/* ------------------------------ проекты ------------------------------ */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.project-card { position: relative; overflow: hidden; }
.project-edit {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  opacity: 0.5;
}
.project-card:hover .project-edit { opacity: 1; }
.project-card .bar { height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.08); margin-top: 12px; overflow: hidden; }
.project-card .bar i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.project-top { display: flex; align-items: center; gap: 9px; }
.project-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }

/* ------------------------------ календарь ------------------------------ */
.day-group { margin-bottom: 18px; }
.day-title { font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 8px 4px; }
.event-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 11px 14px;
  border-left: 3px solid var(--accent);
  border-radius: 0 12px 12px 0;
  background: rgba(255, 255, 255, 0.035);
  margin-bottom: 7px;
}
.event-time { font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 600; font-size: 13.5px; min-width: 48px; }
.event-title { font-size: 14.5px; }
.event-row .icon-btn { margin-left: auto; flex: 0 0 auto; width: 30px; height: 30px; }

/* ------------------------------ модальное окно ------------------------------ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(3, 6, 14, 0.7);
  backdrop-filter: blur(6px);
}
.modal-card {
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  box-shadow: var(--shadow);
  animation: rise 0.22s ease;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 18px; overflow-y: auto; }

.field { margin-bottom: 13px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.field input, .field textarea, .field select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: rgba(0, 0, 0, 0.25);
  outline: none;
  font-size: 14px;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); }
.field textarea { min-height: 110px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

.email-body {
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.55;
  color: #d6dcee;
  max-height: 46vh;
  overflow-y: auto;
  padding: 4px 2px;
}

/* ------------------------------ прочее ------------------------------ */
.section { margin-bottom: 28px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin-bottom: 12px; }

.status-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.status-card { display: flex; align-items: center; gap: 10px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255, 255, 255, 0.03); }
.status-card .s-name { font-size: 13.5px; }
.status-card .s-value { font-size: 24px; font-weight: 750; line-height: 1.1; }
.status-card:has(.s-value) { align-items: center; gap: 12px; }
.status-card:has(.s-value) .s-name { font-size: 12.5px; color: var(--muted); }
.status-card .s-state { font-size: 12px; color: var(--muted); }
.status-card.ok { border-color: rgba(53, 211, 154, 0.28); }
.status-card.bad { border-color: rgba(255, 107, 129, 0.25); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 80;
  padding: 11px 18px;
  border-radius: 12px;
  background: #1b2540;
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  font-size: 13.5px;
  max-width: 90vw;
  animation: rise 0.2s ease;
}
.toast.error { border-color: rgba(255, 107, 129, 0.5); color: #ffb3be; }

.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------ мобильная версия ------------------------------ */
@media (max-width: 899px) {
  .app { grid-template-columns: 1fr; height: 100dvh; }
  .sidebar { display: none; }
  .topbar { padding: 14px 16px 10px; }
  .topbar h2 { font-size: 18px; }
  .topbar p { display: none; }
  .views { padding: 14px 14px calc(84px + var(--safe-bottom)); }
  .tabbar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 6px 6px calc(6px + var(--safe-bottom));
    background: rgba(10, 16, 30, 0.92);
    backdrop-filter: blur(18px);
    border-top: 1px solid var(--line);
  }
  .tabbar button {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 7px 2px;
    border: 0;
    border-radius: 11px;
    background: transparent;
    color: var(--muted);
    font-size: 10.5px;
    cursor: pointer;
  }
  .tabbar button svg {
    width: 21px; height: 21px;
    fill: none; stroke: currentColor; stroke-width: 1.8;
    stroke-linecap: round; stroke-linejoin: round;
  }
  .tabbar button.active { color: #cfd9ff; background: rgba(108, 140, 255, 0.1); }
  .tabbar .badge { position: absolute; top: 3px; right: calc(50% - 18px); }
  .view[data-view="chat"] { height: 100%; }
  .chat-list { padding-bottom: 10px; }
  .msg .bubble { max-width: 88%; }
  .modal { padding: 0; align-items: flex-end; }
  .modal-card { max-width: 100%; max-height: 92vh; border-radius: 20px 20px 0 0; }
  .toast { bottom: calc(78px + var(--safe-bottom)); }
  .field-row { grid-template-columns: 1fr; }
}
