:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #d8dee8;
  --text: #1a2332;
  --muted: #5c6b7f;
  --accent: #2563eb;
  --accent-dim: #1d4ed8;
  --danger: #dc2626;
  --success: #15803d;
  --radius: 10px;
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", "Consolas", monospace;
}

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

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #ffffff 0%, var(--bg) 100%);
}

header h1 {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

header p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
  max-width: 62ch;
}

main {
  padding: 1.25rem 1.5rem 2.5rem;
  max-width: 1280px;
  margin: 0 auto;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: #eef2f7;
  border-bottom: 1px solid var(--border);
}

.panel-head h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.panel-body {
  padding: 1rem;
}

/* Collapsible panels (__uprmap, tags, slots) — closed by default */
details.panel-collapsible > summary {
  list-style: none;
  cursor: pointer;
}

details.panel-collapsible > summary::-webkit-details-marker {
  display: none;
}

details.panel-collapsible > summary.panel-head-collapsible {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

details.panel-collapsible > summary.panel-head-collapsible h2 {
  margin: 0;
  flex: 1;
  text-align: left;
  font-size: 1rem;
  font-weight: 600;
  user-select: none;
}

.panel-collapse-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
}

.panel-collapse-icon::before {
  content: "▸";
  display: block;
  transition: transform 0.2s ease;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1;
}

details.panel-collapsible[open] > summary.panel-head-collapsible .panel-collapse-icon::before {
  transform: rotate(90deg);
}

label.small {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

input[type="text"],
input[type="file"],
select,
textarea {
  width: 100%;
  font-family: inherit;
  font-size: 0.875rem;
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
}

textarea {
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.45;
  resize: vertical;
  min-height: 120px;
}

textarea.code-lg {
  min-height: 320px;
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 720px) {
  .row-2 {
    grid-template-columns: 1fr;
  }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}

.btn:active {
  transform: scale(0.98);
}

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

.btn-primary:hover {
  background: var(--accent-dim);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: rgba(0, 0, 0, 0.05);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(220, 38, 38, 0.35);
}

.btn-danger:hover {
  background: rgba(220, 38, 38, 0.08);
}

.btn-tiny {
  padding: 0.2rem 0.45rem;
  font-size: 0.75rem;
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8125rem;
}

.wide {
  width: 100%;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

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

.hint.error {
  color: var(--danger);
}

.hint.ok {
  color: var(--success);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

th,
td {
  padding: 0.5rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  background: #eef2f7;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: rgba(37, 99, 235, 0.04);
}

td input,
td select {
  min-width: 0;
}

td .leaf {
  min-width: 200px;
  font-family: var(--mono);
  font-size: 0.75rem;
}

.actions-col {
  width: 72px;
  text-align: center;
}

.export-bar {
  position: sticky;
  bottom: 0;
  margin: 1.5rem -1.5rem -2.5rem;
  padding: 1rem 1.5rem;
  background: linear-gradient(0deg, var(--bg) 55%, transparent);
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.export-bar .field {
  flex: 1;
  min-width: 180px;
  max-width: 320px;
}

kbd {
  font-family: var(--mono);
  font-size: 0.7rem;
  padding: 0.1rem 0.35rem;
  background: #e8ecf2;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--text);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem 1rem;
  align-items: end;
}

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

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

.checks-line {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  padding-bottom: 0.25rem;
}

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

.code-block {
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.45;
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
}

.cards-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafbfc;
  overflow: hidden;
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: #eef2f7;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.card-body {
  padding: 0.75rem;
}

.sub-head {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0.75rem 0 0.4rem;
}

.sub-head:first-child {
  margin-top: 0;
}

.grid-slot-core {
  display: grid;
  grid-template-columns: 2fr 1fr 0.7fr 0.6fr 1.5fr 1fr 1.2fr 1.2fr;
  gap: 0.5rem;
  align-items: end;
}

@media (max-width: 1100px) {
  .grid-slot-core {
    grid-template-columns: 1fr 1fr;
  }
}

.slot-details {
  border-top: 1px solid var(--border);
  margin-top: 0.75rem;
  padding-top: 0.5rem;
}

.slot-details summary {
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--accent);
  padding: 0.35rem 0;
  user-select: none;
}

.slot-details summary:hover {
  color: var(--accent-dim);
}

.grid-opt {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  align-items: end;
}

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

.grid-opt-full {
  grid-column: 1 / -1;
}

.mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
}

.mini-table th {
  text-align: left;
  padding: 0.35rem 0.4rem;
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
}

.mini-table td {
  padding: 0.25rem 0.35rem;
}

.row-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-top: 0.35rem;
}

/* Login page */
.login-page {
  margin: 0;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  background: #0f1419;
}

.login-backdrop {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 120% 80% at 50% -20%, rgba(37, 99, 235, 0.35), transparent 50%),
    radial-gradient(ellipse 80% 50% at 100% 50%, rgba(99, 102, 241, 0.12), transparent 45%),
    radial-gradient(ellipse 60% 40% at 0% 80%, rgba(14, 165, 233, 0.1), transparent 40%),
    linear-gradient(180deg, #121820 0%, #0f1419 40%, #0c1016 100%);
  pointer-events: none;
  z-index: 0;
}

.login-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
}

.login-card {
  width: 100%;
  max-width: 420px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06),
    0 24px 48px -12px rgba(0, 0, 0, 0.45),
    0 0 80px -20px rgba(37, 99, 235, 0.25);
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(12px);
}

.login-card-accent {
  height: 4px;
  background: linear-gradient(90deg, #2563eb, #6366f1, #0ea5e9);
}

.login-card-inner {
  padding: 1.75rem 1.75rem 1.5rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07) 0%, rgba(255, 255, 255, 0.02) 100%);
}

.login-brand {
  text-align: center;
  margin-bottom: 1.75rem;
}

.login-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  margin-bottom: 0.75rem;
  border-radius: 12px;
  font-size: 1rem;
  color: #93c5fd;
  background: linear-gradient(145deg, rgba(37, 99, 235, 0.35), rgba(99, 102, 241, 0.15));
  border: 1px solid rgba(147, 197, 253, 0.25);
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.2);
}

.login-title {
  margin: 0 0 0.35rem;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #f1f5f9;
}

.login-subtitle {
  margin: 0;
  font-size: 0.9rem;
  color: #94a3b8;
  line-height: 1.45;
}

.login-mono {
  font-family: var(--mono);
  font-size: 0.82em;
  color: #cbd5e1;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.login-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
}

.login-input {
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(15, 20, 25, 0.65);
  color: #f1f5f9;
  padding: 0.65rem 0.85rem;
  font-size: 0.95rem;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.login-input::placeholder {
  color: #64748b;
}

.login-input:hover {
  border-color: rgba(255, 255, 255, 0.18);
}

.login-input:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.65);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.login-error {
  margin: 0;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  font-size: 0.85rem;
  background: rgba(220, 38, 38, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.25);
  color: #fecaca;
}

.login-submit {
  margin-top: 0.25rem;
  width: 100%;
  padding: 0.7rem 1rem;
  font-weight: 600;
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.login-submit:hover:not(:disabled) {
  filter: brightness(1.06);
}

.login-foot {
  margin: 1.25rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.75rem;
  color: #64748b;
  text-align: center;
  line-height: 1.5;
}

.app-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #ffffff 0%, var(--bg) 100%);
}

.app-top h1 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* Boot / auth check overlay (shown until session is verified) */
.auth-boot {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  transition: opacity 0.2s ease;
}

body.auth-booting {
  overflow: hidden;
}

.auth-boot-inner {
  text-align: center;
}

.auth-boot-spinner {
  width: 2.5rem;
  height: 2.5rem;
  margin: 0 auto 1rem;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: auth-spin 0.7s linear infinite;
}

@keyframes auth-spin {
  to {
    transform: rotate(360deg);
  }
}

.auth-boot-text {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
}
