:root {
  --navy-900: #0f2942;
  --navy-800: #163a5f;
  --navy-700: #1f4e78;
  --teal-600: #0d9488;
  --teal-700: #0f766e;
  --teal-50: #f0fdfa;
  --amber-400: #ffd966;
  --amber-100: #fff8db;
  --amber-700: #b45309;
  --red-600: #dc2626;
  --red-50: #fef2f2;
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-500: #64748b;
  --slate-700: #334155;
  --slate-900: #0f172a;
  --radius: 12px;
  --shadow-sm: 0 1px 3px rgba(15, 41, 66, 0.08);
  --shadow-md: 0 6px 20px rgba(15, 41, 66, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Be Vietnam Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--slate-50);
  color: var(--slate-900);
  line-height: 1.5;
}

/* Header */
.topbar {
  background: linear-gradient(135deg, var(--navy-900) 0%, var(--navy-700) 100%);
  color: #fff;
  padding: 16px 24px;
  box-shadow: 0 2px 12px rgba(15, 41, 66, 0.18);
}

.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.24);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.brand h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand p {
  margin: 2px 0 0;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.82);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge-schema {
  background: rgba(255, 217, 102, 0.18);
  color: var(--amber-400);
  border: 1px solid rgba(255, 217, 102, 0.45);
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

/* Layout */
.container {
  max-width: 1400px;
  margin: 22px auto 60px;
  padding: 0 20px;
}

.card {
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 18px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.16s ease;
  text-decoration: none;
  font-family: inherit;
}

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

.btn-primary {
  background: var(--teal-600);
  color: #fff;
  box-shadow: 0 2px 8px rgba(13, 148, 136, 0.28);
}

.btn-primary:hover:not(:disabled) {
  background: var(--teal-700);
  transform: translateY(-1px);
}

.btn-navy {
  background: var(--navy-700);
  color: #fff;
}

.btn-navy:hover:not(:disabled) {
  background: var(--navy-800);
  transform: translateY(-1px);
}

.btn-outline {
  background: #fff;
  color: var(--slate-700);
  border-color: var(--slate-300);
}

.btn-outline:hover:not(:disabled) {
  background: var(--slate-100);
  border-color: var(--slate-500);
}

.btn-ghost-light {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
  padding: 7px 13px;
  font-size: 13px;
}

.btn-ghost-light:hover {
  background: rgba(255, 255, 255, 0.22);
}

.btn-lg {
  padding: 12px 22px;
  font-size: 15px;
}

/* Upload Zone */
.upload-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.dropzone {
  border: 2px dashed #94a3b8;
  border-radius: 12px;
  padding: 28px 20px;
  text-align: center;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  cursor: pointer;
  transition: all 0.18s ease;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--teal-600);
  background: var(--teal-50);
}

.dropzone-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.dropzone h2 {
  margin: 0 0 6px;
  font-size: 17px;
  color: var(--navy-900);
}

.dropzone p {
  margin: 0;
  font-size: 13.5px;
  color: var(--slate-500);
}

.file-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  background: #e0f2fe;
  color: #0369a1;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}

.secondary-upload {
  border: 1px dashed var(--slate-300);
  border-radius: 10px;
  padding: 12px 16px;
  background: var(--slate-50);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* Action Bar */
.action-bar {
  background: linear-gradient(135deg, #f0fdfa 0%, #eff6ff 100%);
  border: 1px solid #99f6e4;
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.action-bar-info h3 {
  margin: 0 0 4px;
  font-size: 16px;
  color: var(--navy-900);
}

.action-bar-info p {
  margin: 0;
  font-size: 13px;
  color: var(--slate-700);
}

.action-bar-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}

@media (max-width: 960px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 560px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
}

.kpi-card {
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: 11px;
  padding: 15px 18px;
  box-shadow: var(--shadow-sm);
}

.kpi-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--slate-500);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--navy-900);
  margin: 4px 0 2px;
}

.kpi-sub {
  font-size: 12.5px;
  color: var(--slate-500);
}

/* Config Grid */
.config-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 18px;
}

@media (max-width: 1024px) {
  .config-layout {
    grid-template-columns: 1fr;
  }
}

.section-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--navy-900);
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.company-list {
  max-height: 270px;
  overflow-y: auto;
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  padding: 6px;
  background: var(--slate-50);
}

.company-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}

.company-item:hover {
  background: #e2e8f0;
}

.company-item label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  flex: 1;
  min-width: 0;
}

.company-name-txt {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.company-count {
  font-size: 11.5px;
  background: #fff;
  border: 1px solid var(--slate-200);
  padding: 1px 7px;
  border-radius: 999px;
  color: var(--slate-700);
  white-space: nowrap;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

@media (max-width: 768px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--slate-700);
  margin-bottom: 4px;
}

.field input[type="text"],
.field input[type="number"],
.field select,
.search-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--slate-300);
  border-radius: 7px;
  font-size: 13px;
  font-family: inherit;
  color: var(--slate-900);
  background: #fff;
}

.field input:focus,
.field select:focus,
.search-input:focus {
  outline: none;
  border-color: var(--teal-600);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.14);
}

.checkbox-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--slate-200);
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--slate-700);
  cursor: pointer;
}

/* Tabs & Tables */
.tabs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--slate-200);
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.tab-btns {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 10px 16px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--slate-500);
  cursor: pointer;
  border-bottom: 3px solid transparent;
}

.tab-btn.active {
  color: var(--navy-700);
  border-bottom-color: var(--teal-600);
}

.table-wrap {
  overflow-x: auto;
  max-height: 520px;
  border: 1px solid var(--slate-200);
  border-radius: 8px;
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12.5px;
}

th,
td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--slate-200);
  border-right: 1px solid var(--slate-100);
  white-space: nowrap;
  text-align: left;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--navy-700);
  color: #fff;
  font-weight: 600;
}

thead th.col-yellow {
  background: var(--amber-400);
  color: #000;
}

tbody tr:hover {
  background: #f8fafc;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}

.badge-ok {
  background: #dcfce7;
  color: #166534;
}

.badge-warn {
  background: #fef3c7;
  color: #92400e;
}

.badge-err {
  background: #fee2e2;
  color: #991b1b;
}

.badge-info {
  background: #e0f2fe;
  color: #075985;
}

.inline-input {
  padding: 4px 7px;
  border: 1px solid var(--slate-300);
  border-radius: 5px;
  font-size: 12.5px;
  font-family: inherit;
}

.inline-input.err {
  border-color: var(--red-600);
  background: var(--red-50);
}

.hidden {
  display: none !important;
}

/* Loading Toast */
.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  background: var(--navy-900);
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  font-size: 13.5px;
  font-weight: 500;
  z-index: 999;
}
