*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  margin: 0;
  padding: 0;
  color: #1a1a1a;
  background: #f5f6f8;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---- Top bar ---- */
.top-bar {
  background: #fff;
  border-bottom: 1px solid #e2e5e9;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
.top-bar-title {
  font-size: 16px;
  font-weight: 600;
  color: #1a1a1a;
  letter-spacing: -0.01em;
}
.top-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: #666;
}
.top-bar-user {
  font-weight: 500;
  color: #1a1a1a;
}
.btn-logout {
  padding: 6px 14px;
  background: none;
  color: #c0392b;
  border: 1px solid #e8c4c0;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-logout:hover {
  background: #fdf0ef;
  border-color: #c0392b;
}

/* ---- Login ---- */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 56px);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border: 1px solid #e2e5e9;
  border-radius: 12px;
  padding: 36px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.03);
}
.login-card h2 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.login-subtitle {
  font-size: 13px;
  color: #888;
  margin: 0 0 24px;
}
.login-card label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
  color: #444;
}
.login-card input[type="text"],
.login-card input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 16px;
  border: 1px solid #d5d9df;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: #1a1a1a;
  background: #fafbfc;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.login-card input[type="text"]:focus,
.login-card input[type="password"]:focus {
  border-color: #0a4d8c;
  box-shadow: 0 0 0 3px rgba(10, 77, 140, 0.1);
  background: #fff;
}
.login-card button[type="submit"] {
  width: 100%;
  padding: 10px;
  margin-top: 4px;
  background: #0a4d8c;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
.login-card button[type="submit"]:hover {
  background: #083d6e;
}
.login-card button[type="submit"]:disabled {
  background: #a0b4c8;
  cursor: not-allowed;
}
.login-error {
  color: #c0392b;
  font-size: 13px;
  margin-bottom: 12px;
  display: none;
  background: #fdf0ef;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid #f0d0cc;
}

/* ---- Layout ---- */
.app-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  min-height: calc(100vh - 56px);
}
.app-main {
  padding: 28px 32px 48px;
  min-width: 0;
}

.section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #999;
  margin: 0 0 8px;
}
.component-card {
  background: #fff;
  border: 1px solid #e2e5e9;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 28px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
.component-slot {
  min-height: 60px;
}

.hidden {
  display: none !important;
}

/* ---- Sidebar panel ---- */
.sidebar {
  background: #fff;
  border-left: 1px solid #e2e5e9;
  position: sticky;
  top: 56px;
  align-self: start;
  max-height: calc(100vh - 56px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #ccc transparent;
}
.sidebar::-webkit-scrollbar {
  width: 5px;
}
.sidebar::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}
.sidebar-section {
  padding: 16px;
  border-bottom: 1px solid #eee;
}
.sidebar-section:last-child {
  border-bottom: none;
}
.sidebar-heading {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #999;
  margin: 0 0 12px;
}

/* Theme rows */
.theme-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.theme-row:last-child {
  margin-bottom: 0;
}
.theme-row label {
  font-size: 12px;
  color: #555;
  min-width: 76px;
  flex-shrink: 0;
}
.theme-row input[type="color"] {
  width: 28px;
  height: 28px;
  padding: 2px;
  border: 1px solid #d5d9df;
  border-radius: 6px;
  cursor: pointer;
  background: none;
  flex-shrink: 0;
  transition: border-color 0.15s;
}
.theme-row input[type="color"]:hover {
  border-color: #999;
}
.theme-row input[type="text"].hex-input {
  width: 68px;
  font-size: 11px;
  font-family: "SF Mono", "Fira Code", monospace;
  padding: 5px 6px;
  border: 1px solid #d5d9df;
  border-radius: 6px;
  text-transform: uppercase;
  color: #444;
  background: #fafbfc;
  transition: border-color 0.15s;
  outline: none;
}
.theme-row input[type="text"].hex-input:focus {
  border-color: #0a4d8c;
  background: #fff;
}
.theme-row input[type="range"] {
  flex: 1;
  min-width: 50px;
  accent-color: #0a4d8c;
}
.theme-row .range-value {
  font-size: 11px;
  font-family: "SF Mono", "Fira Code", monospace;
  color: #666;
  min-width: 32px;
  text-align: right;
}
.theme-row select {
  flex: 1;
  font-size: 12px;
  font-family: inherit;
  padding: 5px 8px;
  border: 1px solid #d5d9df;
  border-radius: 6px;
  color: #444;
  background: #fafbfc;
  min-width: 0;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
}
.theme-row select:focus {
  border-color: #0a4d8c;
}
.theme-row input[type="number"] {
  width: 60px;
  font-size: 12px;
  font-family: inherit;
  padding: 5px 8px;
  border: 1px solid #d5d9df;
  border-radius: 6px;
  color: #444;
  background: #fafbfc;
  outline: none;
  transition: border-color 0.15s;
}
.theme-row input[type="number"]:focus {
  border-color: #0a4d8c;
}
.theme-row .unit {
  font-size: 11px;
  color: #999;
}

/* Sidebar actions */
.sidebar-actions {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sidebar-actions .btn {
  display: block;
  width: 100%;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.btn-primary {
  background: #0a4d8c;
  color: #fff;
  border: 1px solid #0a4d8c;
}
.btn-primary:hover {
  background: #083d6e;
  border-color: #083d6e;
}
.btn-secondary {
  background: #fff;
  color: #444;
  border: 1px solid #d5d9df;
}
.btn-secondary:hover {
  background: #f5f6f8;
  border-color: #bbb;
}

/* Labels editor */
.label-group {
  margin-bottom: 4px;
}
.label-group:last-child {
  margin-bottom: 0;
}
.label-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 6px 0;
  user-select: none;
}
.label-group-toggle:hover .toggle-title {
  color: #555;
}
.label-group-toggle .toggle-title {
  font-size: 12px;
  font-weight: 500;
  color: #777;
  transition: color 0.15s;
}
.label-group-toggle .toggle-arrow {
  font-size: 9px;
  color: #bbb;
  transition: transform 0.2s;
}
.label-group-toggle.open .toggle-arrow {
  transform: rotate(90deg);
}
.label-group-body {
  display: none;
  padding: 4px 0 8px;
}
.label-group-body.open {
  display: block;
}
.label-row {
  margin-bottom: 6px;
}
.label-row:last-child {
  margin-bottom: 0;
}
.label-row label {
  display: block;
  font-size: 11px;
  color: #999;
  margin-bottom: 2px;
  font-family: "SF Mono", "Fira Code", monospace;
}
.label-row input[type="text"] {
  width: 100%;
  font-size: 12px;
  font-family: inherit;
  padding: 5px 8px;
  border: 1px solid #d5d9df;
  border-radius: 6px;
  color: #444;
  background: #fafbfc;
  outline: none;
  transition: border-color 0.15s;
}
.label-row input[type="text"]:focus {
  border-color: #0a4d8c;
  background: #fff;
}
.label-row input[type="text"]::placeholder {
  color: #c0c4ca;
}

/* Props editor */
.prop-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.prop-row:last-child {
  margin-bottom: 0;
}
.prop-row label {
  font-size: 12px;
  color: #555;
  flex: 1;
}
.prop-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #0a4d8c;
  cursor: pointer;
  flex-shrink: 0;
}
.prop-row input[type="number"] {
  width: 60px;
  font-size: 12px;
  font-family: inherit;
  padding: 5px 8px;
  border: 1px solid #d5d9df;
  border-radius: 6px;
  color: #444;
  background: #fafbfc;
  outline: none;
  transition: border-color 0.15s;
}
.prop-row input[type="number"]:focus {
  border-color: #0a4d8c;
  background: #fff;
}
.prop-row input[type="text"] {
  width: 140px;
  font-size: 12px;
  font-family: inherit;
  padding: 5px 8px;
  border: 1px solid #d5d9df;
  border-radius: 6px;
  color: #444;
  background: #fafbfc;
  outline: none;
  transition: border-color 0.15s;
}
.prop-row input[type="text"]:focus {
  border-color: #0a4d8c;
  background: #fff;
}
.prop-row input[type="text"]::placeholder {
  color: #c0c4ca;
}
