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

[hidden] { display: none !important; }

:root {
  --color-header-bg: #1a1f2e;
  --color-header-text: #e8eaf0;
  --color-bg: #f4f5f7;
  --color-surface: #ffffff;
  --color-border: #d0d4dc;
  --color-text: #1e2230;
  --color-text-muted: #6b7280;
  --color-primary: #2d4a7a;
  --color-primary-hover: #1e3560;
  --color-primary-text: #ffffff;
  --color-secondary-hover: #e8eaf0;
  --color-error-bg: #fef2f2;
  --color-error-border: #fca5a5;
  --color-error-text: #7f1d1d;
  --color-entity-bar-bg: #f0f2f6;
  --color-entity-border: #c8ccd4;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", "Cascadia Code", "Courier New", monospace;
  --radius: 5px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

body {
  font-family: var(--font-ui);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
.header {
  background: var(--color-header-bg);
  color: var(--color-header-text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 52px;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
}

.header-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.language-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.language-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted, #6b7280);
}

.language-select {
  background: var(--color-surface, #fff);
  color: var(--color-text, #1a1f2e);
  border: 1px solid var(--color-border, #d1d5db);
  border-radius: var(--radius);
  padding: 0.4rem 0.75rem;
  font-size: 0.9rem;
  cursor: pointer;
  appearance: auto;
}

.language-select:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ── Main layout ── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1.5rem 1.5rem;
  gap: 0.75rem;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

.panels {
  display: flex;
  flex: 1;
  gap: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  min-height: 420px;
}

.panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1rem 1.25rem;
  gap: 0.75rem;
}

.panel-divider {
  width: 1px;
  background: var(--color-border);
  flex-shrink: 0;
}

.panel-title {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-muted);
}

/* ── Text areas ── */
.text-area {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--color-text);
  background: #fafbfc;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.75rem;
  resize: none;
  width: 100%;
  transition: border-color 0.15s;
}

.text-area:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(45, 74, 122, 0.12);
}

.text-area[readonly] {
  background: #f7f8fa;
  color: #374151;
  cursor: default;
}

.text-area::placeholder {
  color: #b0b6c2;
}

/* ── Panel actions ── */
.panel-actions {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-ui);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius);
  padding: 0.45rem 1rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-primary-text);
  border-color: var(--color-primary);
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-secondary {
  background: transparent;
  color: var(--color-text);
  border-color: var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-secondary-hover);
}

.btn-secondary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-label {
  display: inline;
}

.btn-loading {
  display: none;
}

/* ── Loading state ── */
.btn--loading .btn-label {
  display: none;
}

.btn--loading .btn-loading {
  display: inline;
}

.btn--loading .btn-icon {
  display: none;
}

/* ── Error bar ── */
.error-bar {
  background: var(--color-error-bg);
  border: 1px solid var(--color-error-border);
  color: var(--color-error-text);
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
  font-size: 0.875rem;
}

/* ── Entity bar ── */
.entity-bar {
  background: var(--color-entity-bar-bg);
  border: 1px solid var(--color-entity-border);
  border-radius: var(--radius);
  padding: 0.55rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  min-height: 40px;
}

.entity-bar-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.entity-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.entity-placeholder {
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

/* ── Entity badges ── */
.entity-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 3px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
}

.entity-badge--PERSON   { background: #e8eff8; color: #1e3a6e; border-color: #b8cce8; }
.entity-badge--PHONE    { background: #eef4ee; color: #1a4a1a; border-color: #a8cca8; }
.entity-badge--EMAIL    { background: #f5f0f8; color: #3d1a5c; border-color: #c8a8e0; }
.entity-badge--ORG      { background: #fdf4e8; color: #5c3800; border-color: #e0c080; }
.entity-badge--LOCATION { background: #f0f4f8; color: #1a3040; border-color: #90b0c8; }
.entity-badge--DATE     { background: #f8f2ee; color: #4a2010; border-color: #d8b098; }
.entity-badge--ID       { background: #f2f2f2; color: #2a2a2a; border-color: #b8b8b8; }
.entity-badge--default  { background: #f0f0f0; color: #303030; border-color: #c0c0c0; }

/* ── Tabs ── */
.tab-bar {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.tab {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.tab:hover:not(.tab--active) {
  background: var(--color-secondary-hover);
  color: var(--color-text);
}

.tab--active {
  background: var(--color-primary);
  color: var(--color-primary-text);
  border-color: var(--color-primary);
}

.tab:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.tab-panel {
  display: none;
  flex-direction: column;
  flex: 1;
  gap: 0.75rem;
}

.tab-panel--active {
  display: flex;
}

/* ── Summary panel ── */
#summary-output {
  flex: 1;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--color-text);
  background: #f7f8fa;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.75rem;
  min-height: 120px;
  white-space: pre-wrap;
  overflow-y: auto;
}

/* ── PDF upload ── */
.upload-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.upload-status {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

/* ── Accessibility ── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Responsive ── */
@media (max-width: 720px) {
  .panels {
    flex-direction: column;
    min-height: auto;
  }

  .panel-divider {
    width: 100%;
    height: 1px;
  }

  .panel {
    min-height: 200px;
  }

  .main-content {
    padding: 0.75rem;
  }
}

/* ── Anonymize progress bar ── */
.anon-progress {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.anon-progress-label {
  font-size: 0.78rem;
  color: var(--color-text-muted, #6b7280);
}

.anon-progress-track {
  height: 6px;
  background: var(--color-border, #e5e7eb);
  border-radius: 999px;
  overflow: hidden;
}

.anon-progress-fill {
  height: 100%;
  background: var(--color-primary, #2d4a7a);
  border-radius: 999px;
  width: 0%;
  transition: width 0.4s ease;
}

/* ── Provider status bar ── */
.provider-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.model-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted, #6b7280);
  flex-shrink: 0;
}

.model-select {
  background: var(--color-surface, #fff);
  color: var(--color-text, #1a1f2e);
  border: 1px solid var(--color-border, #d1d5db);
  border-radius: var(--radius);
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  cursor: pointer;
  appearance: auto;
  max-width: 200px;
}

.model-select:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.model-select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.summary-model-status {
  font-size: 0.78rem;
  color: var(--color-text-muted, #6b7280);
  white-space: nowrap;
}

/* ── Azure config ── */
.azure-config {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem 0.75rem;
  padding: 0.6rem;
  margin-bottom: 0.5rem;
  background: var(--color-bg, #f4f5f7);
  border: 1px solid var(--color-border, #d1d5db);
  border-radius: var(--radius);
}

.azure-config-row {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.azure-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted, #6b7280);
}

.azure-input {
  background: var(--color-surface, #fff);
  color: var(--color-text, #1a1f2e);
  border: 1px solid var(--color-border, #d1d5db);
  border-radius: var(--radius);
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  font-family: var(--font-mono);
}

.azure-input:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.btn-sm {
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
}

.azure-test-status {
  font-size: 0.78rem;
  color: var(--color-text-muted, #6b7280);
  align-self: center;
}

/* ── Drop zone ── */
.drop-zone {
  position: relative;
  flex: 1;
  display: flex;
}

.drop-zone .text-area {
  flex: 1;
}

.drop-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(45, 74, 122, 0.08);
  border: 2px dashed var(--color-primary, #2d4a7a);
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-primary, #2d4a7a);
  pointer-events: none;
  z-index: 10;
}

.drop-zone--active .drop-overlay {
  display: flex;
}

.drop-zone--active .text-area {
  opacity: 0.3;
}

/* ── Small icon buttons ── */
.btn-icon-sm {
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text-muted);
  cursor: pointer;
  flex-shrink: 0;
}

.btn-icon-sm:hover {
  background: var(--color-secondary-hover);
  color: var(--color-text);
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
}

.modal-title {
  font-size: 0.9rem;
  font-weight: 600;
}

.modal-body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
}

.modal-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
}

.modal-input {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
  font-family: var(--font-ui);
}

.modal-input:focus, .modal-textarea:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

.modal-textarea {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.5rem 0.6rem;
  font-size: 0.8rem;
  font-family: var(--font-mono);
  line-height: 1.5;
  resize: vertical;
  min-height: 120px;
}

.modal-hint {
  font-size: 0.72rem;
  color: var(--color-text-muted);
}

.modal-hint code {
  background: var(--color-entity-bar-bg);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  font-size: 0.72rem;
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--color-border);
}

.modal-spacer {
  flex: 1;
}

.btn-danger {
  color: var(--color-error-text);
  border-color: var(--color-error-border);
}

.btn-danger:hover:not(:disabled) {
  background: var(--color-error-bg);
}

/* ── Unified activity log ── */
.activity-log {
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.activity-log-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 0.75rem;
  background: var(--color-entity-bar-bg, #f0f2f6);
  border-bottom: 1px solid var(--color-border);
}

.activity-log-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.btn-copy-log {
  font-size: 0.68rem;
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text-muted);
  cursor: pointer;
  flex-shrink: 0;
}

.btn-copy-log:hover {
  background: var(--color-border);
}

.activity-progress-track {
  flex: 1;
  height: 4px;
  background: var(--color-border, #e5e7eb);
  border-radius: 999px;
  overflow: hidden;
}

.activity-progress-fill {
  height: 100%;
  background: var(--color-primary, #2d4a7a);
  border-radius: 999px;
  width: 0%;
  transition: width 0.4s ease;
}

.activity-progress-label {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  min-width: 3rem;
  text-align: right;
}

.activity-log-output {
  font-size: 0.72rem;
  color: var(--color-text-muted, #6b7280);
  background: var(--color-surface, #fff);
  padding: 0.4rem 0.75rem;
  max-height: 110px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
  font-family: var(--font-mono);
  line-height: 1.5;
}
