:root {
  --bg: #f0f3f6;
  --bg-accent: #e4ebf2;
  --surface: #ffffff;
  --ink: #1a2332;
  --muted: #5a6a7a;
  --line: #c8d2dc;
  --brand: #0b5f8a;
  --brand-dark: #084866;
  --danger: #9b2c2c;
  --ok: #1f6b3a;
  --radius: 6px;
  --font: "Segoe UI", "Candara", "Gill Sans", sans-serif;
  --font-display: "Candara", "Segoe UI Semibold", "Trebuchet MS", sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, #d4e6f2 0%, transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 0%, #dfe8e0 0%, transparent 50%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-accent) 100%);
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 3rem;
}

.shell-wide {
  max-width: 1480px;
}

.panel-editor {
  padding: 1.25rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0 1.25rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.75rem;
}

.brand {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--brand-dark);
  letter-spacing: -0.02em;
}

.brand span {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: center;
}

.nav a {
  color: var(--ink);
  font-weight: 500;
}

.nav a.active {
  color: var(--brand);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.user-meta {
  font-size: 0.85rem;
  color: var(--muted);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
}

h1 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  margin: 0 0 0.5rem;
  letter-spacing: -0.02em;
}

.lead {
  color: var(--muted);
  margin: 0 0 1.5rem;
  max-width: 42rem;
}

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

.tile {
  display: block;
  padding: 1.1rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(160deg, #fff 0%, #f7fafc 100%);
  color: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.tile:hover {
  border-color: var(--brand);
  text-decoration: none;
  transform: translateY(-1px);
}

.tile strong {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--brand-dark);
}

.tile small {
  color: var(--muted);
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  border: 1px solid var(--line);
}

.flash-error {
  background: #fdf2f2;
  border-color: #e8bcbc;
  color: var(--danger);
}

.flash-ok {
  background: #f0faf3;
  border-color: #b7d9c3;
  color: var(--ok);
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2rem 1.75rem;
  box-shadow: 0 12px 40px rgba(26, 35, 50, 0.08);
}

.login-card .brand {
  margin-bottom: 1.5rem;
}

.login-card input[type="email"],
.login-card input[type="password"] {
  margin-bottom: 1rem;
}

label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0 0 0.35rem;
}

input[type="email"],
input[type="password"],
input[type="text"],
input[type="number"],
input[type="date"],
select {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font: inherit;
  margin-bottom: 0;
  background: #fff;
}

input:focus,
select:focus {
  outline: 2px solid rgba(11, 95, 138, 0.35);
  border-color: var(--brand);
}

.btn {
  display: inline-block;
  border: none;
  border-radius: var(--radius);
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 600;
  padding: 0.65rem 1.1rem;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover {
  background: var(--brand-dark);
  text-decoration: none;
  color: #fff;
}

.btn-secondary {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn-secondary:hover {
  background: #f7fafc;
  color: var(--ink);
  border-color: var(--brand);
}

.btn-block {
  width: 100%;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.page-head .lead {
  margin-bottom: 0;
}

.gen-form fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem 1.15rem;
  margin: 0 0 1rem;
  background: #fafcfd;
}

.gen-form legend {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--brand-dark);
  padding: 0 0.35rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.85rem 1rem;
}

.field-wide {
  grid-column: 1 / -1;
}

.field-hint {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.steuve-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 0.65rem;
}

.steuve-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem 0.95rem;
  background: #fff;
}

.steuve-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.steuve-list-actions {
  margin-top: 0.85rem;
}

.fieldset-subhead {
  margin: 1.1rem 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text, #1a2332);
}

.fieldset-subhead:first-of-type {
  margin-top: 0.35rem;
}

.fieldset-subhead-sm {
  margin: 0.75rem 0 0.35rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--muted);
}

.pv-bestand-block {
  margin: 0.35rem 0 0.5rem;
  padding: 0.65rem 0.85rem 0.85rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: #fafbfc;
}

.btn-small {
  padding: 0.28rem 0.65rem;
  font-size: 0.82rem;
}

.check-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  margin: 1.6rem 0 0;
}

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

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.5rem;
}

.error-list {
  margin: 0;
  padding-left: 1.1rem;
}

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.65rem 0.55rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.data-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.data-table .actions {
  white-space: nowrap;
  display: flex;
  gap: 0.75rem;
}

.preview-frame {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(45deg, #eef2f6 25%, transparent 25%),
    linear-gradient(-45deg, #eef2f6 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eef2f6 75%),
    linear-gradient(-45deg, transparent 75%, #eef2f6 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-color: #fff;
  padding: 1rem;
  overflow: auto;
}

.preview-frame svg {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}

.tile-badge {
  display: inline-block;
  margin-top: 0.65rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ok);
}

.tile-badge.muted {
  color: var(--muted);
  font-weight: 500;
}

.tile-disabled {
  opacity: 0.72;
}

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

.stub-note {
  margin-top: 1.5rem;
  padding: 1rem 1.1rem;
  background: #f7fafc;
  border-left: 3px solid var(--brand);
  color: var(--muted);
  font-size: 0.95rem;
}

.symbol-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.symbol-card {
  display: flex;
  gap: 0.9rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(160deg, #fff 0%, #f7fafc 100%);
}

.symbol-card.is-editor {
  border-style: dashed;
}

.symbol-preview {
  flex: 0 0 88px;
  width: 88px;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(45deg, #eef2f6 25%, transparent 25%),
    linear-gradient(-45deg, #eef2f6 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eef2f6 75%),
    linear-gradient(-45deg, transparent 75%, #eef2f6 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.symbol-preview img {
  max-width: 72px;
  max-height: 110px;
  display: block;
}

.symbol-missing {
  font-size: 0.75rem;
  color: var(--danger);
  text-align: center;
  padding: 0.5rem;
}

.symbol-meta {
  min-width: 0;
  flex: 1;
}

.symbol-meta strong {
  display: block;
  color: var(--brand-dark);
  margin-bottom: 0.25rem;
}

.symbol-ref {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  word-break: break-all;
  margin-bottom: 0.45rem;
}

.symbol-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.tag {
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--muted);
  background: #fff;
}

.tag-ok {
  border-color: #b7d9c3;
  color: var(--ok);
}

.tag-editor {
  border-color: #d0d7e0;
}

.field-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.8rem;
}

.field-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.15rem 0;
  border-top: 1px solid #e8eef3;
}

.field-list code {
  font-size: 0.78rem;
}

.field-list span {
  color: var(--muted);
  white-space: nowrap;
}

.field-empty {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

@media (max-width: 640px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ----- Editor M5 ----- */
.editor-meta {
  margin-bottom: 1rem;
}

.editor-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 240px;
  gap: 0.85rem;
  align-items: stretch;
  min-height: 640px;
}

.editor-palette,
.editor-props {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fafcfd;
  padding: 0.75rem;
  overflow: auto;
  max-height: 78vh;
}

.editor-palette h2,
.editor-props h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  margin: 0 0 0.65rem;
  color: var(--brand-dark);
}

.editor-props h3 {
  font-size: 0.85rem;
  margin: 1rem 0 0.35rem;
  color: var(--muted);
}

.palette-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.palette-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  padding: 0.35rem 0.45rem;
  cursor: grab;
  font: inherit;
  color: inherit;
}

.palette-item img {
  width: 28px;
  height: 42px;
  object-fit: contain;
  flex-shrink: 0;
}

.palette-item span {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.25;
}

.palette-item small {
  font-weight: 500;
  color: var(--muted);
  font-size: 0.7rem;
}

.palette-item.is-active,
.palette-item:hover {
  border-color: var(--brand);
}

.palette-item.is-editor {
  border-style: dashed;
}

.editor-canvas-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding: 0.45rem 0.65rem;
  border-bottom: 1px solid var(--line);
  background: #f7fafc;
  font-size: 0.85rem;
  color: var(--muted);
}

#editor-canvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: 72vh;
  background: #fff;
  cursor: crosshair;
  touch-action: none;
}

#editor-canvas .port {
  fill: #0b5f8a;
  stroke: #fff;
  stroke-width: 1.5;
  cursor: pointer;
}

#editor-canvas .port.is-active {
  fill: #c45c26;
}

#editor-canvas .port:hover {
  fill: #084866;
}

.editor-help ul {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.prop-field {
  margin-bottom: 0.65rem;
}

.prop-field label {
  font-size: 0.8rem;
}

.prop-field.is-required label::after {
  content: none;
}

.props-validation.is-error {
  color: #8b1e1e;
  font-weight: 600;
}

.inline-form {
  display: inline;
  margin: 0;
  padding: 0;
}

.actions .inline-form {
  display: inline-block;
  margin-left: 0.35rem;
}

button.linkish {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--brand, #0b5f8a);
  cursor: pointer;
  text-decoration: underline;
}

.settings-form {
  max-width: 40rem;
}

.logo-preview {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0.5rem 0;
  padding: 0.75rem;
  background: #f7fafc;
  border: 1px solid var(--line, #c8d2dc);
}

.check-inline {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
}

.tag-editor-plan {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border: 1px dashed var(--line);
  border-radius: 3px;
  color: var(--muted);
}

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

  .editor-palette,
  .editor-props {
    max-height: none;
  }
}
