:root {
  --color-bg: #f4f5f7;
  --color-surface: #ffffff;
  --color-border: #dcdfe4;
  --color-text: #1f2430;
  --color-text-muted: #6b7280;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-danger: #dc2626;
  --color-danger-hover: #b91c1c;
  --radius: 6px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
}

header.app-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

header.app-header h1 {
  font-size: 16px;
  margin: 0;
}

header.app-header a {
  color: var(--color-primary);
  text-decoration: none;
  font-size: 14px;
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px;
}

h2 {
  font-size: 20px;
  margin-top: 0;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.app-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.app-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
}

.app-list li:last-child {
  border-bottom: none;
}

.app-list .app-name {
  font-weight: 600;
}

.app-list .app-links a {
  margin-left: 12px;
  font-size: 13px;
}

label {
  display: block;
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--color-surface);
  color: var(--color-text);
}

textarea {
  min-height: 72px;
  resize: vertical;
}

.form-row {
  margin-bottom: 14px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-row input[type="checkbox"] {
  width: auto;
}

button {
  font-size: 14px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--color-primary);
  background: var(--color-primary);
  color: #fff;
  cursor: pointer;
}

button:hover {
  background: var(--color-primary-hover);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

button.secondary {
  background: var(--color-surface);
  color: var(--color-primary);
}

button.secondary:hover {
  background: #eef2ff;
}

button.danger {
  background: var(--color-danger);
  border-color: var(--color-danger);
}

button.danger:hover {
  background: var(--color-danger-hover);
}

button.small {
  padding: 4px 10px;
  font-size: 12px;
}

.field-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
}

.field-row .options-editor {
  grid-column: 1 / -1;
  margin-top: 6px;
}

.option-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #eef2ff;
  border-radius: 999px;
  padding: 2px 4px 2px 10px;
  font-size: 12px;
  margin: 2px 4px 2px 0;
}

.option-chip button {
  padding: 0 6px;
  font-size: 11px;
  border-radius: 999px;
  background: transparent;
  border: none;
  color: var(--color-danger);
}

.option-chip button:hover {
  background: rgba(220, 38, 38, 0.1);
}

table.records-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.records-table th,
table.records-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

table.records-table th {
  color: var(--color-text-muted);
  font-weight: 600;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 16px;
}

.toolbar .form-row {
  margin-bottom: 0;
  min-width: 140px;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--color-text-muted);
}

.error-banner {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  color: #991b1b;
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
  white-space: pre-wrap;
}

.success-banner {
  background: #dcfce7;
  border: 1px solid #86efac;
  color: #166534;
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
  white-space: pre-wrap;
}

.empty-state {
  color: var(--color-text-muted);
  font-size: 13px;
  padding: 20px 0;
  text-align: center;
}

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e5e7eb;
  color: var(--color-text-muted);
}

.orphan-option {
  color: var(--color-text-muted);
}

dialog.form-dialog {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  width: min(520px, 92vw);
}

dialog.form-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

dialog.form-dialog .dialog-body {
  padding: 20px;
}

dialog.form-dialog .dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.upload-dropzone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  color: var(--color-text-muted);
}

.step-indicator {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 12px;
}
