:root {
  --radius-base: 8px;
  --ui-page-gutter: clamp(16px, 2vw, 32px);
  --radius-card: 12px;
  --shadow-card: 0 2px 5px rgba(20, 33, 61, 0.04);
  --padding-card: 20px;
  --color-border: #dce4ed;
  --color-bg-light: #f6f8fb;
  --ui-surface: #ffffff;
  --ui-surface-soft: #f1f5f9;
  --ui-selected: #eaf3ff;
  --color-text-base: var(--ui-ink);
  --color-primary: #0E4DA4;
  --color-secondary: #1E9EFF;
  --ui-ink: #193e53;
  --ui-muted: #5b6d83;
  --ui-subtle: #728198;
  --ui-link: var(--brand-primary, #0E4DA4);
  --ui-success: #25846b;
  --ui-warning: #97621c;
  --ui-error: #b7443c;
  --ui-success-bg: #e5f5ef;
  --ui-warning-bg: #fcf4e5;
  --ui-error-bg: #fcecea;
  --font-family-code: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
  --font-family-sans: 'Inter', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  --builder-block-event-color: #1554ad;
  --builder-block-event-surface: #e3f2fd;
  --builder-block-event-border: #90caf9;
  --builder-block-content-color: #6b21a8;
  --builder-block-content-surface: #f3e8ff;
  --builder-block-content-border: #c4b5fd;
  --builder-block-validation-color: #1b5e20;
  --builder-block-validation-surface: #e8f5e9;
  --builder-block-validation-border: #a5d6a7;
  --builder-block-issue-color: #92400e;
  --builder-block-issue-surface: #fff8e1;
  --builder-block-issue-border: #f6c960;
  --builder-block-text-color: #424242;
  --builder-block-text-surface: #f5f5f5;
  --builder-block-text-border: #e0e0e0;
  --builder-danger-color: #e53935;
  --builder-danger-border: #d32f2f;
  --builder-danger-hover: #d32f2f;
  --builder-danger-hover-border: #b71c1c;
  --builder-neutral-surface: #ffffff;
  --builder-neutral-hover-surface: #f5f5f5;
  --builder-neutral-border: #dddddd;
  --builder-neutral-hover-border: #cfcfcf;
  --builder-icon-color: #4b5563;
  --builder-import-surface: #f5f5f5;
  --builder-import-border: #e0e0e0;
  --builder-import-hover-surface: #ffffff;
  --builder-import-hover-border: #bdbdbd;
  --builder-import-text: #424242;
}

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

body {
  margin: 0;
  font-family: var(--font-family-sans);
  background: var(--color-bg-light);
  color: var(--color-text-base);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

a:hover {
  color: inherit;
}

.app-shell {
  background: var(--color-bg-light);
  color: var(--color-text-base);
  min-height: 100vh;
}

.app-shell .app-container {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: clamp(16px, 3vw, 32px) var(--ui-page-gutter);
}

.surface-card,
.module-card {
  background: var(--ui-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

.surface-card {
  padding: var(--padding-card);
}

.module-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.module-card .module-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px var(--padding-card);
  background: linear-gradient(
    135deg,
    var(--brand-primary-alpha-08, rgba(14, 77, 164, 0.08)) 0%,
    var(--brand-accent-alpha-04, rgba(30, 158, 255, 0.04)) 100%
  );
  border-bottom: 1px solid var(--color-border);
}

.module-card .module-header-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.module-card .module-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--color-text-base);
}

.module-card .module-subtitle {
  font-size: 0.85rem;
  color: #64748b;
  margin: 0;
}

.module-card .module-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.module-card .module-body {
  padding: var(--padding-card);
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: #ffffff;
}

.event-card .module-header {
  background: linear-gradient(
    135deg,
    var(--theme-event-bg, var(--brand-primary-alpha-12, rgba(14, 77, 164, 0.12))) 0%,
    var(--brand-primary-alpha-04, rgba(14, 77, 164, 0.04)) 100%
  );
}

.content-grouping-card .module-header {
  background: linear-gradient(
    135deg,
    var(--theme-content-bg, rgba(30, 158, 255, 0.12)) 0%,
    var(--brand-accent-alpha-04, rgba(30, 158, 255, 0.04)) 100%
  );
}

.issue-card .module-header {
  background: linear-gradient(135deg, var(--theme-incident-bg, rgba(250, 204, 21, 0.18)) 0%, rgba(250, 204, 21, 0.06) 100%);
}

.validation-card .module-header {
  background: linear-gradient(135deg, rgba(11, 85, 196, 0.15) 0%, rgba(11, 85, 196, 0.05) 100%);
}

.app-shell :where(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="color"]):not([type="range"]), select, textarea) {
  width: 100%;
  border: 1px solid var(--color-border) !important;
  border-radius: var(--radius-base) !important;
  background: #ffffff;
  font-size: 0.92rem;
  color: var(--color-text-base);
  padding: 10px 12px !important;
  min-height: 40px;
  box-shadow: none !important;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.app-shell textarea {
  min-height: 96px;
  padding: 12px 14px !important;
  resize: vertical;
}

.app-shell :where(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="color"]):not([type="range"]), select, textarea):focus-visible {
  outline: 2px solid var(--ui-link);
  outline-offset: 2px;
}

.app-shell input[type="checkbox"],
.app-shell input[type="radio"] {
  width: 18px;
  height: 18px;
  border-radius: calc(var(--radius-base) / 2);
  border: 1px solid var(--color-border);
  accent-color: var(--brand-primary, var(--color-primary));
}

.button,
[data-theme-button] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  height: 40px;
  padding: 0 16px;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1;
  border-radius: var(--radius-base);
  border: 1px solid transparent;
  background: var(--brand-primary, var(--color-primary));
  color: var(--brand-on-primary, #ffffff);
  cursor: pointer;
  text-decoration: none;
  transition: filter 0.18s ease;
}

.button--secondary {
  background: var(--brand-secondary, var(--color-secondary));
  color: var(--brand-on-secondary, #ffffff);
}

.button--ghost {
  background: #ffffff;
  color: var(--color-text-base);
  border-color: var(--color-border);
}

.button--ghost:hover {
  background: var(--color-bg-light);
}

.button--danger {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fecaca;
}

.button--light {
  background: var(--color-bg-light);
  color: var(--color-text-base);
  border-color: var(--color-border);
}

.upload-field {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.upload-field .upload-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.upload-field .upload-hint {
  margin: 0;
  font-size: 0.8rem;
  color: #64748b;
}

.upload-preview-box {
  width: 100%;
  max-width: 240px;
  min-height: 128px;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-base);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg-light);
  position: relative;
  overflow: hidden;
  padding: 8px;
}

.upload-preview-box img {
  max-width: 100%;
  max-height: 100%;
  border-radius: calc(var(--radius-base) - 2px);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.15);
}

.upload-empty {
  font-size: 0.8rem;
  color: #94a3b8;
  text-align: center;
}

.button--sm {
  height: 32px;
  padding: 0 12px;
  font-size: 0.75rem;
}

.button--icon {
  width: 32px;
  height: 32px;
  padding: 0;
}

[data-theme-button="primary"] {
  background: var(--brand-primary, var(--color-primary));
  border-color: var(--brand-primary, var(--color-primary));
  color: var(--brand-on-primary, var(--theme-primary-contrast, #ffffff));
}

[data-theme-button="secondary"] {
  background: var(--brand-secondary, var(--color-secondary));
  border-color: var(--brand-secondary, var(--color-secondary));
  color: var(--brand-on-secondary, var(--theme-secondary-contrast, #ffffff));
}

[data-theme-button="ghost"] {
  background: transparent;
  border-color: var(--color-border);
  color: var(--color-text-base);
}

[data-theme-button="incident"] {
  background: var(--theme-incident-bg, rgba(250, 204, 21, 0.18));
  border-color: var(--theme-incident-border, rgba(250, 204, 21, 0.4));
  color: var(--color-text-base);
}

.button:hover,
[data-theme-button]:hover {
  filter: brightness(0.98);
}

.button:active,
[data-theme-button]:active {
  filter: none;
}

.button:focus-visible,
[data-theme-button]:focus-visible {
  outline: 2px solid var(--ui-link);
  outline-offset: 2px;
}

.button:disabled,
[data-theme-button]:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.module-actions .button,
.module-actions [data-theme-button] {
  height: 32px;
  padding: 0 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.module-actions .button--danger {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fecaca;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--color-bg-light);
  color: var(--color-text-base);
  border: 1px solid var(--color-border);
}

.stack-sm {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stack-md {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.table-surface {
  border-radius: var(--radius-card);
  border: 1px solid var(--color-border);
  overflow: hidden;
  background: #ffffff;
  box-shadow: var(--shadow-card);
}

.table-surface table {
  width: 100%;
  border-collapse: collapse;
}

.table-surface th {
  text-align: left;
  font-size: 0.8rem;
  font-weight: 600;
  color: #64748b;
  background: var(--ui-surface-soft);
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
}

.table-surface td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.9rem;
  color: var(--color-text-base);
}

@media (max-width: 640px) {
  .module-card .module-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .module-card .module-actions {
    width: 100%;
    justify-content: flex-start;
  }
}


/*
 * Shared text hierarchy and keyboard focus for application screens.
 */
.app-shell {
  --color-text-base: var(--ui-ink);
  --color-primary: var(--brand-primary, #0E4DA4);
  color: var(--ui-ink);
  font-family: var(--font-family-sans);
}
.app-shell :where(h1,h2,h3,h4) {
  font-family: var(--font-family-sans);
  color: inherit;
  letter-spacing: -0.025em;
}
.app-shell :where(p,small,.module-subtitle,.upload-hint) {
  font-family: var(--font-family-sans);
}
.app-shell :where(code,kbd,samp,.technical-key,[data-variable-name]) {
  font-family: var(--font-family-code);
}
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--ui-link);
  outline-offset: 2px;
}
.app-shell .module-card .module-title {color:var(--ui-ink);}
.app-shell .module-card .module-subtitle {color:var(--ui-muted);}
.app-shell .table-surface th {color:var(--ui-muted);}
.app-shell .button--danger {color:var(--ui-error);background:var(--ui-error-bg);}
