:root {
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f8fafc;
  --card: #ffffff;
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

h1 { font-size: 1.5rem; margin: 0 0 0.25rem; }
h2 { font-size: 1.1rem; margin: 0 0 1rem; }
.muted { color: var(--muted); }

.brand { display: flex; align-items: center; gap: 0.5rem; font-weight: 700; letter-spacing: -0.01em; }
.brand .kis { color: var(--accent); }
.brand-mark {
  display: grid; place-items: center;
  width: 1.6rem; height: 1.6rem; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink); font-weight: 800;
}

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

/* Auth */
.auth-page { display: grid; place-items: center; min-height: 100dvh; padding: 1rem; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .brand { margin-bottom: 1.25rem; }
.toggle { margin-top: 1rem; text-align: center; }
.toggle a { color: var(--accent); text-decoration: none; }

/* Forms */
.field { margin-bottom: 0.9rem; }
.field label { display: block; font-size: 0.85rem; color: var(--ink-2); margin-bottom: 0.3rem; }
.field input, .field select, .field textarea {
  width: 100%; padding: 0.55rem 0.65rem;
  border: 1px solid var(--line); border-radius: 8px; font: inherit; color: var(--ink);
  background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.btn {
  padding: 0.55rem 0.9rem; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--ink); font: inherit; cursor: pointer;
}
.btn:hover { background: #f1f5f9; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); width: 100%; }
.btn.primary:hover { filter: brightness(1.05); }
.btn:disabled { opacity: 0.6; cursor: default; }

.error {
  display: none; background: var(--danger-bg); color: var(--danger);
  border: 1px solid #fecaca; border-radius: 8px; padding: 0.6rem 0.75rem; margin-bottom: 0.9rem;
  font-size: 0.9rem;
}
.ok {
  display: none; background: #f0fdf4; color: #166534;
  border: 1px solid #bbf7d0; border-radius: 8px; padding: 0.6rem 0.75rem; margin-bottom: 0.9rem;
  font-size: 0.9rem;
}

/* App */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1.25rem; background: var(--card); border-bottom: 1px solid var(--line);
}
.topbar-right { display: flex; align-items: center; gap: 1rem; }
.obj-select { margin-left: 1rem; padding: 0.35rem 0.6rem; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; }
.kit-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.5rem 0.65rem; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 0.4rem; }
.role-badge { background: #eef2ff; color: var(--accent); border-radius: 999px; padding: 0.1rem 0.55rem; font-size: 0.75rem; font-weight: 600; }
.share-bar { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; background: #eef2ff; border: 1px solid #e0e7ff; border-radius: 8px; padding: 0.5rem 0.65rem; margin-bottom: 1rem; font-size: 0.9rem; }
.share-bar input { flex: 1; min-width: 180px; padding: 0.3rem 0.45rem; border: 1px solid var(--line); border-radius: 6px; font: inherit; background: #fff; }
.share-bar a.btn-sm { text-decoration: none; }
.topbar-right a { text-decoration: none; }
.ws-pill {
  background: #eef2ff; color: var(--accent); border-radius: 999px;
  padding: 0.2rem 0.7rem; font-size: 0.8rem; font-weight: 600;
}

.app-grid {
  display: grid; grid-template-columns: 360px 1fr; gap: 1.25rem;
  max-width: 1100px; margin: 1.5rem auto; padding: 0 1.25rem;
}
@media (max-width: 800px) { .app-grid { grid-template-columns: 1fr; } }

#form-card .btn.primary { width: auto; }
.form-actions { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.25rem; }
.btn-sm {
  padding: 0.25rem 0.55rem; font: inherit; font-size: 0.8rem; cursor: pointer;
  border: 1px solid var(--line); border-radius: 6px; background: #fff;
}
.btn-sm:hover { background: #f1f5f9; }
.btn-sm.danger { color: var(--danger); border-color: #fecaca; }
td.actions { white-space: nowrap; text-align: right; }

/* rich form controls */
.rating .star { font-size: 1.4rem; color: #cbd5e1; cursor: pointer; line-height: 1; }
.rating .star.on { color: #f59e0b; }
.scale { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.scale button, .seg button {
  padding: 0.3rem 0.55rem; border: 1px solid var(--line); background: #fff;
  border-radius: 6px; cursor: pointer; font: inherit;
}
.scale button.on, .seg button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.seg { display: flex; gap: 0.25rem; }
.checks { display: flex; flex-direction: column; gap: 0.3rem; }
.checks .check { font-weight: 400; color: var(--ink); display: flex; align-items: center; gap: 0.35rem; margin: 0; }

/* customize editor */
.entity-item {
  display: block; width: 100%; text-align: left; padding: 0.55rem 0.65rem;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer;
  margin-bottom: 0.4rem; font: inherit;
}
.entity-item:hover { background: #f1f5f9; }
.dict-table { font-size: 0.85rem; min-width: 780px; }
.dict-table th { font-size: 0.7rem; white-space: nowrap; }
.dict-table td { padding: 0.3rem; vertical-align: middle; }
.dict-table input, .dict-table select {
  width: 100%; padding: 0.3rem 0.4rem; border: 1px solid var(--line); border-radius: 6px; font: inherit;
}
.dict-table .c-type { min-width: 150px; }
.dict-table .c-name, .dict-table .c-label, .dict-table .c-def, .dict-table .c-opts { min-width: 88px; }
.dict-table th:nth-child(4), .dict-table th:nth-child(5),
.dict-table td:nth-child(4), .dict-table td:nth-child(5) { width: 40px; text-align: center; }
.dict-table input:disabled { background: #f8fafc; color: #94a3b8; }
code { background: #f1f5f9; padding: 0.1rem 0.3rem; border-radius: 4px; font-size: 0.9em; }

.list-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.list-head h2 { margin: 0; }
.list-actions { display: flex; align-items: center; gap: 0.75rem; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
tbody tr:hover td { background: #f8fafc; }
