:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172026;
  background: #f4f6f7;
  letter-spacing: 0;
  --border: #cfd7dc;
  --muted: #63717a;
  --surface: #ffffff;
  --surface-alt: #eef2f3;
  --accent: #087f72;
  --accent-strong: #05645a;
  --danger: #b42318;
  --warning: #9a6700;
  --focus: #1d4ed8;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: #f4f6f7; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, select, input, textarea { border: 1px solid var(--border); border-radius: 4px; }
button { min-height: 36px; padding: 7px 12px; background: var(--surface); cursor: pointer; }
button:hover { background: var(--surface-alt); }
button:disabled { cursor: not-allowed; opacity: .48; }
button.primary { color: white; background: var(--accent); border-color: var(--accent); }
button.primary:hover { background: var(--accent-strong); }
button.danger { color: var(--danger); border-color: #e6aaa5; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 2px;
}

.app-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 18px 28px; background: #1f2a30; color: white; border-bottom: 3px solid var(--accent); }
.app-header h1 { margin: 0; font-size: 22px; font-weight: 650; }
.status-line { margin: 5px 0 0; color: #c7d1d6; font-size: 13px; }
.header-actions, .inline-form, .toolbar, .dialog-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tabs { display: flex; gap: 0; padding: 0 28px; background: var(--surface); border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab { border: 0; border-bottom: 3px solid transparent; border-radius: 0; padding: 12px 16px; background: transparent; white-space: nowrap; }
.tab.is-active { border-bottom-color: var(--accent); color: var(--accent-strong); font-weight: 650; }
main { width: min(1600px, 100%); margin: 0 auto; }
.view { display: none; padding: 24px 28px 40px; }
.view.is-active { display: block; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.section-heading h2 { margin: 0; font-size: 19px; }
.section-heading p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.toolbar { padding: 10px 0; color: var(--muted); font-size: 13px; }
.toolbar input[type="search"] { width: min(360px, 100%); }
input[type="search"], select, textarea { padding: 8px 10px; background: var(--surface); color: inherit; }
.file-picker { display: inline-flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); cursor: pointer; }
.file-picker input { width: min(260px, 45vw); border: 0; }
.table-wrap { overflow: auto; border: 1px solid var(--border); background: var(--surface); }
table { width: 100%; border-collapse: collapse; min-width: 900px; }
.wide table { min-width: 1200px; }
th, td { padding: 10px 12px; border-bottom: 1px solid #e2e7ea; text-align: left; vertical-align: top; font-size: 13px; }
th { position: sticky; top: 0; z-index: 1; background: #e8edef; color: #36454d; font-weight: 650; }
tbody tr:hover { background: #f7fafa; }
.check-column { width: 44px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.status { display: inline-block; min-width: 64px; padding: 2px 6px; border-radius: 3px; text-align: center; font-size: 12px; font-weight: 650; background: #e6f4f1; color: #08685e; }
.status.warning { background: #fff2cc; color: var(--warning); }
.status.danger { background: #fee4e2; color: var(--danger); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.actions button { min-height: 30px; padding: 4px 8px; font-size: 12px; }
.empty-state { margin: 0; padding: 28px; text-align: center; border: 1px solid var(--border); color: var(--muted); background: var(--surface); }
.preview-form { display: grid; gap: 14px; max-width: 960px; }
.preview-form label { display: grid; gap: 6px; color: #36454d; font-size: 13px; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.preview-result { margin-top: 22px; border-top: 1px solid var(--border); padding-top: 18px; }
.preview-summary { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.preview-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.preview-columns section { min-width: 0; }
.preview-columns h3 { font-size: 15px; margin: 0 0 8px; }
pre { margin: 0; padding: 14px; min-height: 180px; max-height: 520px; overflow: auto; border: 1px solid var(--border); background: #182126; color: #e8eef1; border-radius: 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
dialog { width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 40px); padding: 0; border: 1px solid #aebbc2; border-radius: 6px; }
dialog::backdrop { background: rgb(15 23 42 / 45%); }
.dialog-shell { display: grid; max-height: calc(100vh - 42px); }
.dialog-heading { display: flex; justify-content: space-between; gap: 16px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.dialog-heading h2 { margin: 0; font-size: 18px; }
.dialog-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.dynamic-controls { display: grid; gap: 14px; padding: 18px 20px; overflow: auto; }
.control-section { display: grid; gap: 9px; padding-bottom: 14px; border-bottom: 1px solid #e5e9eb; }
.control-section h3 { margin: 0; font-size: 14px; }
.control-row { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.2fr); gap: 14px; align-items: center; }
.control-row label { font-size: 13px; }
.control-row small { display: block; color: var(--muted); margin-top: 3px; }
.dialog-actions { justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--border); }
.toast { position: fixed; right: 20px; bottom: 20px; max-width: min(460px, calc(100vw - 40px)); padding: 12px 14px; border-radius: 4px; background: #1f2a30; color: white; box-shadow: 0 8px 28px rgb(15 23 42 / 22%); }
.toast.error { background: #7a271a; }

@media (max-width: 760px) {
  .app-header, .section-heading { align-items: stretch; flex-direction: column; }
  .app-header, .view { padding-left: 16px; padding-right: 16px; }
  .tabs { padding: 0 8px; }
  .header-actions button, .inline-form button { flex: 1; }
  .inline-form { align-items: stretch; }
  .file-picker { width: 100%; flex-direction: column; align-items: flex-start; }
  .file-picker input { width: 100%; }
  .field-grid, .preview-columns { grid-template-columns: 1fr; }
  .control-row { grid-template-columns: 1fr; gap: 6px; }
}
