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

:root {
  --c-bg: #f5f6fa;
  --c-surface: #fff;
  --c-border: #d1d5db;
  --c-primary: #1d4ed8;
  --c-primary-hover: #1e40af;
  --c-text: #1f2937;
  --c-text-light: #6b7280;
  --c-success: #059669;
  --c-error: #dc2626;
  --c-warn: #d97706;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.5;
  min-height: 100vh;
}

header {
  background: var(--c-primary);
  color: #fff;
  padding: 1rem 2rem;
}
.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1100px;
  margin: 0 auto;
}
header h1 { font-size: 1.25rem; font-weight: 600; }
header .subtitle { font-size: .85rem; opacity: .85; }
.header-nav { display: flex; gap: .25rem; }
.header-link {
  color: rgba(255,255,255,.7);
  text-decoration: none;
  padding: .3rem .75rem;
  border-radius: var(--radius);
  font-size: .85rem;
  transition: color .15s, background .15s;
}
.header-link:hover { color: #fff; background: rgba(255,255,255,.1); }
.header-link.active { color: #fff; background: rgba(255,255,255,.15); font-weight: 600; }

main { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem; }

footer {
  text-align: center;
  padding: 1rem;
  font-size: .75rem;
  color: var(--c-text-light);
}

/* Buttons */
.btn {
  display: inline-block;
  padding: .45rem 1rem;
  border: none;
  border-radius: var(--radius);
  font-size: .85rem;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s;
}
.btn-primary { background: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-hover); }
.btn-file {
  padding: .6rem 1.5rem;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(29,78,216,.25);
}
.btn-primary:disabled { background: #93c5fd; cursor: not-allowed; }
.btn-secondary { background: #e5e7eb; color: var(--c-text); }
.btn-secondary:hover { background: #d1d5db; }
.btn-link { background: none; color: var(--c-primary); padding: .2rem .4rem; text-decoration: underline; }

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--c-border);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  background: var(--c-surface);
  transition: border-color .2s, background .2s;
}
.drop-zone.dragover { border-color: var(--c-primary); background: #eff6ff; }
.drop-zone p { margin: .5rem 0; color: var(--c-text-light); }
.file-name { font-weight: 600; color: var(--c-text); }

/* Toolbar */
.toolbar-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: .75rem 1rem;
  background: var(--c-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.toolbar-actions { margin-left: auto; display: flex; gap: .5rem; }

.badge {
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  background: #dbeafe;
  color: var(--c-primary);
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--c-border);
  margin-bottom: 1rem;
}
.tab {
  padding: .5rem 1.2rem;
  border: none;
  background: none;
  font-size: .85rem;
  cursor: pointer;
  color: var(--c-text-light);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--c-text); }
.tab.active { color: var(--c-primary); border-bottom-color: var(--c-primary); font-weight: 600; }

.tab-content {
  background: var(--c-surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
th, td {
  text-align: left;
  padding: .4rem .6rem;
  border-bottom: 1px solid #f0f0f0;
}
th {
  font-weight: 600;
  color: var(--c-text-light);
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  white-space: nowrap;
}
tr:hover td { background: #f9fafb; }

/* Form fields */
.field-group { margin-bottom: 1rem; }
.field-group h3 {
  font-size: .9rem;
  margin-bottom: .5rem;
  padding-bottom: .25rem;
  border-bottom: 1px solid var(--c-border);
  color: var(--c-primary);
}
.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: .5rem .75rem;
}
.field {
  display: flex;
  flex-direction: column;
  gap: .15rem;
}
.field label {
  font-size: .75rem;
  color: var(--c-text-light);
  font-weight: 500;
}
.field input, .field select {
  padding: .35rem .5rem;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  font-size: .85rem;
  background: #fff;
  transition: border-color .15s;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 2px rgba(29,78,216,.15);
}
.field input[readonly] { background: #f9fafb; color: var(--c-text-light); }
.field input.modified { border-color: var(--c-warn); background: #fffbeb; }
.field input.field-error {
  border-color: var(--c-error);
  background: #fef2f2;
  box-shadow: 0 0 0 2px rgba(220,38,38,.15);
}
.field input.field-error:focus {
  border-color: var(--c-error);
  box-shadow: 0 0 0 2px rgba(220,38,38,.25);
}

/* Employee list */
.employee-list { list-style: none; }
.employee-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .5rem .75rem;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: background .15s;
}
.employee-item:hover { background: #f0f7ff; }
.employee-item .emp-index {
  font-size: .75rem;
  color: var(--c-text-light);
  min-width: 2rem;
}
.employee-item .emp-name { font-weight: 600; }
.employee-item .emp-meta { font-size: .8rem; color: var(--c-text-light); margin-left: auto; }
.employee-item.emp-error {
  background: #fef2f2;
  border-left: 3px solid var(--c-error);
}
.employee-item.emp-error .emp-name { color: var(--c-error); }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
  z-index: 100;
  overflow-y: auto;
}
.modal-content {
  background: var(--c-surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 900px;
  box-shadow: 0 10px 40px rgba(0,0,0,.2);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .75rem 1.25rem;
  border-bottom: 1px solid var(--c-border);
}
.modal-header h2 { font-size: 1rem; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--c-text-light);
  line-height: 1;
}
.modal-body { padding: 1.25rem; max-height: 75vh; overflow-y: auto; }

/* Validation results */
.val-ok { background: #ecfdf5; border: 1px solid #a7f3d0; border-radius: var(--radius); padding: 1rem; color: var(--c-success); }
.val-err { background: #fef2f2; border: 1px solid #fecaca; border-radius: var(--radius); padding: 1rem; }
.val-err-item { padding: .3rem 0; font-size: .85rem; color: var(--c-error); }
.val-warn { background: #fffbeb; border: 1px solid #fde68a; border-radius: var(--radius); padding: 1rem; color: var(--c-warn); }
.val-loading { text-align: center; padding: 2rem; color: var(--c-text-light); }
.val-warn a.request-more { color: var(--c-primary); font-weight: 600; }

/* GDPR consent */
.consent-box {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  padding: .75rem 1rem;
}
.consent-label {
  display: flex;
  gap: .6rem;
  align-items: flex-start;
  font-size: .8rem;
  line-height: 1.5;
  color: var(--c-text);
  cursor: pointer;
}
.consent-label input[type="checkbox"] {
  margin-top: .2rem;
  flex-shrink: 0;
}
.backend-status {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .7rem;
  margin-top: .4rem;
  margin-left: 1.6rem;
}
.backend-status::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.backend-ok { color: var(--c-success); }
.backend-ok::before { background: var(--c-success); }
.backend-down { color: var(--c-error); }
.backend-down::before { background: var(--c-error); }

/* Guide page */
.guide-content {
  background: var(--c-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  line-height: 1.7;
  font-size: .9rem;
}
.guide-content h2 {
  font-size: 1.1rem;
  margin: 1.5rem 0 .5rem;
  padding-bottom: .25rem;
  border-bottom: 1px solid var(--c-border);
  color: var(--c-primary);
}
.guide-content h2:first-child { margin-top: 0; }
.guide-content h3 { font-size: .95rem; margin: 1rem 0 .4rem; }
.guide-content p { margin: .4rem 0; }
.guide-content ol, .guide-content ul { margin: .5rem 0; padding-left: 1.5rem; }
.guide-content li { margin: .25rem 0; }
.guide-content details { margin: .4rem 0; }
.guide-content details summary { cursor: pointer; padding: .3rem 0; }
.guide-content details p { padding-left: .5rem; color: var(--c-text-light); }
.guide-content table { margin: .75rem 0; }

/* About box */
.about-box {
  background: var(--c-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-top: .75rem;
  font-size: .85rem;
}
.about-box summary {
  padding: .6rem 1rem;
  cursor: pointer;
  color: var(--c-text-light);
  font-weight: 500;
}
.about-box summary:hover { color: var(--c-text); }
.about-content {
  padding: 0 1rem 1rem;
  line-height: 1.6;
}
.about-content ul {
  margin: .5rem 0;
  padding-left: 1.25rem;
}
.about-content li { margin: .25rem 0; }

/* Editor components */
.editor-section { margin-bottom: .5rem; }
.editor-section-header {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .35rem .5rem;
  background: #f0f4ff;
  border-radius: var(--radius);
  cursor: default;
}
.editor-section-title { font-weight: 600; font-size: .85rem; color: var(--c-primary); }
.editor-toggle {
  background: none;
  border: none;
  font-size: .85rem;
  cursor: pointer;
  color: var(--c-text-light);
  width: 1.2rem;
  text-align: center;
}
.editor-section-body { padding: .5rem 0 .5rem .75rem; border-left: 2px solid #e0e7ff; margin-left: .4rem; }
.editor-section-body.collapsed { display: none; }

.btn-add {
  display: inline-block;
  padding: .3rem .75rem;
  background: #ecfdf5;
  color: var(--c-success);
  border: 1px dashed #a7f3d0;
  border-radius: var(--radius);
  font-size: .8rem;
  cursor: pointer;
  margin: .25rem 0;
  transition: background .15s;
}
.btn-add:hover { background: #d1fae5; }

.btn-remove {
  background: none;
  border: none;
  color: var(--c-error);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 .3rem;
  line-height: 1;
  margin-left: auto;
  opacity: .6;
  transition: opacity .15s;
}
.btn-remove:hover { opacity: 1; }

.editor-repeating { margin: .5rem 0; }
.editor-repeating-header { margin-bottom: .25rem; }
.editor-repeating-list { }
.editor-repeating-item {
  border: 1px solid #e5e7eb;
  border-radius: var(--radius);
  padding: .5rem;
  margin-bottom: .4rem;
  background: #fafbfc;
}
.editor-repeating-item-header {
  display: flex;
  align-items: center;
  gap: .4rem;
  margin-bottom: .3rem;
  font-size: .8rem;
  color: var(--c-text-light);
}

.choice-select {
  padding: .3rem .5rem;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  font-size: .8rem;
  margin: .3rem 0;
  background: #fff;
}

.field select {
  padding: .35rem .5rem;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  font-size: .85rem;
  background: #fff;
}
.field select.modified { border-color: var(--c-warn); background: #fffbeb; }

/* Utilities */
.hidden { display: none !important; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.text-sm { font-size: .8rem; }
.text-light { color: var(--c-text-light); }

section + section { margin-top: 1rem; }

/* Spinner */
.spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid #e5e7eb;
  border-top-color: var(--c-primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  vertical-align: middle;
  margin-right: .4rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
