* {
  box-sizing: border-box;
}

:root {
  --bg: #0b0f1a;
  --surface: #141926;
  --surface2: #1c2233;
  --input: #1e2538;
  --border: #2a3247;
  --text: #e2e8f0;
  --text2: #7b8bab;
  --text3: #4a5568;
  --blue: #3b82f6;
  --purple: #8b5cf6;
  --green: #10b981;
  --red: #ef4444;
  --yellow: #f59e0b;
  --radius: 12px;
  --radius-sm: 8px;
}

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif;
}

button, input, textarea, pre {
  font: inherit;
}

.hidden {
  display: none !important;
}

.login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(11, 15, 26, 0.98), rgba(20, 25, 38, 0.95));
  backdrop-filter: blur(8px);
  z-index: 9999;
}

.login-screen.hidden {
  display: none;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
  padding: 48px;
  width: 100%;
  max-width: 360px;
}

.login-header {
  text-align: center;
  margin-bottom: 36px;
}

.login-logo {
  font-size: 48px;
  margin-bottom: 16px;
  display: block;
}

.login-header h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.login-header p {
  margin: 6px 0 0;
  color: var(--text2);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: text;
}

.login-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text2);
}

.login-field input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--input);
  color: var(--text);
  padding: 12px 14px;
  outline: none;
  transition: 0.2s ease;
  font-size: 14px;
}

.login-field input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.login-field input::placeholder {
  color: var(--text3);
}

.login-btn {
  background: linear-gradient(135deg, var(--blue), var(--purple));
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: 0.2s ease;
  margin-top: 8px;
}

.login-btn:hover {
  filter: brightness(1.08);
}

.login-btn:active {
  filter: brightness(0.95);
}

.login-error {
  color: var(--red);
  font-size: 12px;
  text-align: center;
  min-height: 16px;
}

.app-screen {
  display: contents;
}

.app-screen.hidden {
  display: none;
}

button {
  cursor: pointer;
}

.app {
  max-width: 1540px;
  height: 100vh;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

.header {
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.25), rgba(139, 92, 246, 0.22));
  color: #fff;
  font-size: 20px;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.brand p {
  margin: 3px 0 0;
  color: var(--text2);
  font-size: 12px;
}

.icon-btn, .ghost-btn, .reset-btn, .toggle-btn {
  border: 1px solid var(--border);
  background: var(--input);
  color: var(--text2);
  border-radius: 10px;
  transition: 0.2s ease;
}

.icon-btn {
  width: 40px;
  height: 40px;
  font-weight: 700;
}

.icon-btn:hover, .ghost-btn:hover, .reset-btn:hover, .toggle-btn:hover {
  background: var(--surface2);
  color: var(--text);
}

.status-bar {
  padding: 11px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text2);
  font-size: 13px;
  white-space: pre-line;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
  flex: 0 0 auto;
}

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(340px, 0.85fr);
  gap: 12px;
}

.panel {
  padding: 16px;
  min-height: 0;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}

.panel-header h2 {
  margin: 0;
  font-size: 14px;
  letter-spacing: 0.02em;
}

.muted {
  color: var(--text3);
  font-size: 12px;
}

.fields-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field, .field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-wide {
  grid-column: 1 / -1;
}

.field-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text2);
}

input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--input);
  color: var(--text);
  padding: 11px 12px;
  outline: none;
  transition: 0.2s ease;
}

input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.field-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #061421;
  background: var(--blue);
  padding: 3px 7px;
  border-radius: 999px;
}

.reset-btn, .toggle-btn {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
}

.reset-btn {
  margin-left: auto;
}

.actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

.primary-btn, .secondary-btn, .ghost-btn {
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 700;
  padding: 10px 14px;
  transition: 0.2s ease;
}

.primary-btn {
  background: var(--blue);
  color: #fff;
}

.primary-btn:hover {
  background: #2563eb;
}

.secondary-btn {
  background: linear-gradient(135deg, var(--purple), var(--blue));
  color: #fff;
  padding-inline: 18px;
  min-width: 160px;
}

.secondary-btn:hover {
  filter: brightness(1.06);
}

.ghost-btn {
  color: var(--text2);
  background: var(--input);
  border-color: var(--border);
  padding: 8px 12px;
}

.side-column {
  display: grid;
  grid-template-rows: 1.05fr 0.95fr;
  gap: 12px;
  min-height: 0;
}

.preview-panel, .log-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.preview {
  margin: 0;
  flex: 1;
  min-height: 0;
  overflow: auto;
  border-radius: 10px;
  padding: 14px;
  background: #101521;
  border: 1px solid var(--border);
  color: #dbeafe;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: Consolas, Monaco, 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.55;
}

.log {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border-radius: 10px;
  padding: 12px;
  background: #101521;
  border: 1px solid var(--border);
  font-family: Consolas, Monaco, 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.55;
}

.log-entry {
  margin-bottom: 8px;
  white-space: pre-wrap;
}

.log-info { color: #7dd3fc; }
.log-success { color: #34d399; }
.log-warning { color: #fbbf24; }
.log-error { color: #f87171; }

.status-success .status-dot { background: var(--green); box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.12); }
.status-warning .status-dot { background: var(--yellow); box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.12); }
.status-error .status-dot { background: var(--red); box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.12); }
.status-info .status-dot { background: var(--blue); box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12); }
.status-copied .status-dot { background: var(--purple); box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.12); }

@media (max-width: 1100px) {
  .app {
    overflow: auto;
    height: auto;
    min-height: 100vh;
  }

  html, body {
    overflow: auto;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .side-column {
    grid-template-rows: auto auto;
  }
}

@media (max-width: 720px) {
  .app { padding: 12px; }
  .header { padding: 14px; }
  .panel { padding: 14px; }
  .fields-grid { grid-template-columns: 1fr; }
  .secondary-btn { width: 100%; }
  .actions { justify-content: stretch; }
  .actions > * { width: 100%; }
}
