:root {
  --bg: #F8FAFC;
  --card: #FFFFFF;
  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --text: #0F172A;
  --muted: #64748B;
  --border: #E2E8F0;
  --success: #16A34A;
  --warning: #F59E0B;
  --danger: #DC2626;
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.06);
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  line-height: 1.5;
}

h1,
h2,
h3,
strong {
  margin: 0;
  letter-spacing: -0.02em;
}

h1 {
  font-size: clamp(2rem, 2.7vw, 2.5rem);
  font-weight: 700;
}

h2 {
  font-size: 1.5rem;
  font-weight: 600;
}

h3 {
  font-size: 1.125rem;
  font-weight: 600;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 20% 0%, #dbeafe 0%, #eff6ff 38%, #f8fafc 100%);
}

.auth-card {
  width: min(440px, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 32px;
  display: grid;
  gap: 16px;
}

.badge {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  background: #dbeafe;
  color: #1e3a8a;
}

.dashboard {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--border);
  background: #f1f5f9;
  padding: 24px 16px;
  display: grid;
  gap: 24px;
  align-content: start;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(140deg, #2563eb, #1e40af);
  color: #fff;
  font-weight: 700;
}

.brand strong {
  display: block;
  font-size: 16px;
  font-weight: 700;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
}

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

.project-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 8px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
  scrollbar-width: thin;
}

.project-tabs .menu-btn {
  width: auto;
  flex: 0 0 auto;
  white-space: nowrap;
  border-color: transparent;
  background: transparent;
  color: #475569;
  font-weight: 600;
  padding: 9px 12px;
}

.project-tabs .menu-btn:hover {
  background: #eef2ff;
  color: #1e40af;
}

.project-tabs .menu-btn.active {
  background: #dbeafe;
  border-color: #bfdbfe;
  color: #1d4ed8;
  box-shadow: inset 0 -2px 0 rgba(37, 99, 235, 0.22);
}

.menu-btn {
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 10px 12px;
  text-align: left;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.menu-btn:hover {
  background: #e2e8f0;
}

.menu-btn.active {
  background: #dbeafe;
  color: #1e3a8a;
  border-color: #bfdbfe;
}

.sidebar-footer {
  margin-top: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-soft);
  padding: 12px;
}

.main {
  width: 100%;
  padding: 32px;
  display: grid;
  gap: 24px;
}

.topbar {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.kicker {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.stat {
  min-width: 110px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 10px 12px;
}

.stat span {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.stat strong {
  font-size: 20px;
  font-weight: 700;
}

.content-section {
  animation: fadeUp 0.2s ease;
}

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

.layout {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
}

.layout.two > * {
  grid-column: span 6;
}

.layout.three > * {
  grid-column: span 4;
}

.project-shell > * {
  grid-column: span 12;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 24px;
  transition: all 0.2s ease;
}

.card:hover {
  transform: translateY(-1px);
}

.card-head {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
}

.card-head p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.stack {
  display: grid;
  gap: 12px;
}

.inline-form {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.group-box {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #f8fafc;
  padding: 12px;
}

.label {
  display: inline-block;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.checkbox-list {
  display: grid;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
  padding-right: 4px;
}

.checkbox-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
}

input:not([type='checkbox']):not([type='radio']),
select,
textarea,
button {
  width: 100%;
  font: inherit;
}

input:not([type='checkbox']):not([type='radio']),
select,
textarea {
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
  transition: all 0.2s ease;
}

textarea {
  resize: vertical;
  min-height: 88px;
}

input:not([type='checkbox']):not([type='radio'])::placeholder,
textarea::placeholder {
  color: #94a3b8;
}

input:not([type='checkbox']):not([type='radio']):focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
}

.btn {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

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

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

.btn-secondary {
  background: #0f172a;
  color: #fff;
}

.btn-secondary:hover {
  background: #1e293b;
}

.btn-ghost {
  background: #fff;
  color: #334155;
  border-color: var(--border);
}

.btn-ghost:hover {
  background: #f1f5f9;
}

.btn-danger {
  background: #fff;
  color: var(--danger);
  border-color: #fecaca;
}

.btn-danger:hover {
  background: #fff1f2;
}

.list {
  display: grid;
  gap: 10px;
}

.item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
  transition: all 0.2s ease;
}

.item:hover {
  border-color: #cbd5e1;
}

.item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.tag {
  display: inline-flex;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f8fafc;
  color: #334155;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
}

.status-connected,
.status-sent {
  color: var(--success);
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.status-failed,
.status-danger {
  color: var(--danger);
  border-color: #fecaca;
  background: #fff1f2;
}

.status-running,
.status-pending,
.status-warning {
  color: #a16207;
  border-color: #fde68a;
  background: #fffbeb;
}

.qr-wrap {
  display: grid;
  gap: 10px;
  justify-items: center;
}

.qr-image {
  width: min(320px, 100%);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #fff;
  padding: 12px;
}

.error {
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.empty {
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius);
  background: #f8fafc;
  color: var(--muted);
  font-size: 14px;
  padding: 16px;
  text-align: center;
}

.toast-container {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: grid;
  gap: 8px;
  z-index: 60;
}

.toast {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #fff;
  box-shadow: var(--shadow-soft);
  padding: 10px 12px;
  font-size: 13px;
}

.toast.success {
  border-color: #bbf7d0;
}

.toast.error {
  border-color: #fecaca;
}

.busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.36);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  backdrop-filter: blur(2px);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 65;
  background: rgba(15, 23, 42, 0.5);
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-card {
  width: min(720px, 100%);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 20px;
}

.field-error {
  margin-top: -4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--danger);
}

.field-hint {
  margin-top: -4px;
  font-size: 12px;
  color: var(--muted);
}

.is-invalid {
  border-color: #fca5a5 !important;
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.12) !important;
}

.mobile-menu-btn {
  width: auto;
  display: none;
}

.hidden {
  display: none !important;
}

/* skeleton */
.skeleton {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  background: #e2e8f0;
}

.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

@media (max-width: 1024px) {
  .dashboard {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .dashboard.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .mobile-menu-btn {
    display: inline-flex;
  }

  .main {
    padding: 20px 16px 24px;
  }

  .layout.two > *,
  .layout.three > * {
    grid-column: span 12;
  }

  .item-actions .btn,
  .inline-form .btn {
    width: 100%;
  }
}
