:root {
  --bg-main: #070b14;
  --bg-card: rgba(15, 23, 42, 0.78);
  --bg-elevated: rgba(30, 41, 59, 0.65);
  --border: rgba(148, 163, 184, 0.16);
  --border-accent: rgba(99, 102, 241, 0.45);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --cyan: #06b6d4;
  --emerald: #10b981;
  --amber: #f59e0b;
  --rose: #f43f5e;
  --cf-orange: #f6821f;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: radial-gradient(circle at 15% 10%, rgba(99, 102, 241, 0.16), transparent 40%),
              radial-gradient(circle at 85% 80%, rgba(6, 182, 212, 0.12), transparent 40%),
              var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.4rem;
  background: rgba(9, 13, 24, 0.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand img {
  width: 36px;
  height: 36px;
  border-radius: 10px;
}

.brand-title {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.status-pills {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-main);
  font-weight: 500;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 8px var(--emerald);
}

.dot.orange {
  background: var(--cf-orange);
  box-shadow: 0 0 8px var(--cf-orange);
}

.layout {
  display: grid;
  grid-template-columns: 250px 1fr;
  flex: 1;
  min-height: calc(100vh - 65px);
}

.sidebar {
  background: rgba(11, 16, 29, 0.75);
  border-right: 1px solid var(--border);
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.nav-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  text-align: left;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
}

.nav-btn.active {
  background: rgba(99, 102, 241, 0.16);
  color: #fff;
  border-color: var(--border-accent);
}

.nav-badge {
  font-size: 0.7rem;
  padding: 0.12rem 0.45rem;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.main-content {
  padding: 1.5rem;
  overflow-y: auto;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

.tab-panel {
  display: none;
  flex-direction: column;
  gap: 1.25rem;
}

.tab-panel.active {
  display: flex;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1.2rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem;
  backdrop-filter: blur(10px);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.9rem;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  line-height: 1.45;
}

label {
  display: block;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

input, select, textarea {
  width: 100%;
  background: rgba(7, 11, 20, 0.8);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  font-size: 0.86rem;
  font-family: inherit;
  margin-bottom: 0.85rem;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.58rem 1rem;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  transition: all 0.15s ease;
}

.btn:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-elevated);
  border-color: var(--border);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: rgba(51, 65, 85, 0.8);
}

.btn-cf {
  background: var(--cf-orange);
  color: #fff;
}

.btn-cf:hover {
  background: #fb923c;
}

.btn-emerald {
  background: var(--emerald);
  color: #052e16;
}

.btn-danger {
  background: rgba(244, 63, 94, 0.18);
  border-color: rgba(244, 63, 94, 0.4);
  color: #fda4af;
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.76rem;
}

.btn-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.code-box {
  background: #04070e;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.78rem;
  color: #a5b4fc;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 260px;
  overflow-y: auto;
}

.item-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.item-card {
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.badge {
  font-size: 0.7rem;
  padding: 0.18rem 0.5rem;
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.18);
  color: #c7d2fe;
  border: 1px solid rgba(99, 102, 241, 0.35);
}

.badge.cf {
  background: rgba(246, 130, 31, 0.18);
  color: #fed7aa;
  border-color: rgba(246, 130, 31, 0.4);
}

.badge.green {
  background: rgba(16, 185, 129, 0.16);
  color: #a7f3d0;
  border-color: rgba(16, 185, 129, 0.35);
}

.chat-box {
  height: 330px;
  overflow-y: auto;
  background: rgba(4, 7, 14, 0.75);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.chat-msg {
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  font-size: 0.85rem;
  line-height: 1.45;
  max-width: 90%;
  white-space: pre-wrap;
}

.chat-msg.user {
  align-self: flex-end;
  background: rgba(99, 102, 241, 0.25);
  border: 1px solid rgba(99, 102, 241, 0.45);
}

.chat-msg.assistant {
  align-self: flex-start;
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid var(--border);
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0.45rem;
  max-height: 170px;
  overflow-y: auto;
  padding: 0.6rem;
  background: rgba(4, 7, 14, 0.65);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.85rem;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  color: var(--text-main);
  cursor: pointer;
}

.check-item input {
  width: auto;
  margin: 0;
}

.toast {
  position: fixed;
  bottom: 1.2rem;
  right: 1.2rem;
  background: #1e293b;
  border: 1px solid var(--accent);
  color: #fff;
  padding: 0.75rem 1.1rem;
  border-radius: 10px;
  font-size: 0.85rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  z-index: 200;
  display: none;
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .nav-btn {
    white-space: nowrap;
    width: auto;
  }
}
