.kpi-root {
  display: flex;
  flex-direction: column;
  height: 100%;
  font-size: 13px;
  color: #1e2533;
}

.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: #f5f7fa;
  border-bottom: 1px solid #dde2ea;
  flex-shrink: 0;
}

.record-label { font-size: 13px; font-weight: 700; color: #1e2533; }
.action-bar-right { display: flex; gap: 8px; }

.btn-primary {
  padding: 6px 18px; background: #1a73e8; color: #fff; border: none;
  border-radius: 4px; font-size: 12px; font-weight: 600; cursor: pointer;
  &:hover:not(:disabled) { background: #1558b0; }
  &:disabled { opacity: 0.6; cursor: default; }
}

.btn-secondary {
  padding: 6px 14px; background: #fff; color: #5f6b7a; border: 1px solid #dde2ea;
  border-radius: 4px; font-size: 12px; font-weight: 600; cursor: pointer;
  &:hover:not(:disabled) { background: #eef1f6; }
  &:disabled { opacity: 0.5; cursor: default; }
}

.btn-danger {
  padding: 6px 14px; background: #fce8e6; color: #b71c1c; border: 1px solid #f5c6c6;
  border-radius: 4px; font-size: 12px; font-weight: 600; cursor: pointer;
  &:hover:not(:disabled) { background: #f5c6c6; }
  &:disabled { opacity: 0.5; cursor: default; }
}

.save-msg {
  padding: 6px 14px; font-size: 12px; flex-shrink: 0;
  border-bottom: 1px solid transparent;
  &.success { background: #e8f5e9; color: #2e7d32; border-color: #c8e6c9; }
  &.error   { background: #fce8e6; color: #b71c1c; border-color: #f5c6c6; }
}

.loading-overlay {
  padding: 10px 14px; font-size: 12px; color: #5f6b7a;
  background: #f5f7fa; border-bottom: 1px solid #dde2ea; flex-shrink: 0;
}

.form-body { flex: 1; overflow-y: auto; padding: 16px 14px; }

.form-row {
  display: flex; gap: 16px; margin-bottom: 14px; flex-wrap: wrap;
}

.form-field {
  flex: 1; min-width: 160px; display: flex; flex-direction: column; gap: 4px;
  &.form-field-full { flex: unset; width: 100%; min-width: unset; }
}

.field-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.4px; color: #5f6b7a;
}

.required { color: #e53935; }

.field-input {
  padding: 6px 10px; border: 1px solid #ccd3de; border-radius: 4px;
  font-size: 13px; outline: none; width: 100%; box-sizing: border-box;
  &:focus { border-color: #1a73e8; box-shadow: 0 0 0 2px rgba(26,115,232,.15); }
  &.ng-invalid.ng-touched { border-color: #e53935; }
}

.field-textarea { resize: vertical; min-height: 52px; }
.field-hint { font-size: 10px; color: #9eaab6; margin-top: 2px; }
.field-error { font-size: 11px; color: #e53935; margin-top: 2px; }

.section {
  border: 1px solid #dde2ea; border-radius: 6px; padding: 12px 12px 4px;
  margin-bottom: 14px; background: #f9fafc;
}

.section-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.4px; color: #5f6b7a; padding: 0 4px;
}

.subsection-label {
  font-size: 11px; font-weight: 700; color: #1a73e8;
  text-transform: uppercase; letter-spacing: 0.4px;
  margin: 8px 0 6px; padding-left: 2px;
  border-left: 3px solid #1a73e8; padding-left: 8px;
}

// Threshold table
.threshold-hint {
  font-size: 12px; color: #9eaab6; padding: 8px 4px; margin-bottom: 8px;
}

.threshold-table-wrap {
  overflow-x: auto; margin-bottom: 8px;
}

.threshold-table {
  width: 100%; border-collapse: collapse; font-size: 12px;
  th {
    background: #eef1f6; color: #5f6b7a; font-weight: 700;
    text-transform: uppercase; font-size: 10px; letter-spacing: 0.4px;
    padding: 6px 8px; text-align: left; border-bottom: 1px solid #dde2ea;
    white-space: nowrap;
  }
  td { padding: 4px 6px; border-bottom: 1px solid #f0f2f5; vertical-align: middle; }
  tr:last-child td { border-bottom: none; }
  tr:hover td { background: #f5f7fa; }
}

.cell-slno { color: #9eaab6; font-weight: 700; width: 28px; text-align: center; }

.cell-input {
  padding: 4px 8px; border: 1px solid #ccd3de; border-radius: 3px;
  font-size: 12px; outline: none; width: 90px; box-sizing: border-box;
  &:focus { border-color: #1a73e8; }
  &.color-select { width: 80px; padding-left: 4px; }
}

.color-select-wrap {
  display: flex; align-items: center; gap: 6px;
}

.color-dot {
  width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0;
  border: 1px solid rgba(0,0,0,.12);
}

.btn-remove-row {
  background: none; border: none; color: #b71c1c; cursor: pointer;
  font-size: 13px; padding: 2px 6px; border-radius: 3px;
  &:hover { background: #fce8e6; }
}

.btn-add-row {
  margin-top: 4px; padding: 5px 14px;
  background: #e8f0fe; color: #1a73e8; border: 1px solid #c5d8fc;
  border-radius: 4px; font-size: 12px; font-weight: 600; cursor: pointer;
  &:hover { background: #d2e3fc; }
}
