:root {
  --color-navy: #0b2a4a;
  --color-blue: #0b6efd;
  --color-blue-hover: #0956d8;
  --color-bg-page: #f2f4f7;
  --color-border: #d8dde6;
  --color-text: #2d3748;
  --color-muted: #5f6f82;
  --color-white: #ffffff;
  --radius-input: 6px;
  --radius-panel: 8px;
  --shadow-header: 0 1px 0 rgba(0, 0, 0, 0.06);
  --font-stack: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-stack);
  color: var(--color-text);
  background: var(--color-bg-page);
}

.app-header {
  background: var(--color-white);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-header);
}

.header-inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
}

.brand {
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  color: var(--color-navy);
  justify-self: start;
}

.page-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: #111827;
  text-align: center;
}

.header-meta {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.875rem;
}

.user-line {
  color: var(--color-muted);
}

.link-button {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--color-blue);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.link-button:hover {
  color: var(--color-blue-hover);
}

.main {
  position: relative;
  max-width: 720px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 3rem;
  min-height: calc(100vh - 72px);
}

.watermark {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  color: rgba(11, 42, 74, 0.06);
  z-index: 0;
}

.watermark-icon {
  margin-bottom: 0.5rem;
}

.watermark-text {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-align: center;
  max-width: 16rem;
  line-height: 1.35;
}

.panel {
  position: relative;
  z-index: 1;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
  padding: 1.75rem 1.5rem 1.5rem;
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
}

.section-title {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: #374151;
}

.section-hint {
  margin: 0 0 1.25rem;
  font-size: 0.9rem;
  color: var(--color-muted);
}

.dropzone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-input);
  background: #fafbfc;
  padding: 2rem 1.25rem;
  text-align: center;
  transition:
    border-color 0.15s ease,
    background 0.15s ease;
  cursor: pointer;
}

.dropzone:hover,
.dropzone:focus-visible {
  border-color: var(--color-blue);
  outline: none;
}

.dropzone.dragover {
  border-color: var(--color-blue);
  background: rgba(11, 110, 253, 0.06);
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.dropzone-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.dropzone-primary {
  margin: 0;
  font-weight: 600;
  font-size: 1rem;
  color: #374151;
}

.dropzone-secondary {
  margin: 0;
  font-size: 0.85rem;
  color: var(--color-muted);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1.35rem;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: inherit;
  color: var(--color-white);
  background: var(--color-blue);
  border: none;
  border-radius: var(--radius-input);
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-blue-hover);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-secondary {
  flex-shrink: 0;
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-input);
  background: #fff;
  color: var(--color-text);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--color-blue);
  color: var(--color-blue);
}

.btn-secondary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.detdb-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: stretch;
}

.detdb-row .text-input,
.detdb-row .job-code-display {
  flex: 1 1 12rem;
  min-width: 0;
}

.job-code-display {
  display: flex;
  align-items: center;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-input);
  background: #fff;
  font-family: ui-monospace, "Cascadia Code", "Segoe UI Mono", monospace;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text);
}

.detdb-preview {
  margin-top: 0.75rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-input);
  background: #fafbfc;
}

.detdb-preview-title {
  margin: 0 0 0.65rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text);
}

.detdb-preview-list {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(8rem, 38%) 1fr;
  gap: 0.35rem 0.75rem;
  font-size: 0.8125rem;
}

.detdb-preview-list dt {
  margin: 0;
  font-weight: 600;
  color: var(--color-muted);
}

.detdb-preview-list dd {
  margin: 0;
  color: var(--color-text);
  word-break: break-word;
}

.download-results {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-input);
  background: #f0f7ff;
}

.download-results-title {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text);
}

.download-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.download-list li {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.download-link {
  font-weight: 600;
  color: var(--color-blue);
  text-decoration: none;
}

.download-link:hover {
  text-decoration: underline;
}

.download-filename {
  font-size: 0.75rem;
  color: var(--color-muted);
  word-break: break-all;
}

.file-list {
  margin: 1.25rem 0 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-input);
  max-height: 200px;
  overflow: auto;
  background: #fafbfc;
}

.file-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.875rem;
}

.file-list li:last-child {
  border-bottom: none;
}

.file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.remove-file {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--color-blue);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.detdb-fields {
  margin-top: 1.25rem;
  display: grid;
  gap: 0.5rem;
  max-width: 32rem;
}

.field-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-muted);
}

.text-input {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-input);
  font: inherit;
  font-size: 0.875rem;
}

.text-input:focus {
  outline: 2px solid rgba(11, 110, 253, 0.35);
  border-color: var(--color-blue);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-top: 1.25rem;
}

.status {
  font-size: 0.875rem;
  color: var(--color-muted);
}

.status.error {
  color: #b91c1c;
}

.status.success {
  color: #15803d;
}

@media (max-width: 640px) {
  .header-inner {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .brand,
  .header-meta {
    justify-self: center;
  }

  .page-title {
    order: -1;
  }
}
