:root{
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary: #7c3aed;

  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;

  --shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 10px 24px rgba(15, 23, 42, 0.06);

  --radius: 20px;
  --radius-sm: 14px;
  --max-width: 1180px;
}

*{
  box-sizing: border-box;
}

html{
  font-size: 16px;
}

body{
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a{
  color: inherit;
  text-decoration: none;
}

img{
  display: block;
  max-width: 100%;
}

button,
input,
textarea,
select{
  font: inherit;
}

button{
  cursor: pointer;
}

.container{
  width: min(calc(100% - 32px), var(--max-width));
  margin: 0 auto;
}

.hidden{
  display: none !important;
}

.card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.page-shell{
  min-height: 100vh;
}

.topbar{
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(246, 247, 251, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
}

.topbar-inner{
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand{
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  font-size: 1.08rem;
}

.brand-badge{
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: white;
  font-weight: 800;
  background: linear-gradient(135deg, #22c1c3, #2563eb 55%, #7c3aed);
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.24);
}

.topbar-actions{
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.user-pill{
  padding: 10px 14px;
  border-radius: 999px;
  background: white;
  border: 1px solid var(--border);
  color: var(--muted);
  box-shadow: var(--shadow-soft);
}

.page-main{
  padding: 28px 0 42px;
}

.section-title{
  margin: 0 0 8px;
  font-size: clamp(1.4rem, 2vw, 2rem);
  line-height: 1.1;
}

.section-subtitle{
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.field{
  display: grid;
  gap: 8px;
}

.label{
  display: block;
  margin-bottom: 2px;
  font-weight: 700;
}

.input,
.textarea,
.select{
  width: 100%;
  border: 1px solid var(--border);
  background: white;
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--text);
  outline: none;
}

.input:focus,
.textarea:focus,
.select:focus{
  border-color: #93c5fd;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.08);
}

.textarea{
  min-height: 120px;
  resize: vertical;
}

.form-stack{
  display: grid;
  gap: 16px;
}

.btn{
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 700;
  transition: 0.2s ease;
}

.btn:disabled{
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary{
  background: var(--primary);
  color: white;
}

.btn-primary:hover{
  background: var(--primary-hover);
}

.btn-secondary{
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover{
  background: #f8fafc;
}

.btn-danger{
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.btn-success{
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.status{
  padding: 12px 14px;
  border-radius: 14px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: white;
}

.status.success{
  color: #166534;
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.status.error{
  color: #991b1b;
  background: #fef2f2;
  border-color: #fecaca;
}

.status.info{
  color: #1d4ed8;
  background: #eff6ff;
  border-color: #bfdbfe;
}

.helper{
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.6;
}

.empty-state{
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

.badges{
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge{
  padding: 8px 10px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
  border: 1px solid var(--border);
  background: #f8fafc;
}

.badge.success{
  background: #f0fdf4;
  color: #166534;
  border-color: #bbf7d0;
}

.badge.warn{
  background: #fff7ed;
  color: #9a3412;
  border-color: #fdba74;
}

.badge.info{
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.modal-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.44);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-backdrop.show{
  display: flex;
}

.modal{
  width: min(100%, 900px);
  max-height: min(90vh, 900px);
  overflow: auto;
  background: white;
  border-radius: 24px;
  border: 1px solid var(--border);
  box-shadow: 0 25px 80px rgba(15, 23, 42, 0.2);
  padding: 22px;
}

.modal-head{
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.code-box{
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 16px;
  padding: 16px;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.95rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

@media (max-width: 900px){
  .topbar-inner{
    align-items: flex-start;
    padding: 14px 0;
    flex-direction: column;
  }

  .modal{
    padding: 18px;
  }
}