* {
  box-sizing: border-box;
}

:root {
  --bg: #0f172a;
  --panel: #111827;
  --panel-2: #1f2937;
  --border: #2f3c4f;
  --text: #f3f4f6;
  --muted: #9ca3af;
  --accent: #22c55e;
  --accent-2: #38bdf8;
  --danger: #ef4444;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  --radius: 18px;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(56, 189, 248, 0.10), transparent 24%),
    radial-gradient(circle at top right, rgba(34, 197, 94, 0.10), transparent 25%),
    var(--bg);
  color: var(--text);
}

.app-shell {
  width: min(1400px, calc(100% - 32px));
  margin: 24px auto 40px;
}

.topbar,
.panel {
  background: rgba(17, 24, 39, 0.92);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.topbar {
  padding: 22px;
  margin-bottom: 18px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

.topbar h1 {
  margin: 0 0 8px;
  font-size: 28px;
}

.topbar p {
  margin: 0;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.layout {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 18px;
  margin-bottom: 18px;
}

.panel {
  padding: 18px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-header h2 {
  margin: 0;
  font-size: 22px;
}

.logic-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.meta-box {
  display: grid;
  gap: 14px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 16px;
}

.sections-grid {
  display: grid;
  gap: 16px;
}

.section-card {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
}

.section-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.section-card-header h3 {
  margin: 0;
  font-size: 18px;
}

.rule-list,
.logic-flow {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rule-block,
.logic-block {
  position: relative;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}

.rule-block-top,
.logic-block-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.rule-badge,
.logic-type-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: bold;
}

.rule-badge {
  background: rgba(56, 189, 248, 0.15);
  color: #7dd3fc;
}

.logic-block.condition .logic-type-badge {
  background: rgba(245, 158, 11, 0.14);
  color: #fbbf24;
}

.logic-block.action .logic-type-badge {
  background: rgba(34, 197, 94, 0.14);
  color: #86efac;
}

.rule-actions {
  display: flex;
  gap: 8px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.field:last-child {
  margin-bottom: 0;
}

label {
  font-size: 13px;
  color: var(--muted);
}

input,
textarea {
  width: 100%;
  background: #0b1220;
  color: var(--text);
  border: 1px solid #324155;
  border-radius: 10px;
  padding: 11px 12px;
  font: inherit;
  resize: vertical;
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

.links-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.logic-help {
  margin-bottom: 14px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.025);
}

.logic-help p {
  margin: 0;
  color: var(--muted);
}

.logic-flow {
  min-height: 220px;
  padding: 10px;
  border-radius: 16px;
  border: 1px dashed #3b4b62;
  background: rgba(255, 255, 255, 0.02);
}

.logic-block {
  padding-left: 22px;
}

.logic-connector {
  position: absolute;
  left: 9px;
  top: -14px;
  bottom: -14px;
  width: 4px;
  background: linear-gradient(to bottom, rgba(56, 189, 248, 0.25), rgba(34, 197, 94, 0.25));
  border-radius: 999px;
}

.logic-block:first-child .logic-connector {
  top: 22px;
}

.logic-block:last-child .logic-connector {
  bottom: 22px;
}

.btn,
.icon-btn {
  border: none;
  cursor: pointer;
  transition: 0.18s ease;
  font: inherit;
}

.btn {
  min-height: 40px;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: bold;
}

.btn-primary {
  background: var(--accent);
  color: #06210f;
}

.btn-primary:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.btn-secondary {
  background: #223047;
  color: var(--text);
}

.btn-secondary:hover {
  background: #2a3b56;
}

.btn-small {
  min-height: 34px;
  padding: 8px 10px;
  border-radius: 10px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #0b1220;
  color: var(--text);
  border: 1px solid #334155;
}

.icon-btn:hover {
  background: #162033;
}


.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 22px 10px;
  border: 1px dashed #3b4b62;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
}

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

  .links-row {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
  }
}
.btn-menu {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #0b1220;
  color: var(--text);
  border: 1px solid #334155;
  text-decoration: none;
}

.btn-menu:hover {
  background: #162033;
  transform: translateY(-1px);
}

.writer-panel {
  margin-top: 18px;
}

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

.mini-tool {
  min-height: 34px;
  padding: 8px 10px;
  border-radius: 10px;
}

.writer-editor {
  min-height: 260px;
  padding: 16px;
  background: #ffffff;
  color: #111827;
  border: 1px solid #d1d5db;
  border-radius: 14px;
  outline: none;
  line-height: 1.55;
}

.writer-editor:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

.pdf-render-area {
  position: fixed;
  left: -99999px;
  top: 0;
  width: 190mm;
  background: #ffffff;
  color: #111827;
}
