﻿:root {
  --bg: #f4efe6;
  --ink: #1c2736;
  --muted: #566171;
  --line: #decab3;
  --panel: rgba(255, 248, 238, 0.7);
  --panel-strong: #fff7ee;
  --primary: #d85b2d;
  --primary-dark: #9b3310;
  --primary-soft: rgba(216, 91, 45, 0.16);
  --bg-custom-opacity: 0.34;
  --bg-custom-blur: 4px;
  --shadow-sm: 0 10px 26px rgba(24, 34, 48, 0.08);
  --shadow-lg: 0 20px 50px rgba(24, 34, 48, 0.14);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: "Space Grotesk", "Noto Sans SC", sans-serif;
  color: var(--ink);
}

body {
  background:
    radial-gradient(900px 460px at 10% 8%, rgba(241, 180, 134, 0.48), transparent 60%),
    radial-gradient(720px 400px at 95% 0%, rgba(128, 188, 206, 0.36), transparent 58%),
    radial-gradient(840px 440px at 80% 88%, rgba(173, 204, 144, 0.32), transparent 60%),
    linear-gradient(160deg, #f6f0e7 0%, #f4efe6 46%, #f8f3eb 100%);
}

.bg-custom {
  position: fixed;
  inset: -4%;
  z-index: 0;
  pointer-events: none;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  opacity: 0;
  filter: blur(var(--bg-custom-blur));
  transform: scale(1.06);
  transition: opacity 0.28s ease;
}

.bg-custom.enabled {
  opacity: var(--bg-custom-opacity);
}

.bg-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(120deg, transparent 0 44%, rgba(255, 255, 255, 0.45) 50%, transparent 56%),
    linear-gradient(25deg, transparent 0 48%, rgba(255, 255, 255, 0.24) 50%, transparent 52%);
  opacity: 0.7;
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100%;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 14px;
  padding: 14px;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(16, 22, 30, 0.38);
  backdrop-filter: blur(4px);
}

.login-screen.active {
  display: flex;
}

.login-card {
  width: min(440px, 96vw);
  border: 1px solid rgba(222, 202, 179, 0.94);
  background: rgba(255, 248, 238, 0.94);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 18px;
  display: grid;
  gap: 10px;
}

.login-card h2 {
  margin: 0;
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: #a03131;
  font-size: 0.82rem;
}

.sidebar {
  border: 1px solid rgba(222, 202, 179, 0.75);
  border-radius: 20px;
  background: linear-gradient(175deg, rgba(255, 250, 242, 0.84), rgba(255, 246, 236, 0.64));
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-lg);
  padding: 22px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 14px;
  max-height: calc(100vh - 28px);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 22px;
}

.brand-logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  object-fit: cover;
  border: 1px solid rgba(222, 202, 179, 0.95);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 24px rgba(24, 34, 48, 0.16);
}

.logo {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, var(--primary), #f39a59 58%, #ffcb99);
  box-shadow: 0 10px 24px rgba(216, 91, 45, 0.36);
}

.brand h1 {
  margin: 0;
  font-size: 1.14rem;
  line-height: 1.1;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tabs {
  display: grid;
  gap: 8px;
}

.tab {
  appearance: none;
  border: 1px solid rgba(222, 202, 179, 0.9);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.tab:hover {
  transform: translateX(3px);
  box-shadow: var(--shadow-sm);
}

.tab.active {
  border-color: var(--primary);
  color: var(--primary-dark);
  background: linear-gradient(120deg, rgba(216, 91, 45, 0.2), rgba(216, 91, 45, 0.04));
  box-shadow: inset 0 0 0 1px rgba(216, 91, 45, 0.12), var(--shadow-sm);
}

.status-box {
  margin-top: auto;
  padding: 12px;
  border-radius: 12px;
  border: 1px dashed rgba(222, 202, 179, 0.95);
  background: rgba(255, 255, 255, 0.66);
}

.status-box p {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.status-box strong {
  display: block;
  margin-top: 6px;
  font-size: 0.94rem;
}

.content {
  border: 1px solid rgba(222, 202, 179, 0.75);
  border-radius: 20px;
  background: linear-gradient(175deg, rgba(255, 250, 243, 0.82), rgba(255, 246, 236, 0.62));
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-lg);
  padding: 22px;
}

body.has-custom-bg .sidebar {
  background: linear-gradient(175deg, rgba(255, 250, 242, 0.7), rgba(255, 246, 236, 0.5));
}

body.has-custom-bg .content {
  background: linear-gradient(175deg, rgba(255, 250, 243, 0.7), rgba(255, 246, 236, 0.5));
}

.panel {
  display: none;
  animation: rise 0.28s ease;
}

.panel.active {
  display: block;
}

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

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.panel-header h2 {
  margin: 0;
  font-size: 1.26rem;
}

.kpis {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(160px, 230px));
}

.kpi,
.form-card,
.card {
  border: 1px solid rgba(222, 202, 179, 0.94);
  background: var(--panel);
  backdrop-filter: blur(6px);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

body.has-custom-bg .tab {
  background: rgba(255, 255, 255, 0.58);
}

body.has-custom-bg .status-box,
body.has-custom-bg .kpi,
body.has-custom-bg .form-card,
body.has-custom-bg .card {
  background: rgba(255, 248, 238, 0.54);
}

body.has-custom-bg input,
body.has-custom-bg select,
body.has-custom-bg textarea {
  background: rgba(255, 255, 255, 0.62);
}

.kpi {
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
}

.kpi::after {
  content: "";
  position: absolute;
  right: -40px;
  top: -50px;
  width: 120px;
  height: 120px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(216, 91, 45, 0.23), transparent 72%);
}

.kpi h3 {
  margin: 0;
  font-size: 0.84rem;
  color: var(--muted);
  font-weight: 600;
}

.kpi p {
  margin: 10px 0 0;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--primary-dark);
}

.cards {
  margin-top: 16px;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.card {
  padding: 14px;
  transition: transform 0.2s ease, box-shadow 0.25s ease, border-color 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 36px rgba(20, 30, 43, 0.12);
}

.card.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(216, 91, 45, 0.16), 0 20px 42px rgba(20, 30, 43, 0.14);
}

.card h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.form-card {
  padding: 16px;
  position: relative;
}

.form-card h3 {
  margin: 0 0 12px;
}

.muted {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.grid-2,
.grid-3 {
  display: grid;
  gap: 10px;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(180px, 1fr));
}

.grid-3 {
  grid-template-columns: 1fr 1fr 2fr;
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 500;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(222, 202, 179, 0.98);
  border-radius: 11px;
  padding: 9px 11px;
  font: inherit;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.8);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(216, 91, 45, 0.14);
}

input[type="file"] {
  background: rgba(255, 255, 255, 0.66);
}

input[type="color"] {
  padding: 4px;
  min-height: 42px;
}

.btn {
  border: none;
  border-radius: 11px;
  padding: 10px 14px;
  background: linear-gradient(140deg, var(--primary), #f08e4c);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 650;
  letter-spacing: 0.01em;
  box-shadow: 0 10px 18px rgba(216, 91, 45, 0.26);
  transition: transform 0.18s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.03);
  box-shadow: 0 14px 22px rgba(216, 91, 45, 0.3);
}

.btn:active {
  transform: translateY(0);
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.92);
  color: var(--primary-dark);
  border: 1px solid rgba(222, 202, 179, 0.98);
  box-shadow: none;
}

.btn.ghost:hover {
  box-shadow: var(--shadow-sm);
}

.btn[disabled] {
  cursor: not-allowed;
  opacity: 0.58;
  box-shadow: none;
  transform: none;
}

.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.98);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.14);
}

.bot-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hint {
  margin-top: 9px;
  color: var(--muted);
  font-size: 0.8rem;
}

.plugin-meta {
  margin-top: 6px;
  display: grid;
  gap: 4px;
}

.plugin-usage {
  margin-bottom: 6px;
}

.plugin-usage code {
  background: #f1e5d8;
  border: 1px solid rgba(217, 190, 162, 0.76);
  color: #3d2f24;
  padding: 3px 7px;
  border-radius: 7px;
  margin-right: 6px;
  display: inline-block;
  margin-bottom: 6px;
}

body.has-custom-bg .plugin-usage code {
  background: rgba(241, 229, 216, 0.7);
}

.log-box-inline {
  margin-top: 16px;
}

.log-console {
  background: linear-gradient(160deg, rgba(15, 22, 34, 0.78), rgba(19, 29, 45, 0.74) 60%, rgba(24, 35, 56, 0.74));
  color: #dcf2e3;
  border: 1px solid rgba(108, 139, 163, 0.28);
  backdrop-filter: blur(4px);
  border-radius: 12px;
  padding: 12px;
  font-family: "Consolas", "SFMono-Regular", monospace;
  font-size: 12px;
  line-height: 1.55;
  min-height: 240px;
  max-height: 460px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.log-line {
  padding: 2px 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
}

.log-line.info {
  color: #d0ecff;
}

.log-line.error {
  color: #ffc0c0;
}

.log-line.raw {
  color: #d9f2b8;
}

.auth-status {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: #fff;
}

.auth-status.running {
  border-color: #c9b28c;
  background: #fff8ee;
  color: #6e5426;
}

.auth-status.success {
  border-color: #8bc6a2;
  background: #f1fbf5;
  color: #1f7a39;
}

.auth-status.error {
  border-color: #df9d9d;
  background: #fff4f4;
  color: #9d2d2d;
}

body.has-custom-bg .auth-status {
  background: rgba(255, 255, 255, 0.62);
}

body.has-custom-bg .auth-status.running {
  background: rgba(255, 248, 238, 0.62);
}

body.has-custom-bg .auth-status.success {
  background: rgba(241, 251, 245, 0.68);
}

body.has-custom-bg .auth-status.error {
  background: rgba(255, 244, 244, 0.7);
}

/* Scrollbar */
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-thumb {
  background: rgba(120, 92, 68, 0.35);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

*::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.24);
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    max-height: none;
  }
}

@media (max-width: 920px) {
  .app-shell {
    padding: 10px;
  }

  .content,
  .sidebar {
    border-radius: 16px;
    padding: 16px;
  }

  .tabs {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .tab {
    text-align: center;
    padding: 10px 8px;
    font-size: 0.82rem;
  }

  .kpis {
    grid-template-columns: 1fr 1fr;
  }

  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .cards {
    grid-template-columns: 1fr;
  }

  .panel-header {
    flex-wrap: wrap;
  }

  .btn-row {
    width: 100%;
  }
}
