@import url("https://fonts.googleapis.com/css2?family=Figtree:wght@400;500;600;700&family=Sora:wght@500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap");

:root {
  --ink: #132028;
  --muted: #5c6b73;
  --line: #d5e0e4;
  --surface: #ffffff;
  --surface-2: #f3f7f6;
  --bg0: #dfe9e4;
  --bg1: #c9d9d4;
  --accent: #0b6e63;
  --accent-hover: #095a51;
  --accent-soft: #e3f2ef;
  --warn-bg: #fff6e5;
  --warn-border: #f0d39a;
  --warn-text: #7a5310;
  --danger-soft: #f7ece8;
  --shadow: 0 18px 50px rgba(19, 32, 40, 0.12);
  --radius: 14px;
  --font: "Figtree", system-ui, sans-serif;
  --display: "Sora", "Figtree", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(11, 110, 99, 0.16), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(232, 168, 56, 0.12), transparent 50%),
    linear-gradient(165deg, var(--bg0), var(--bg1));
  padding: 28px 16px 48px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

body.center-page {
  align-items: center;
}

.card {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 28px 24px;
  position: relative;
  overflow: hidden;
  animation: rise 420ms ease both;
}

.card.wide {
  max-width: 720px;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: linear-gradient(180deg, var(--accent), #1fa08f 55%, #e8a838);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.app-header {
  text-align: center;
  margin-bottom: 18px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--accent);
  font-family: var(--display);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.brand-mark::before {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background:
    linear-gradient(135deg, transparent 46%, #fff 46% 54%, transparent 54%),
    linear-gradient(45deg, var(--accent) 50%, #1fa08f 50%);
  box-shadow: 0 0 0 1px rgba(11, 110, 99, 0.2);
}

h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
  line-height: 1.15;
}

.subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.4;
}

.version {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-family: var(--mono);
}

.auth-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.auth-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

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

.auth-logout {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.auth-logout:hover {
  text-decoration: underline;
}

.login-card {
  max-width: 440px;
  text-align: center;
}

.login-error {
  margin: 16px 0 0;
  padding: 10px 12px;
  background: var(--danger-soft);
  border-radius: 10px;
  color: #7a2e1a;
  font-size: 0.9rem;
}

.google-signin-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 22px;
  width: 100%;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s ease;
}

.google-signin-btn:hover {
  background: var(--accent-hover);
}

.login-hint {
  margin-top: 16px;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 14px 0 0;
  padding: 0;
}

.nav-links a {
  text-decoration: none;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.84rem;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.nav-links a:hover {
  background: #d5ebe7;
  border-color: rgba(11, 110, 99, 0.2);
  transform: translateY(-1px);
}

.nav-links a.is-active {
  background: var(--accent);
  color: #fff;
}

.test-branch-banner {
  margin: 16px 0 20px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn-text);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-align: center;
}

.section-title {
  margin: 8px 0 14px;
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #314149;
}

.form-group input[type="email"],
.form-group input[type="number"],
.form-group input[type="text"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--font);
  font-size: 0.95rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.file-drop {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 88px;
  padding: 18px 16px;
  border: 1.5px dashed rgba(11, 110, 99, 0.35);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.85), rgba(243, 247, 246, 0.95));
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.file-drop:hover,
.file-drop.is-dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px rgba(11, 110, 99, 0.1);
}

.file-drop-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  font-size: 0;
}

.file-drop-prompt,
.file-drop-name {
  pointer-events: none;
  text-align: center;
  font-size: 0.92rem;
  line-height: 1.35;
}

.file-drop-prompt {
  color: var(--muted);
}

.file-drop-prompt strong {
  color: var(--accent);
  font-weight: 600;
}

.file-drop-name {
  color: var(--ink);
  font-weight: 600;
  word-break: break-all;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  background: #fff;
  border-color: rgba(11, 110, 99, 0.45);
  box-shadow: 0 0 0 3px rgba(11, 110, 99, 0.12);
}

.form-group textarea {
  min-height: 180px;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.45;
  resize: vertical;
}

.form-group textarea.drivers-area {
  min-height: 200px;
}

.form-group input[type="checkbox"] {
  width: auto;
  accent-color: var(--accent);
  transform: scale(1.1);
  margin-right: 6px;
}

.hint {
  margin-top: 6px;
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--muted);
  line-height: 1.4;
}

.hint code {
  font-family: var(--mono);
  font-size: 0.78rem;
  background: #e8eef0;
  padding: 1px 5px;
  border-radius: 4px;
}

button,
.btn {
  width: 100%;
  padding: 12px 14px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-family: var(--display);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 8px 18px rgba(11, 110, 99, 0.22);
}

button:not(:disabled):hover,
.btn:not(:disabled):hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

button:disabled,
.btn:disabled {
  background: #9dbbb6;
  box-shadow: none;
  cursor: not-allowed;
}

#log.log {
  margin-top: 18px;
  padding: 14px;
  height: 220px;
  overflow-y: auto;
  border-radius: 10px;
  background: #101820;
  color: #7dffa6;
  border: 1px solid #1c2a33;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

#log .log-line {
  margin: 0;
  padding: 1px 0;
}

#log .log-progress {
  color: #f0fff4;
  background: rgba(45, 212, 160, 0.14);
  border-left: 3px solid #2dd4a0;
  padding: 4px 8px;
  margin: 4px 0;
  font-weight: 600;
  letter-spacing: 0.01em;
}

#log .log-phase {
  color: #b8f0ff;
}

#log .log-error {
  color: #ff8e8e;
}

#log .log-warn {
  color: #ffd27d;
}

.more-section {
  margin: 16px 0 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-2);
}

.more-toggle {
  width: 100%;
  padding: 12px 14px;
  background: transparent;
  color: var(--ink);
  border: none;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  box-shadow: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font);
  font-size: 0.92rem;
  font-weight: 600;
}

.more-toggle:hover {
  background: #e8efed;
  transform: none;
}

.more-content {
  padding: 14px;
  background: #fff;
  border-top: 1px solid var(--line);
}

.more-content .form-group:last-child {
  margin-bottom: 0;
}

.relay-section {
  margin-top: 8px;
  padding: 14px;
  border: 1px solid #b7d8d2;
  border-radius: 10px;
  background: var(--accent-soft);
}

.relay-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.relay-section-header h3 {
  margin: 0;
  font-family: var(--display);
  font-size: 0.95rem;
  color: var(--accent);
}

.relay-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.relay-section-desc {
  margin: 0 0 14px;
  color: #4d6762;
  font-size: 0.85rem;
  line-height: 1.4;
}

.relay-section .form-group label {
  color: #1d4f49;
}

.relay-section .form-group:last-child {
  margin-bottom: 0;
}

.relay-section input[type="checkbox"],
.relay-section input[type="number"] {
  accent-color: var(--accent);
}

.relay-section.is-disabled {
  opacity: 0.65;
  background: #f2f2f2;
  border-color: #ddd;
}

.relay-section.is-disabled .relay-section-header h3,
.relay-section.is-disabled .form-group label {
  color: #777;
}

.relay-section.is-disabled .relay-badge {
  background: #999;
}

.conditional-field.is-disabled {
  opacity: 0.65;
}

.conditional-field.is-disabled label {
  color: #999;
}

.mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 0 0 10px;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.mode-btn {
  margin: 0;
  border: none;
  border-radius: 10px;
  padding: 10px 12px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: none;
}

.mode-btn:hover {
  background: rgba(11, 110, 99, 0.08);
  transform: none;
}

.mode-btn.is-active {
  background: var(--accent);
  color: #fff;
}

.mode-hint {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.section-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-head-row .section-title {
  margin-bottom: 8px;
}

.link-btn {
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  box-shadow: none;
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  width: auto;
}

.link-btn:hover {
  text-decoration: underline;
  transform: none;
  background: none;
}

.secondary-btn {
  width: auto;
  margin: 0;
  padding: 10px 14px;
  background: var(--surface);
  color: var(--accent);
  border: 1px solid rgba(11, 110, 99, 0.35);
  box-shadow: none;
}

.secondary-btn:hover {
  background: var(--accent-soft);
}

.type-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.type-chip {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 0.82rem;
}

.type-chip strong {
  font-size: 0.88rem;
}

.type-chip span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.75rem;
}

.inventory-wrap {
  overflow-x: auto;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.inventory-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.inventory-table th,
.inventory-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
}

.inventory-table th:first-child,
.inventory-table td:first-child {
  text-align: left;
}

.inventory-table thead th {
  background: var(--surface-2);
  font-weight: 600;
}

.inventory-table input[type="number"] {
  width: 72px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  text-align: right;
}

.inventory-table tfoot td {
  font-weight: 700;
  background: var(--accent-soft);
  border-bottom: none;
}

.inline-row {
  display: flex;
  gap: 8px;
}

.inline-row input {
  flex: 1;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  background: rgba(19, 32, 40, 0.45);
  overflow-y: auto;
}

.modal[hidden] {
  display: none;
}

.modal-card {
  width: 100%;
  max-width: 640px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

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

.modal-header h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.15rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.type-editor {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
  background: var(--surface-2);
}

.type-editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.type-editor .form-group {
  margin-bottom: 0;
}

.type-editor-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  margin-top: 10px;
}

@media (max-width: 600px) {
  body {
    padding: 16px 12px 32px;
  }
  .card {
    padding: 22px 18px 18px;
  }
  h1 {
    font-size: 1.45rem;
  }
  .type-editor-grid {
    grid-template-columns: 1fr;
  }
}
